]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afs: Indicate error from afs_osi_Read/Write better
authorAndrew Deason <adeason@sinenomine.net>
Thu, 22 Dec 2011 20:01:52 +0000 (15:01 -0500)
committerDerrick Brashear <shadow@dementix.org>
Thu, 9 Aug 2012 15:02:22 +0000 (08:02 -0700)
Currently afs_osi_Read and afs_osi_Write just return -1 on any I/O
error, even though they know the error code given from the OS VFS.
Just return that code instead so the caller can see what the error
was; but negate it, so it's clear that it is an error.

Reviewed-on: http://gerrit.openafs.org/6412
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
(cherry picked from commit b5ca12ac4696c4049be14974f1e946bb55e1c440)

Change-Id: Ib5a674af7e0424691887b20d24782a6740d11414
Reviewed-on: http://gerrit.openafs.org/7938
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
src/afs/AIX/osi_file.c
src/afs/DARWIN/osi_file.c
src/afs/FBSD/osi_file.c
src/afs/HPUX/osi_file.c
src/afs/IRIX/osi_file.c
src/afs/LINUX/osi_file.c
src/afs/LINUX24/osi_file.c
src/afs/NBSD/osi_file.c
src/afs/OBSD/osi_file.c
src/afs/SOLARIS/osi_file.c

index 0efcbaba1f7a5f7fac9d6c916ec1368774b744fc..7ecaaf2376f14a20b0ae6753d739608ed25e363b 100644 (file)
@@ -198,7 +198,9 @@ afs_osi_Read(struct osi_file *afile, int offset, void *aptr,
            goto retry_IO;
        }
        setuerror(code);
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     return code;
 }
@@ -241,7 +243,9 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
            afs_warnuser
                ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
        setuerror(code);
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     if (afile->proc) {
        (*afile->proc) (afile, code);
index bbecfd4f49fd5877c609b69f76380b8fc6213507..bc271f02fca67fe55f41377d5b2fdf7e73b9c00b 100644 (file)
@@ -346,7 +346,9 @@ afs_osi_Read(struct osi_file *afile, int offset, void *aptr,
     } else {
        afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
                   ICL_TYPE_INT32, code);
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     return code;
 }
@@ -387,7 +389,9 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
        code = asize - resid;
        afile->offset += code;
     } else {
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     if (afile->proc) {
        (*afile->proc) (afile, code);
index 484c633039731d12ed1b9a3d6414f62040df328a..7c695d60ee73a6b0cb1c69e951f5c0b0698d3c03 100644 (file)
@@ -187,7 +187,9 @@ afs_osi_Read(struct osi_file *afile, int offset, void *aptr,
     } else {
        afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
                   ICL_TYPE_INT32, code);
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     return code;
 }
@@ -216,7 +218,9 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
        code = asize - resid;
        afile->offset += code;
     } else {
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     if (afile->proc) {
        (*afile->proc) (afile, code);
index 2afe1da6e08c024b1c4ab704f856ea5d177facd8..59c2594af7c5b1b157095a4013022b4a95bda142 100644 (file)
@@ -177,7 +177,9 @@ afs_osi_Read(struct osi_file *afile, int offset, void *aptr,
            goto retry_IO;
        }
        setuerror(code);
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     return code;
 }
@@ -208,7 +210,9 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
            afs_warnuser
                ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
        setuerror(code);
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     if (afile->proc) {
        (*afile->proc) (afile, code);
index f351910c846e5e71cfe299b81363bc28bb788791..86984937d254910c3d20cd1ee3a30a3d0d571e80 100644 (file)
@@ -160,7 +160,9 @@ afs_osi_Read(struct osi_file *afile, int offset, void *aptr,
     } else {
        afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
                   ICL_TYPE_INT32, code);
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     return code;
 }
@@ -191,7 +193,9 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
        if (code == ENOSPC)
            afs_warnuser
                ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     if (afile->proc) {
        (*afile->proc) (afile, code);
index 59e7d578503ec7831687dbf7029061df3aa14fe5..0aba82bdadcb908b1d30910ae14c1197a45d589c 100644 (file)
@@ -231,7 +231,9 @@ afs_osi_Read(struct osi_file *afile, int offset, void *aptr,
     } else {
        afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, auio.uio_resid,
                   ICL_TYPE_INT32, code);
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     return code;
 }
@@ -267,7 +269,9 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
        if (code == ENOSPC)
            afs_warnuser
                ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
 
     if (afile->proc)
index b01be67dddca23d6df94a75b38c245a986b9fd5a..35bd031d00bd96afbb23ad0cd1dd5e37fc96759c 100644 (file)
@@ -215,7 +215,9 @@ afs_osi_Read(struct osi_file *afile, int offset, void *aptr,
     } else {
        afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, auio.uio_resid,
                   ICL_TYPE_INT32, code);
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     return code;
 }
@@ -251,7 +253,9 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
        if (code == ENOSPC)
            afs_warnuser
                ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
 
     if (afile->proc)
index e27a19c62b27706e7f9b2aa8f11ee21c40349dfb..6d8746a1c88eee0040c7300e2e0e9c55b594e1e6 100644 (file)
@@ -160,7 +160,9 @@ afs_osi_Read(struct osi_file *afile, int offset, void *aptr, afs_int32 asize)
     } else {
        afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
                   ICL_TYPE_INT32, code);
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     return code;
 }
@@ -192,8 +194,11 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
        afile->offset += code;
        if (afile->offset > afile->size)
            afile->size = afile->offset;
-    } else
-       code = -1;
+    } else {
+       if (code > 0) {
+           code *= -1;
+       }
+    }
 
     if (afile->proc)
        (*afile->proc) (afile, code);
index e9921988ce52b8e764e7ab34e5493f2fc53f7a8c..72a43ef9fa335e1496ebe22c2f1cb8daebb8109c 100644 (file)
@@ -163,7 +163,9 @@ afs_osi_Read(struct osi_file *afile, int offset, void *aptr, afs_int32 asize)
     } else {
        afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32,
                   (unsigned int) resid, ICL_TYPE_INT32, code);
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     return code;
 }
@@ -195,8 +197,11 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
        afile->offset += code;
        if (afile->offset > afile->size)
            afile->size = afile->offset;
-    } else
-       code = -1;
+    } else {
+       if (code > 0) {
+           code *= -1;
+       }
+    }
 
     if (afile->proc)
        (*afile->proc) (afile, code);
index de7b2090871bb95903fa4f85071e65b05aaa6c24..e0c00579a7a4a4b7eb6577ed08725ce52f31fd19 100644 (file)
@@ -396,7 +396,9 @@ afs_osi_Read(struct osi_file *afile, int offset, void *aptr,
     } else {
        afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
                   ICL_TYPE_INT32, code);
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     return code;
 }
@@ -428,7 +430,9 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
        code = asize - resid;
        afile->offset += code;
     } else {
-       code = -1;
+       if (code > 0) {
+           code *= -1;
+       }
     }
     if (afile->proc) {
        (*afile->proc) (afile, code);