afs: afs_osi_Read/Write returns negative on error
[openafs.git] / src / afs / AIX / osi_file.c
index a256240..0efcbab 100644 (file)
@@ -10,8 +10,6 @@
 #include <afsconfig.h>
 #include "afs/param.h"
 
-RCSID
-    ("$Header$");
 
 #include "afs/sysincludes.h"   /* Standard vendor system headers */
 #include "afsincludes.h"       /* Afs-based standard headers */
@@ -19,18 +17,17 @@ RCSID
 
 
 int afs_osicred_initialized = 0;
-struct AFS_UCRED afs_osi_cred;
+afs_ucred_t afs_osi_cred;
 afs_lock_t afs_xosi;           /* lock is for tvattr */
 extern struct osi_dev cacheDev;
 extern struct vfs *afs_cacheVfsp;
 
 
 void *
-osi_UFSOpen(afs_int32 ainode)
+osi_UFSOpen(afs_dcache_id_t *ainode)
 {
     struct inode *ip;
-    register struct osi_file *afile = NULL;
-    extern struct vfs *rootvfs;
+    struct osi_file *afile = NULL;
     struct vnode *vp = NULL;
     extern int cacheDiskType;
     afs_int32 code = 0;
@@ -41,15 +38,15 @@ osi_UFSOpen(afs_int32 ainode)
     }
     if (!afs_osicred_initialized) {
        /* valid for alpha_osf, SunOS, Ultrix */
-       memset((char *)&afs_osi_cred, 0, sizeof(struct AFS_UCRED));
+       memset(&afs_osi_cred, 0, sizeof(afs_ucred_t));
        crhold(&afs_osi_cred);  /* don't let it evaporate, since it is static */
        afs_osicred_initialized = 1;
     }
     afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file));
     setuerror(0);
     AFS_GUNLOCK();
-    ip = (struct inode *)igetinode((dev_t) cacheDev.dev, rootvfs,
-                                  (ino_t) ainode, &vp, &dummy);
+    ip = (struct inode *)igetinode((dev_t) cacheDev.dev, afs_cacheVfsp,
+                                  (ino_t) ainode->ufs, &vp, &dummy);
     AFS_GLOCK();
     if (getuerror()) {
        osi_FreeSmallSpace(afile);
@@ -59,17 +56,16 @@ osi_UFSOpen(afs_int32 ainode)
     afile->size = VTOI(afile->vnode)->i_size;
     afile->offset = 0;
     afile->proc = (int (*)())0;
-    afile->inum = ainode;      /* 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);
-    MObtainWriteLock(&afs_xosi, 320);
+    ObtainWriteLock(&afs_xosi, 320);
     AFS_GUNLOCK();
     code = VNOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred);
     AFS_GLOCK();
@@ -78,12 +74,12 @@ afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat)
        astat->mtime = tvattr.va_mtime.tv_sec;
        astat->atime = tvattr.va_atime.tv_sec;
     }
-    MReleaseWriteLock(&afs_xosi);
+    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
 int
-osi_UFSClose(register struct osi_file *afile)
+osi_UFSClose(struct osi_file *afile)
 {
     AFS_STATCNT(osi_Close);
     if (afile->vnode) {
@@ -109,11 +105,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)
 {
-    struct AFS_UCRED *oldCred;
+    afs_ucred_t *oldCred;
     struct vattr tvattr;
-    register afs_int32 code;
+    afs_int32 code;
     struct osi_stat tstat;
     afs_int32 mode = FWRITE | FSYNC;
     AFS_STATCNT(osi_Truncate);
@@ -125,7 +121,7 @@ osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
     code = afs_osi_Stat(afile, &tstat);
     if (code || tstat.size <= asize)
        return code;
-    MObtainWriteLock(&afs_xosi, 321);
+    ObtainWriteLock(&afs_xosi, 321);
     /* 
      * If we're truncating an unopened file to a non-zero length,
      * we need to bind it to a vm segment    
@@ -137,7 +133,7 @@ osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
     AFS_GUNLOCK();
     code = VNOP_FTRUNC(afile->vnode, mode, asize, (caddr_t) 0, &afs_osi_cred);
     AFS_GLOCK();
-    MReleaseWriteLock(&afs_xosi);
+    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -151,13 +147,13 @@ osi_DisableAtimes(struct vnode *avp)
 
 /* 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)
 {
-    struct AFS_UCRED *oldCred;
+    afs_ucred_t *oldCred;
     unsigned int resid;
-    register afs_int32 code;
-    register afs_int32 cnt1 = 0;
+    afs_int32 code;
+    afs_int32 cnt1 = 0;
     AFS_STATCNT(osi_Read);
 
     /**
@@ -168,7 +164,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)
@@ -209,12 +205,12 @@ afs_osi_Read(register struct osi_file *afile, int offset, void *aptr,
 
 /* 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)
 {
-    struct AFS_UCRED *oldCred;
+    afs_ucred_t *oldCred;
     unsigned int resid;
-    register afs_int32 code;
+    afs_int32 code;
     AFS_STATCNT(osi_Write);
     if (!afile)
        osi_Panic("afs_osi_Write called with null param");
@@ -258,7 +254,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;
 
@@ -273,8 +269,6 @@ afs_osi_MapStrategy(int (*aproc) (), register struct buf *bp)
 void
 shutdown_osifile(void)
 {
-    extern int afs_cold_shutdown;
-
     AFS_STATCNT(shutdown_osifile);
     if (afs_cold_shutdown) {
        afs_osicred_initialized = 0;