Unix CM: Always use ->storeproc()
[openafs.git] / src / afs / afs_fetchstore.c
index bf00316..dd9c2b8 100644 (file)
@@ -266,6 +266,15 @@ rxfs_storeDestroy(void **r, afs_int32 error)
 
 static
 struct storeOps rxfs_storeUfsOps = {
+#if (defined(AFS_SGI_ENV) && !defined(__c99))
+    rxfs_storeUfsPrepare,
+    rxfs_storeUfsRead,
+    rxfs_storeUfsWrite,
+    rxfs_storeStatus,
+    rxfs_storePadd,
+    rxfs_storeClose,
+    rxfs_storeDestroy
+#else
     .prepare =         rxfs_storeUfsPrepare,
     .read =    rxfs_storeUfsRead,
     .write =   rxfs_storeUfsWrite,
@@ -276,10 +285,20 @@ struct storeOps rxfs_storeUfsOps = {
 #ifdef AFS_LINUX26_ENV
     .storeproc = afs_linux_storeproc
 #endif
+#endif
 };
 
 static
 struct storeOps rxfs_storeMemOps = {
+#if (defined(AFS_SGI_ENV) && !defined(__c99))
+    rxfs_storeMemPrepare,
+    rxfs_storeMemRead,
+    rxfs_storeMemWrite,
+    rxfs_storeStatus,
+    rxfs_storePadd,
+    rxfs_storeClose,
+    rxfs_storeDestroy
+#else
     .prepare = rxfs_storeMemPrepare,
     .read =    rxfs_storeMemRead,
     .write =   rxfs_storeMemWrite,
@@ -287,6 +306,7 @@ struct storeOps rxfs_storeMemOps = {
     .padd =    rxfs_storePadd,
     .close =   rxfs_storeClose,
     .destroy = rxfs_storeDestroy
+#endif
 };
 
 afs_int32
@@ -495,12 +515,8 @@ afs_CacheStoreDCaches(struct vcache *avc, struct dcache **dclist,
 #endif /* AFS_NOSTATS */
        bytesXferred = 0;
 
-       if (ops->storeproc)
-           code = (*ops->storeproc)(ops, rock, tdc, shouldwake,
+       code = (*ops->storeproc)(ops, rock, tdc, shouldwake,
                                     &bytesXferred);
-       else
-            code = afs_GenericStoreProc(ops, rock, tdc, shouldwake,
-                                       &bytesXferred);
 
        afs_Trace4(afs_iclSetp, CM_TRACE_STOREPROC, ICL_TYPE_POINTER, avc,
                    ICL_TYPE_FID, &(avc->f.fid), ICL_TYPE_OFFSET,
@@ -989,6 +1005,22 @@ rxfs_fetchInit(struct afs_conn *tc, struct vcache *avc, afs_offs_t base,
     } else
        code = -1;
 
+    /* We need to cast here, in order to avoid issues if *alength is
+     * negative. Some, older, fileservers can return a negative length,
+     * which the rest of the code deals correctly with. */
+    if (code == 0 && *alength > (afs_int32) size) {
+       /* The fileserver told us it is going to send more data than we
+        * requested. It shouldn't do that, and accepting that much data
+        * can make us take up more cache space than we're supposed to,
+        * so error. */
+       code = rx_Error(v->call);
+       RX_AFS_GUNLOCK();
+       code1 = rx_EndCall(v->call, code);
+       RX_AFS_GLOCK();
+       v->call = NULL;
+       code = EIO;
+    }
+
     if (!code && code1)
        code = code1;