afs: Indicate error from afs_osi_Read/Write better
[openafs.git] / src / afs / IRIX / osi_file.c
index 21e4b96..8698493 100644 (file)
@@ -22,14 +22,14 @@ extern struct osi_dev cacheDev;
 extern struct vfs *afs_cacheVfsp;
 
 vnode_t *
-afs_XFSIGetVnode(afs_dcache_id_t *ainode)
+afs_XFSIGetVnode(ino_t ainode)
 {
     struct xfs_inode *ip;
     int error;
     vnode_t *vp;
 
     if ((error =
-        xfs_igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, ainode->ufs, &ip))) {
+        xfs_igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, ainode, &ip))) {
        osi_Panic("afs_XFSIGetVnode: xfs_igetinode failed, error=%d", error);
     }
     vp = XFS_ITOV(ip);
@@ -41,7 +41,7 @@ void *
 osi_UFSOpen(afs_dcache_id_t *ainode)
 {
     struct inode *ip;
-    register struct osi_file *afile = NULL;
+    struct osi_file *afile = NULL;
     extern int cacheDiskType;
     afs_int32 code = 0;
     int dummy;
@@ -57,19 +57,18 @@ osi_UFSOpen(afs_dcache_id_t *ainode)
     }
     afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file));
     AFS_GUNLOCK();
-    afile->vnode = AFS_SGI_IGETVNODE(ainode->ufs);
+    afile->vnode = afs_XFSIGetVnode(ainode->ufs);
     AFS_GLOCK();
     afile->size = VnodeToSize(afile->vnode);
     afile->offset = 0;
     afile->proc = (int (*)())0;
-    afile->inum = ainode->ufs; /* for hint validity checking */
     return (void *)afile;
 }
 
 int
-afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat)
+afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
 {
-    register afs_int32 code;
+    afs_int32 code;
     struct vattr tvattr;
     AFS_STATCNT(osi_Stat);
     ObtainWriteLock(&afs_xosi, 320);
@@ -87,7 +86,7 @@ afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat)
 }
 
 int
-osi_UFSClose(register struct osi_file *afile)
+osi_UFSClose(struct osi_file *afile)
 {
     AFS_STATCNT(osi_Close);
     if (afile->vnode) {
@@ -99,11 +98,11 @@ osi_UFSClose(register struct osi_file *afile)
 }
 
 int
-osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
+osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
 {
     afs_ucred_t *oldCred;
     struct vattr tvattr;
-    register afs_int32 code;
+    afs_int32 code;
     struct osi_stat tstat;
     mon_state_t ms;
     AFS_STATCNT(osi_Truncate);
@@ -128,13 +127,13 @@ osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
 
 /* Generic read interface */
 int
-afs_osi_Read(register struct osi_file *afile, int offset, void *aptr,
+afs_osi_Read(struct osi_file *afile, int offset, void *aptr,
             afs_int32 asize)
 {
     afs_ucred_t *oldCred;
     ssize_t resid;
-    register afs_int32 code;
-    register afs_int32 cnt1 = 0;
+    afs_int32 code;
+    afs_int32 cnt1 = 0;
     AFS_STATCNT(osi_Read);
 
     /**
@@ -145,7 +144,7 @@ afs_osi_Read(register struct osi_file *afile, int offset, void *aptr,
        if (!afs_shuttingdown)
            osi_Panic("osi_Read called with null param");
        else
-           return EIO;
+           return -EIO;
     }
 
     if (offset != -1)
@@ -161,19 +160,21 @@ afs_osi_Read(register 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;
 }
 
 /* Generic write interface */
 int
-afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr,
+afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
              afs_int32 asize)
 {
     afs_ucred_t *oldCred;
     ssize_t resid;
-    register afs_int32 code;
+    afs_int32 code;
     AFS_STATCNT(osi_Write);
     if (!afile)
        osi_Panic("afs_osi_Write called with null param");
@@ -192,7 +193,9 @@ afs_osi_Write(register 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);
@@ -205,7 +208,7 @@ afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr,
     This routine written from the RT NFS port strategy routine.
     It has been generalized a bit, but should still be pretty clear. */
 int
-afs_osi_MapStrategy(int (*aproc) (), register struct buf *bp)
+afs_osi_MapStrategy(int (*aproc) (), struct buf *bp)
 {
     afs_int32 returnCode;