Fix build for FreeBSD 10.0
[openafs.git] / src / afs / FBSD / osi_file.c
index 4b38d70..096e472 100644 (file)
@@ -36,13 +36,9 @@ osi_UFSOpen(afs_dcache_id_t *ainode)
     AFS_STATCNT(osi_UFSOpen);
     if (cacheDiskType != AFS_FCACHE_TYPE_UFS)
        osi_Panic("UFSOpen called for non-UFS cache\n");
-    afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file));
+    afile = osi_AllocSmallSpace(sizeof(struct osi_file));
     AFS_GUNLOCK();
-#if defined(AFS_FBSD50_ENV)
     code = VFS_VGET(afs_cacheVfsp, (ino_t) ainode->ufs, LK_EXCLUSIVE, &vp);
-#else
-    code = VFS_VGET(afs_cacheVfsp, (ino_t) ainode->ufs, &vp);
-#endif
     AFS_GLOCK();
     if (code == 0 && vp->v_type == VNON)
        code = ENOENT;
@@ -63,9 +59,9 @@ osi_UFSOpen(afs_dcache_id_t *ainode)
 }
 
 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);
@@ -90,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) {
@@ -102,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)
 {
     struct vattr tvattr;
     struct vnode *vp;
-    register afs_int32 code, glocked;
+    afs_int32 code, glocked;
     AFS_STATCNT(osi_Truncate);
 
     ObtainWriteLock(&afs_xosi, 321);
@@ -159,11 +155,15 @@ 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)
 {
-    unsigned int resid;
-    register afs_int32 code;
+#if (__FreeBSD_version >= 900505 && __FreeBSD_Version < 1000000) ||__FreeBSD_version >= 1000009
+    ssize_t resid;
+#else
+    int resid;
+#endif
+    afs_int32 code;
     AFS_STATCNT(osi_Read);
 
     /**
@@ -174,7 +174,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)
@@ -189,20 +189,26 @@ afs_osi_Read(register struct osi_file *afile, int offset, void *aptr,
        afile->offset += code;
        osi_DisableAtimes(afile->vnode);
     } else {
-       afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
+       afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, (int)resid,
                   ICL_TYPE_INT32, code);
-       code = -1;
+       if (code > 0) {
+           code = -code;
+       }
     }
     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)
 {
-    unsigned int resid;
-    register afs_int32 code;
+#if (__FreeBSD_version >= 900505 && __FreeBSD_Version < 1000000) ||__FreeBSD_version >= 1000009
+    ssize_t resid;
+#else
+    int resid;
+#endif
+    afs_int32 code;
     AFS_STATCNT(osi_Write);
     if (!afile)
        osi_Panic("afs_osi_Write called with null param");
@@ -220,7 +226,9 @@ afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr,
        code = asize - resid;
        afile->offset += code;
     } else {
-       code = -1;
+       if (code > 0) {
+           code = -code;
+       }
     }
     if (afile->proc) {
        (*afile->proc) (afile, code);
@@ -233,7 +241,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;