make-storedata-use-unsigned-values-so-quota-cant-get-corrupted-20011203
[openafs.git] / src / viced / afsfileprocs.c
index ac0a9a1..71d102a 100644 (file)
  * privilege"? 
  */
 
+#include <afsconfig.h>
 #include <afs/param.h>
+
+RCSID("$Header$");
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -74,7 +78,7 @@
 #include <rx/rx.h>
 #include <rx/rx_globals.h>
 #include <sys/stat.h>
-#if ! defined(AFS_SGI_ENV) && ! defined(AFS_AIX32_ENV) && ! defined(AFS_NT40_ENV) && ! defined(AFS_LINUX20_ENV)
+#if ! defined(AFS_SGI_ENV) && ! defined(AFS_AIX32_ENV) && ! defined(AFS_NT40_ENV) && ! defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
 #include <sys/map.h>
 #endif
 #if !defined(AFS_NT40_ENV)
@@ -85,7 +89,7 @@
 #include <sys/statfs.h>
 #include <sys/lockf.h>
 #else
-#if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
 #include <sys/dk.h>
 #endif
 #endif
@@ -269,6 +273,7 @@ static CallPreamble(acall, activecall)
     struct client *tclient;
     int retry_flag=1;
     int code = 0;
+    char hoststr[16];
     tconn = rx_ConnectionOf(*acall);
     *acall = (struct rx_call *)tconn;      /* change it! */
 
@@ -308,13 +313,26 @@ retry:
 
     h_Lock_r(thost);
     if (thost->hostFlags & HOSTDELETED) {
-      ViceLog(3,("Discarded a packet for deleted host %08x\n",thost->host));
+      ViceLog(3,("Discarded a packet for deleted host %s\n",afs_inet_ntoa_r(thost->host,hoststr)));
       code = VBUSY; /* raced, so retry */
     }
     else if (thost->hostFlags & VENUSDOWN) {
       if (BreakDelayedCallBacks_r(thost)) {
-       ViceLog(0,("BreakDelayedCallbacks FAILED for host %08x which IS UP.  Possible network or routing failure.\n",thost->host));
-       code = -1;
+       ViceLog(0,("BreakDelayedCallbacks FAILED for host %s which IS UP.  Possible network or routing failure.\n",
+               afs_inet_ntoa_r(thost->host, hoststr)));
+       if ( MultiProbeAlternateAddress_r (thost) ) {
+           ViceLog(0, ("MultiProbe failed to find new address for host %s:%d\n",
+                       afs_inet_ntoa_r(thost->host, hoststr), thost->port));
+           code = -1;
+       } else {
+           ViceLog(0, ("MultiProbe found new address for host %s:%d\n",
+                       afs_inet_ntoa_r(thost->host, hoststr), 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)));
+               code = -1;
+           }
+       }
       }
     } else {
        code =  0;
@@ -426,6 +444,51 @@ SRXAFS_FetchData (tcon, Fid, Pos, Len, OutStatus, CallBack, Sync)
     struct AFSVolSync *Sync;           /* synchronization info */
 
 {
+    int code;
+
+    code = common_FetchData (tcon, Fid, Pos, Len, OutStatus,
+                                                 CallBack, Sync, 0);
+    return code;
+}
+
+SRXAFS_FetchData64 (tcon, Fid, Pos, Len, OutStatus, CallBack, Sync)
+    struct rx_connection *tcon;         /* Rx connection handle */
+    struct AFSFid *Fid;                 /* Fid of file to fetch */
+    afs_int64 Pos, Len;                 /* Not implemented yet */
+    struct AFSFetchStatus *OutStatus;   /* Returned status for Fid */
+    struct AFSCallBack *CallBack;       /* If r/w return CB for Fid */
+    struct AFSVolSync *Sync;            /* synchronization info */
+{
+    int code;
+    afs_int32 tPos, tLen;
+
+#ifdef AFS_64BIT_ENV
+    if (Pos + Len > 0x7fffffff)
+        return E2BIG;
+    tPos = Pos;
+    tLen = Len;
+#else /* AFS_64BIT_ENV */
+    if (Pos.high || Len.high)
+        return E2BIG;
+    tPos = Pos.low;
+    tLen = Len.low;
+#endif /* AFS_64BIT_ENV */
+
+    code = common_FetchData (tcon, Fid, tPos, tLen, OutStatus,
+                                                 CallBack, Sync, 1);
+    return code;
+}
+
+common_FetchData (tcon, Fid, Pos, Len, OutStatus, CallBack, Sync, type)
+    struct rx_connection *tcon;         /* Rx connection handle */
+    struct AFSFid *Fid;                 /* Fid of file to fetch */
+    afs_int32 Pos, Len;                 /* Not implemented yet */
+    struct AFSFetchStatus *OutStatus;   /* Returned status for Fid */
+    struct AFSCallBack *CallBack;       /* If r/w return CB for Fid */
+    struct AFSVolSync *Sync;            /* synchronization info */
+    int type;                           /* 32 bit or 64 bit call */
+
+{ 
     Vnode * targetptr =        0;                  /* pointer to vnode to fetch */
     Vnode * parentwhentargetnotdir = 0;            /* parent vnode if vptr is a file */
     Vnode   tparentwhentargetnotdir;       /* parent vnode for GetStatus */
@@ -508,7 +571,7 @@ SRXAFS_FetchData (tcon, Fid, Pos, Len, OutStatus, CallBack, Sync)
 
     /* Check whether the caller has permission access to fetch the data */
     if (errorCode = Check_PermissionRights(targetptr, client, rights,
-                                          CHK_FETCHDATA, 0))
+                                          CHK_FETCHDATA, 0)) 
        goto Bad_FetchData;
 
     /*
@@ -531,10 +594,10 @@ SRXAFS_FetchData (tcon, Fid, Pos, Len, OutStatus, CallBack, Sync)
 
     /* actually do the data transfer */
 #if FS_STATS_DETAILED
-    errorCode = FetchData_RXStyle(volptr, targetptr, tcall, Pos, Len,
+    errorCode = FetchData_RXStyle(volptr, targetptr, tcall, Pos, Len, type,
                                  &bytesToXfer, &bytesXferred);
 #else
-    if (errorCode = FetchData_RXStyle(volptr, targetptr, tcall, Pos, Len))
+    if (errorCode = FetchData_RXStyle(volptr, targetptr, tcall, Pos, Len, type))
        goto Bad_FetchData;
 #endif /* FS_STATS_DETAILED */
 
@@ -620,7 +683,7 @@ SRXAFS_FetchData (tcon, Fid, Pos, Len, OutStatus, CallBack, Sync)
        SetCallBackStruct(AddCallBack(client->host, Fid), CallBack);
     else {
       struct AFSFid myFid;             
-      bzero(&myFid, sizeof(struct AFSFid));
+      memset(&myFid, 0, sizeof(struct AFSFid));
       myFid.Volume = Fid->Volume;
       SetCallBackStruct(AddVolCallBack(client->host, &myFid), CallBack);
       }
@@ -768,8 +831,8 @@ Bad_FetchACL:
  * This routine is called exclusively by SRXAFS_FetchStatus(), and should be
  * merged into it when possible.
  */
-SAFSS_FetchStatus (tcon, Fid, OutStatus, CallBack, Sync)
-    struct rx_connection *tcon;                /* Rx connection handle */
+SAFSS_FetchStatus (tcall, Fid, OutStatus, CallBack, Sync)
+    struct rx_call *tcall;
     struct AFSFid *Fid;                        /* Fid of target file */
     struct AFSFetchStatus *OutStatus;  /* Returned status for the fid */
     struct AFSCallBack *CallBack;      /* if r/w, callback promise for Fid */
@@ -784,6 +847,7 @@ SAFSS_FetchStatus (tcon, Fid, OutStatus, CallBack, Sync)
     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 */
+    struct rx_connection *tcon = rx_ConnectionOf(tcall);
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)  rx_GetSpecific(tcon, rxcon_client_key);
@@ -809,8 +873,11 @@ SAFSS_FetchStatus (tcon, Fid, OutStatus, CallBack, Sync)
     /* Are we allowed to fetch Fid's status? */
     if (targetptr->disk.type != vDirectory) {
       if (errorCode = Check_PermissionRights(targetptr, client, rights,
-                                            CHK_FETCHSTATUS, 0))
-       goto Bad_FetchStatus;
+                                            CHK_FETCHSTATUS, 0)) {
+         if (rx_GetCallAbortCode(tcall) == errorCode) 
+             rx_SetCallAbortCode(tcall, 0);
+         goto Bad_FetchStatus;
+      }
     }
 
     /* set OutStatus From the Fid  */
@@ -821,7 +888,7 @@ SAFSS_FetchStatus (tcon, Fid, OutStatus, CallBack, Sync)
        SetCallBackStruct(AddCallBack(client->host, Fid), CallBack);
     else {
       struct AFSFid myFid;             
-      bzero(&myFid, sizeof(struct AFSFid));
+      memset(&myFid, 0, sizeof(struct AFSFid));
       myFid.Volume = Fid->Volume;
       SetCallBackStruct(AddVolCallBack(client->host, &myFid), CallBack);
       }
@@ -909,9 +976,12 @@ SRXAFS_BulkStatus(tcon, Fids, OutStats, CallBacks, Sync)
 
        /* Are we allowed to fetch Fid's status? */
        if (targetptr->disk.type != vDirectory) {
-         if (errorCode = Check_PermissionRights(targetptr, client, rights,
-                                              CHK_FETCHSTATUS, 0))
-               goto Bad_BulkStatus;
+           if (errorCode = Check_PermissionRights(targetptr, client, rights,
+                                                  CHK_FETCHSTATUS, 0)) {
+               if (rx_GetCallAbortCode(tcall) == errorCode) 
+                   rx_SetCallAbortCode(tcall, 0);
+               goto Bad_BulkStatus;
+           }
        }
 
        /* set OutStatus From the Fid  */
@@ -924,7 +994,7 @@ SRXAFS_BulkStatus(tcon, Fids, OutStats, CallBacks, Sync)
                              &CallBacks->AFSCBs_val[i]);
        else {
          struct AFSFid myFid;          
-         bzero(&myFid, sizeof(struct AFSFid));
+         memset(&myFid, 0, sizeof(struct AFSFid));
          myFid.Volume = tfid->Volume;
          SetCallBackStruct(AddVolCallBack(client->host, &myFid),
                              &CallBacks->AFSCBs_val[i]);
@@ -969,6 +1039,155 @@ Audit_and_Return:
 } /*SRXAFS_BulkStatus*/
 
 
+SRXAFS_InlineBulkStatus(tcon, Fids, OutStats, CallBacks, Sync)
+    struct rx_connection *tcon;
+    struct AFSCBFids *Fids;
+    struct AFSBulkStats *OutStats;
+    struct AFSCBs *CallBacks;
+    struct AFSVolSync *Sync;
+{
+    register int i;
+    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 */
+    Volume * volptr = 0;               /* pointer to the volume */
+    struct client *client;             /* 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_call *tcall = (struct rx_call *) tcon; 
+    AFSFetchStatus *tstatus;
+#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_BULKSTATUS]);
+    FS_LOCK
+    (opP->numOps)++;
+    FS_UNLOCK
+    TM_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 */
+    if (nfiles <= 0) {                  /* Sanity check */
+       errorCode = EINVAL;
+       goto Audit_and_Return;
+    }
+
+    /* allocate space for return output parameters */
+    OutStats->AFSBulkStats_val = (struct AFSFetchStatus *)
+       malloc(nfiles * sizeof(struct AFSFetchStatus));
+    OutStats->AFSBulkStats_len = nfiles;
+    CallBacks->AFSCBs_val = (struct AFSCallBack *)
+       malloc(nfiles * sizeof(struct AFSCallBack));
+    CallBacks->AFSCBs_len = nfiles;
+
+    if (errorCode = CallPreamble((struct rx_call **) &tcon, ACTIVECALL)) {
+       goto Bad_InlineBulkStatus;
+    }
+
+    tfid = Fids->AFSCBFids_val;
+    for (i=0; i<nfiles; i++, tfid++) {
+       /*
+        * Get volume/vnode for the fetched file; caller's rights to it
+        * are also returned
+        */
+       if (errorCode =
+           GetVolumePackage(tcon, tfid, &volptr, &targetptr,
+                            DONTCHECK, &parentwhentargetnotdir, &client,
+                            READ_LOCK, &rights, &anyrights)) {
+           tstatus = &OutStats->AFSBulkStats_val[i];
+           tstatus->errorCode = errorCode;
+           parentwhentargetnotdir = (Vnode *) 0;
+           targetptr = (Vnode *) 0;
+           volptr = (Volume *) 0;
+           continue;
+       }
+
+       /* set volume synchronization information, but only once per call */
+       if (i == nfiles)
+           SetVolumeSync(Sync, volptr);
+
+       /* Are we allowed to fetch Fid's status? */
+       if (targetptr->disk.type != vDirectory) {
+           if (errorCode = Check_PermissionRights(targetptr, client, rights,
+                                                  CHK_FETCHSTATUS, 0)) {
+               tstatus = &OutStats->AFSBulkStats_val[i];
+               tstatus->errorCode = errorCode;
+               PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, volptr);
+               parentwhentargetnotdir = (Vnode *) 0;
+               targetptr = (Vnode *) 0;
+               volptr = (Volume *) 0;
+               continue;
+           }
+       }
+
+       /* set OutStatus From the Fid  */
+       GetStatus(targetptr, &OutStats->AFSBulkStats_val[i],
+                 rights, anyrights, parentwhentargetnotdir);
+
+       /* If a r/w volume, also set the CallBack state */
+       if (VolumeWriteable(volptr))
+           SetCallBackStruct(AddBulkCallBack(client->host, tfid),
+                             &CallBacks->AFSCBs_val[i]);
+       else {
+         struct AFSFid myFid;          
+         memset(&myFid, 0, sizeof(struct AFSFid));
+         myFid.Volume = tfid->Volume;
+         SetCallBackStruct(AddVolCallBack(client->host, &myFid),
+                             &CallBacks->AFSCBs_val[i]);
+       }
+
+       /* put back the file ID and volume */
+       PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, volptr);
+       parentwhentargetnotdir = (Vnode *) 0;
+       targetptr = (Vnode *) 0;
+       volptr = (Volume *) 0;
+    }
+
+Bad_InlineBulkStatus: 
+    /* Update and store volume/vnode and parent vnodes back */
+    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *)0, volptr);
+    CallPostamble(tcon);
+
+#if FS_STATS_DETAILED
+    TM_GetTimeOfDay(&opStopTime, 0);
+    if (errorCode == 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 */
+
+Audit_and_Return:
+    ViceLog(2, ("SAFS_InlineBulkStatus returns %d\n", errorCode)); 
+    osi_auditU (tcall, InlineBulkFetchStatusEvent, errorCode, AUD_FIDS, Fids, AUD_END);
+    return 0;
+
+} /*SRXAFS_InlineBulkStatus*/
+
+
 SRXAFS_FetchStatus (tcon, Fid, OutStatus, CallBack, Sync)
     struct AFSVolSync *Sync;
     struct rx_connection *tcon;                /* Rx connection handle */
@@ -999,7 +1218,7 @@ SRXAFS_FetchStatus (tcon, Fid, OutStatus, CallBack, Sync)
     if (code = CallPreamble((struct rx_call **) &tcon, ACTIVECALL))
        goto Bad_FetchStatus;
 
-    code = SAFSS_FetchStatus (tcon, Fid, OutStatus, CallBack, Sync);
+    code = SAFSS_FetchStatus (tcall, Fid, OutStatus, CallBack, Sync);
 
 Bad_FetchStatus:    
     CallPostamble(tcon);
@@ -1034,9 +1253,9 @@ SRXAFS_StoreData (tcon, Fid, InStatus, Pos, Length, FileLength, OutStatus, Sync)
     struct rx_connection *tcon;                /* Rx connection Handle */
     struct AFSFid *Fid;                        /* Fid of taret file */
     struct AFSStoreStatus *InStatus;   /* Input Status for Fid */
-    afs_int32 Pos;                             /* Not implemented yet */
-    afs_int32 Length;                  /* Length of data to store */
-    afs_int32 FileLength;                      /* Length of file after store */
+    afs_uint32 Pos;                    /* Not implemented yet */
+    afs_uint32 Length;                 /* Length of data to store */
+    afs_uint32 FileLength;             /* Length of file after store */
     struct AFSFetchStatus *OutStatus;  /* Returned status for target fid */
 
 {
@@ -1263,6 +1482,39 @@ Bad_StoreData:
 
 } /*SRXAFS_StoreData*/
 
+SRXAFS_StoreData64 (tcon, Fid, InStatus, Pos, Length, FileLength, OutStatus, Sync)
+    struct AFSVolSync *Sync;
+    struct rx_connection *tcon;         /* Rx connection Handle */
+    struct AFSFid *Fid;                 /* Fid of taret file */
+    struct AFSStoreStatus *InStatus;    /* Input Status for Fid */
+    afs_uint64 Pos;                     /* Not implemented yet */
+    afs_uint64 Length;                  /* Length of data to store */
+    afs_uint64 FileLength;              /* Length of file after store */
+    struct AFSFetchStatus *OutStatus;   /* Returned status for target fid */
+{
+    int code;
+    afs_int32 tPos;
+    afs_int32 tLength;
+    afs_int32 tFileLength;
+
+#ifdef AFS_64BIT_ENV
+    if (FileLength > 0x7fffffff)
+        return E2BIG;
+    tPos = Pos;
+    tLength = Length;
+    tFileLength = FileLength;
+#else /* AFS_64BIT_ENV */
+    if (FileLength.high)
+        return E2BIG;
+    tPos = Pos.low;
+    tLength = Length.low;
+    tFileLength = FileLength.low;
+#endif /* AFS_64BIT_ENV */
+
+    code = SRXAFS_StoreData (tcon, Fid, InStatus, tPos, tLength, tFileLength,
+                                OutStatus, Sync);
+    return code;
+}
 
 SRXAFS_StoreACL (tcon, Fid, AccessList, OutStatus, Sync)
     struct AFSVolSync *Sync;
@@ -2365,15 +2617,15 @@ SAFSS_Symlink (tcon, DirFid, Name, LinkContents, InStatus, OutFid, OutFidStatus,
     }
 
     /*
-     * If we're creating a mount point (owner mode bits sans x bit), we must
-     * have administer access to the directory, too.  Always allow sysadmins
+     * If we're creating a mount point (any x bits clear), we must have
+     * administer access to the directory, too.  Always allow sysadmins
      * to do this.
      */
-    if ((InStatus->Mask & AFS_SETMODE) && !(InStatus->UnixModeBits & 0100)) {
+    if ((InStatus->Mask & AFS_SETMODE) && !(InStatus->UnixModeBits & 0111)) {
        /*
-        * We have a symlink, 'cause we're trying to set the Unix mode bits
-        * to something without the owner x bits (default mode bits if
-        * AFS_SETMODE is false is 0777)
+        * We have a mountpoint, 'cause we're trying to set the Unix mode
+        * bits to something with some x bits missing (default mode bits
+        * if AFS_SETMODE is false is 0777)
         */
        if (VanillaUser(client) && !(rights & PRSFS_ADMINISTER)) {
            errorCode = EACCES;
@@ -2787,7 +3039,7 @@ SAFSS_MakeDir (tcon, DirFid, Name, InStatus, OutFid, OutFidStatus,
     assert((SetAccessList(&targetptr, &volptr, &newACL, &newACLSize,
                          &parentwhentargetnotdir, (AFSFid *)0, 0)) == 0);
     assert(parentwhentargetnotdir == 0);
-    bcopy((char *)VVnodeACL(parentptr), (char *)newACL, VAclSize(parentptr));
+    memcpy((char *)newACL, (char *)VVnodeACL(parentptr), VAclSize(parentptr));
 
     /* update the status for the target vnode */
     Update_TargetVnodeStatus(targetptr, TVS_MKDIR, client, InStatus,
@@ -3448,7 +3700,7 @@ static GetStatistics (tcon, Statistics)
     FS_LOCK
     AFSCallStats.GetStatistics++, AFSCallStats.TotalCalls++;
     FS_UNLOCK
-    bzero(Statistics, sizeof(*Statistics));
+    memset(Statistics, 0, sizeof(*Statistics));
     SetAFSStats(Statistics);
     SetVolumeStats(Statistics);
     SetSystemStats(Statistics);
@@ -3827,7 +4079,7 @@ int SRXAFS_GetXStats(a_call, a_clientVersionNum, a_collectionNumber, a_srvVersio
         */
        dataBytes = sizeof(struct afs_Stats);
        dataBuffP = (afs_int32 *)malloc(dataBytes);
-       bcopy(&afs_cmstats, dataBuffP, dataBytes);
+       memcpy(dataBuffP, &afs_cmstats, dataBytes);
        a_dataP->AFS_CollData_len = dataBytes>>2;
        a_dataP->AFS_CollData_val = dataBuffP;
 #else
@@ -3854,7 +4106,7 @@ int SRXAFS_GetXStats(a_call, a_clientVersionNum, a_collectionNumber, a_srvVersio
 
        dataBytes = sizeof(struct afs_PerfStats);
        dataBuffP = (afs_int32 *)osi_Alloc(dataBytes);
-       bcopy(&afs_perfstats, dataBuffP, dataBytes);
+       memcpy(dataBuffP, &afs_perfstats, dataBytes);
        a_dataP->AFS_CollData_len = dataBytes>>2;
        a_dataP->AFS_CollData_val = dataBuffP;
        break;
@@ -3881,7 +4133,7 @@ int SRXAFS_GetXStats(a_call, a_clientVersionNum, a_collectionNumber, a_srvVersio
 
        dataBytes = sizeof(struct fs_stats_FullPerfStats);
        dataBuffP = (afs_int32 *)osi_Alloc(dataBytes);
-       bcopy(&afs_FullPerfStats, dataBuffP, dataBytes);
+       memcpy(dataBuffP, &afs_FullPerfStats, dataBytes);
        a_dataP->AFS_CollData_len = dataBytes>>2;
        a_dataP->AFS_CollData_val = dataBuffP;
 #endif
@@ -4790,15 +5042,16 @@ PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr, volptr)
  #                       the File Server.
  */
 
-FetchData_RXStyle(volptr, targetptr, Call, Pos, Len, a_bytesToFetchP, a_bytesFetchedP)
+FetchData_RXStyle(volptr, targetptr, Call, Pos, Len, Int64Mode, a_bytesToFetchP, a_bytesFetchedP)
 #else
-FetchData_RXStyle(volptr, targetptr, Call, Pos, Len)
+FetchData_RXStyle(volptr, targetptr, Call, Pos, Len, Int64Mode)
 #endif /* FS_STATS_DETAILED */
 Volume                 * volptr;
 Vnode                  * targetptr;
 register struct rx_call                * Call;
 afs_int32                      Pos;
 afs_int32                      Len;
+afs_int32                      Int64Mode;
 #if FS_STATS_DETAILED
 afs_int32 *a_bytesToFetchP;
 afs_int32 *a_bytesFetchedP;
@@ -4836,6 +5089,8 @@ afs_int32 *a_bytesFetchedP;
         * back to make the cache manager happy...
         */
        tlen = htonl(0);
+        if (Int64Mode)
+            rx_Write(Call, &tlen, sizeof(afs_int32));   /* send 0-length  */
        rx_Write(Call, &tlen, sizeof(afs_int32));       /* send 0-length  */
        return (0);
     }
@@ -4853,6 +5108,10 @@ afs_int32 *a_bytesFetchedP;
     if (Pos + Len > tlen) Len =        tlen - Pos;     /* get length we should send */
     FDH_SEEK(fdP, Pos, 0);
     tlen = htonl(Len);
+    if (Int64Mode) {
+        afs_int32 zero = 0;
+        rx_Write(Call, &zero, sizeof(afs_int32)); /* High order bits */
+    }
     rx_Write(Call, &tlen, sizeof(afs_int32));  /* send length on fetch */
 #if FS_STATS_DETAILED
     (*a_bytesToFetchP) = Len;
@@ -4989,9 +5248,9 @@ StoreData_RXStyle(volptr, targetptr, Fid, client, Call, Pos, Length,
     struct AFSFid *Fid;
     struct client *client;
     register struct rx_call *Call;
-    afs_int32 Pos;
-    afs_int32 Length;
-    afs_int32 FileLength;
+    afs_uint32 Pos;
+    afs_uint32 Length;
+    afs_uint32 FileLength;
     int sync;
 #if FS_STATS_DETAILED
     afs_int32 *a_bytesToStoreP;
@@ -5442,7 +5701,7 @@ RXStore_AccessList(targetptr, AccessList)
        return(EINVAL);
     if ((newACL->size + 4) > VAclSize(targetptr))
        return(E2BIG);
-    bcopy((char *) newACL,(char *) VVnodeACL(targetptr),(int)(newACL->size));
+    memcpy((char *) VVnodeACL(targetptr), (char *) newACL, (int)(newACL->size));
     acl_FreeACL(&newACL);
     return(0);
 
@@ -5489,7 +5748,7 @@ Store_AccessList(targetptr, AccessList)
        return(EINVAL);
     if ((newACL->size + 4) > VAclSize(targetptr))
        return(E2BIG);
-    bcopy((char *) newACL,(char *) VVnodeACL(targetptr),(int)(newACL->size));
+    memcpy((char *) VVnodeACL(targetptr), (char *) newACL, (int)(newACL->size));
     acl_FreeACL(&newACL);
     return(0);
 
@@ -6198,8 +6457,9 @@ void GetStatus(targetptr, status, rights, anyrights, parentptr)
 {
     /* initialize return status from a vnode  */
     status->InterfaceVersion = 1;
-    status->SyncCounter = status->dataVersionHigh = status->spare2 =
-    status->spare3 = status->spare4 = 0;
+    status->SyncCounter = status->dataVersionHigh = status->lockCount =
+    status->errorCode = 0;
+    status->ResidencyMask = 1; /* means for MR-AFS: file in /vicepr-partition */
     if (targetptr->disk.type == vFile)
        status->FileType = File;
     else if (targetptr->disk.type == vDirectory)
@@ -6209,6 +6469,7 @@ void GetStatus(targetptr, status, rights, anyrights, parentptr)
     else
        status->FileType = Invalid;                     /*invalid type field */
     status->LinkCount = targetptr->disk.linkCount;
+    status->Length_hi = 0;
     status->Length = targetptr->disk.length;
     status->DataVersion = targetptr->disk.dataVersion;
     status->Author = targetptr->disk.author;
@@ -6219,10 +6480,10 @@ void GetStatus(targetptr, status, rights, anyrights, parentptr)
     status->ClientModTime = targetptr->disk.unixModifyTime;    /* This might need rework */
     status->ParentVnode = (status->FileType == Directory ? targetptr->vnodeNumber : parentptr->vnodeNumber);
     status->ParentUnique = (status->FileType == Directory ? targetptr->disk.uniquifier : parentptr->disk.uniquifier);
-    status->SegSize = 0;
     status->ServerModTime = targetptr->disk.serverModifyTime;                  
     status->Group = targetptr->disk.group;
-    status->spare2 = targetptr->disk.lock.lockCount;
+    status->lockCount = targetptr->disk.lock.lockCount;
+    status->errorCode = 0;
 
 } /*GetStatus*/
 
@@ -6388,17 +6649,19 @@ int CopyOnWrite(targetptr, volptr)
                        rc = IH_DEC(V_linkHandle(volptr), ino,
                                  V_parentId(volptr));
                        if (!rc ) {
-                           ViceLog(0,("CopyOnWrite failed: volume %u in partition %s needs salvage\n",
-                                   V_id(volptr), volptr->partition->name));
+                           ViceLog(0,("CopyOnWrite failed: error %u after i_dec on disk full, volume %u in partition %s needs salvage\n",
+                                      rc, V_id(volptr), 
+                                      volptr->partition->name));
                            VTakeOffline (volptr);
                        }
                        free(buff);
                        return ENOSPC;
                }
                else {
-                   ViceLog(0,("CopyOnWrite failed: volume %u in partition %s needs salvage\n",
-                           V_id(volptr), volptr->partition->name));
-                   /* Decrement this inode so salvager doesn't find it. */
+                   ViceLog(0,("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));
+                    /* Decrement this inode so salvager doesn't find it. */
                    FDH_REALLYCLOSE(newFdP);
                    IH_RELEASE(newH);
                    FDH_REALLYCLOSE(targFdP);
@@ -6701,7 +6964,7 @@ void SetVolumeStats(stats)
     for (part = DiskPartitionList; part && i < AFS_MSTATDISKS; part = part->next) {
        stats->Disks[i].TotalBlocks = part->totalUsable;
        stats->Disks[i].BlocksAvailable = part->free;
-       bzero(stats->Disks[i].Name, AFS_DISKNAMESIZE);
+       memset(stats->Disks[i].Name, 0, AFS_DISKNAMESIZE);
        strncpy(stats->Disks[i].Name, part->name, AFS_DISKNAMESIZE);
        i++;
     }
@@ -6896,3 +7159,11 @@ SRXAFS_DFSSymlink (tcon, DirFid, Name, LinkContents, InStatus, OutFid, OutFidSta
     return EINVAL;
 }
 
+SRXAFS_ResidencyCmd (tcon, Fid, Inputs, Outputs)
+    struct rx_connection *tcon;
+    struct AFSFid *Fid;
+    struct ResidencyCmdInputs *Inputs;
+    struct ResidencyCmdOutputs *Outputs;
+{
+    return EINVAL;
+}