reindent-20030715
[openafs.git] / src / afs / IRIX / osi_file.c
index 9542c53..df4c759 100644 (file)
 #include <afsconfig.h>
 #include "afs/param.h"
 
-RCSID("$Header$");
+RCSID
+    ("$Header$");
 
 #include "afs/sysincludes.h"   /* Standard vendor system headers */
 #include "afsincludes.h"       /* Afs-based standard headers */
-#include "afs/afs_stats.h"  /* afs statistics */
+#include "afs/afs_stats.h"     /* afs statistics */
 
-int afs_osicred_initialized=0;
+int afs_osicred_initialized = 0;
 afs_lock_t afs_xosi;           /* lock is for tvattr */
 extern struct osi_dev cacheDev;
 extern struct vfs *afs_cacheVfsp;
@@ -27,32 +28,34 @@ extern struct vfs *afs_cacheVfsp;
  * added which accesses the inode, that will also need EFS/XFS variants.
  */
 #ifdef AFS_SGI_EFS_IOPS_ENV
-vnode_t *afs_EFSIGetVnode(ino_t ainode)
+vnode_t *
+afs_EFSIGetVnode(ino_t ainode)
 {
     struct inode *ip;
     int error;
 
-    if ((error = igetinode(afs_cacheVfsp, (dev_t)cacheDev.dev, ainode, &ip))) {
+    if ((error = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, ainode, &ip))) {
        osi_Panic("afs_EFSIGetVnode: igetinode failed, error=%d", error);
     }
     /* We don't care about atimes on the cache files, so disable them.  I'm not
      * sure that this is the right place to do this: it should be *after* readi 
      * and getattr and stuff. 
      */
-    ip->i_flags &= ~(ISYN|IACC);
+    ip->i_flags &= ~(ISYN | IACC);
     iunlock(ip);
     return (EFS_ITOV(ip));
-}    
+}
 #endif /* AFS_SGI_EFS_IOPS_ENV */
 
-vnode_t *afs_XFSIGetVnode(ino_t ainode)
+vnode_t *
+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, &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);
@@ -60,7 +63,8 @@ vnode_t *afs_XFSIGetVnode(ino_t ainode)
 }
 
 /* Force to 64 bits, even for EFS filesystems. */
-void *osi_UFSOpen(ino_t ainode)
+void *
+osi_UFSOpen(ino_t ainode)
 {
     struct inode *ip;
     register struct osi_file *afile = NULL;
@@ -68,7 +72,7 @@ void *osi_UFSOpen(ino_t ainode)
     afs_int32 code = 0;
     int dummy;
     AFS_STATCNT(osi_UFSOpen);
-    if(cacheDiskType != AFS_FCACHE_TYPE_UFS) {
+    if (cacheDiskType != AFS_FCACHE_TYPE_UFS) {
        osi_Panic("UFSOpen called for non-UFS cache\n");
     }
     if (!afs_osicred_initialized) {
@@ -77,25 +81,26 @@ void *osi_UFSOpen(ino_t ainode)
        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));
+    afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file));
     AFS_GUNLOCK();
     afile->vnode = AFS_SGI_IGETVNODE(ainode);
     AFS_GLOCK();
     afile->size = VnodeToSize(afile->vnode);
     afile->offset = 0;
-    afile->proc = (int (*)()) 0;
-    afile->inum = ainode;        /* for hint validity checking */
+    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)
+int
+afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat)
 {
     register afs_int32 code;
     struct vattr tvattr;
     AFS_STATCNT(osi_Stat);
-    MObtainWriteLock(&afs_xosi,320);
+    MObtainWriteLock(&afs_xosi, 320);
     AFS_GUNLOCK();
-    tvattr.va_mask = AT_SIZE|AT_BLKSIZE|AT_MTIME|AT_ATIME;
+    tvattr.va_mask = AT_SIZE | AT_BLKSIZE | AT_MTIME | AT_ATIME;
     AFS_VOP_GETATTR(afile->vnode, &tvattr, 0, &afs_osi_cred, code);
     AFS_GLOCK();
     if (code == 0) {
@@ -108,18 +113,20 @@ int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *asta
     return code;
 }
 
-int osi_UFSClose(register struct osi_file *afile)
+int
+osi_UFSClose(register struct osi_file *afile)
 {
-      AFS_STATCNT(osi_Close);
-      if(afile->vnode) {
+    AFS_STATCNT(osi_Close);
+    if (afile->vnode) {
        VN_RELE(afile->vnode);
-      }
-      
-      osi_FreeSmallSpace(afile);
-      return 0;
+    }
+
+    osi_FreeSmallSpace(afile);
+    return 0;
 }
 
-int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
+int
+osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
 {
     struct AFS_UCRED *oldCred;
     struct vattr tvattr;
@@ -133,8 +140,9 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
      * small enough.  Check now and save some time.
      */
     code = afs_osi_Stat(afile, &tstat);
-    if (code || tstat.size <= asize) return code;
-    MObtainWriteLock(&afs_xosi,321);    
+    if (code || tstat.size <= asize)
+       return code;
+    MObtainWriteLock(&afs_xosi, 321);
     AFS_GUNLOCK();
     tvattr.va_mask = AT_SIZE;
     tvattr.va_size = asize;
@@ -145,42 +153,46 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
 }
 
 #ifdef AFS_SGI_EFS_IOPS_ENV
-void osi_DisableAtimes(struct vnode *avp)
+void
+osi_DisableAtimes(struct vnode *avp)
 {
-   if (afs_CacheFSType == AFS_SGI_EFS_CACHE) 
-   {
-   struct inode *ip = EFS_VTOI(avp);
-   ip->i_flags &= ~IACC;
-   }
+    if (afs_CacheFSType == AFS_SGI_EFS_CACHE) {
+       struct inode *ip = EFS_VTOI(avp);
+       ip->i_flags &= ~IACC;
+    }
 
 }
 #endif /* AFS_SGI_EFS_IOPS_ENV */
 
 
 /* Generic read interface */
-int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_int32 asize)
+int
+afs_osi_Read(register struct osi_file *afile, int offset, void *aptr,
+            afs_int32 asize)
 {
     struct AFS_UCRED *oldCred;
     ssize_t resid;
     register afs_int32 code;
-    register afs_int32 cnt1=0;
+    register afs_int32 cnt1 = 0;
     AFS_STATCNT(osi_Read);
-    
+
     /**
       * If the osi_file passed in is NULL, panic only if AFS is not shutting
       * down. No point in crashing when we are already shutting down
       */
-    if ( !afile ) {
-       if ( !afs_shuttingdown )
+    if (!afile) {
+       if (!afs_shuttingdown)
            osi_Panic("osi_Read called with null param");
        else
-          return EIO;
+           return EIO;
     }
-    if (offset != -1) afile->offset = offset;
+
+    if (offset != -1)
+       afile->offset = offset;
     AFS_GUNLOCK();
-    code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset,
-                 AFS_UIOSYS, 0, 0x7fffffff, &afs_osi_cred, &resid);
+    code =
+       gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset,
+                AFS_UIOSYS, 0, 0x7fffffff, &afs_osi_cred, &resid);
     AFS_GLOCK();
     if (code == 0) {
        code = asize - resid;
@@ -188,39 +200,44 @@ int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_in
 #ifdef AFS_SGI_EFS_IOPS_ENV
        osi_DisableAtimes(afile->vnode);
 #endif /* AFS_SGI_EFS_IOPS_ENV */
-    }
-    else {
+    } else {
        afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
-                ICL_TYPE_INT32, code);
+                  ICL_TYPE_INT32, code);
        code = -1;
     }
     return code;
 }
 
 /* Generic write interface */
-int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize)
+int
+afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr,
+             afs_int32 asize)
 {
     struct AFS_UCRED *oldCred;
     ssize_t resid;
     register afs_int32 code;
     AFS_STATCNT(osi_Write);
-    if ( !afile )
-        osi_Panic("afs_osi_Write called with null param");
-    if (offset != -1) afile->offset = offset;
+    if (!afile)
+       osi_Panic("afs_osi_Write called with null param");
+    if (offset != -1)
+       afile->offset = offset;
     AFS_GUNLOCK();
-    code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset,
-                 AFS_UIOSYS, 0, 0x7fffffff, &afs_osi_cred, &resid);
+    code =
+       gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize,
+                afile->offset, AFS_UIOSYS, 0, 0x7fffffff, &afs_osi_cred,
+                &resid);
     AFS_GLOCK();
     if (code == 0) {
        code = asize - resid;
        afile->offset += code;
-    }
-    else {
-       if (code == ENOSPC) afs_warnuser("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
+    } else {
+       if (code == ENOSPC)
+           afs_warnuser
+               ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
        code = -1;
     }
     if (afile->proc) {
-       (*afile->proc)(afile, code);
+       (*afile->proc) (afile, code);
     }
     return code;
 }
@@ -229,7 +246,8 @@ int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr,
 /*  This work should be handled by physstrat in ca/machdep.c.
     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)
+int
+afs_osi_MapStrategy(int (*aproc) (), register struct buf *bp)
 {
     afs_int32 returnCode;
 
@@ -241,13 +259,13 @@ int afs_osi_MapStrategy(int (*aproc)(), register struct buf *bp)
 
 
 
-void shutdown_osifile(void)
+void
+shutdown_osifile(void)
 {
-  extern int afs_cold_shutdown;
+    extern int afs_cold_shutdown;
 
-  AFS_STATCNT(shutdown_osifile);
-  if (afs_cold_shutdown) {
-    afs_osicred_initialized = 0;
-  }
+    AFS_STATCNT(shutdown_osifile);
+    if (afs_cold_shutdown) {
+       afs_osicred_initialized = 0;
+    }
 }
-