afs: Avoid using logical OR when setting f_fsid
[openafs.git] / src / afs / UKERNEL / osi_vfsops.c
index e146b2c..38b1e72 100644 (file)
@@ -7,17 +7,13 @@
  * directory or online at http://www.openafs.org/dl/license10.html
  */
 
-#include "../afs/param.h"      /* Should be always first */
-#include "../afs/sysincludes.h"        /* Standard vendor system headers */
-#include "../afs/afsincludes.h"        /* Afs-based standard headers */
-#include "../afs/afs_stats.h"   /* statistics stuff */
+#include <afsconfig.h>
+#include "afs/param.h"
 
 
-int afs_mount();
-int afs_unmount();
-int afs_root();
-int afs_statfs();
-int afs_sync();
+#include "afs/sysincludes.h"   /* Standard vendor system headers */
+#include "afsincludes.h"       /* Afs-based standard headers */
+#include "afs/afs_stats.h"     /* statistics stuff */
 
 struct vfsops Afs_vfsops = {
     afs_mount,
@@ -32,65 +28,68 @@ struct vcache *afs_globalVp = 0;
 int afs_rootCellIndex = 0;
 
 #if !defined(AFS_USR_AIX_ENV)
-#include "../sys/syscall.h"
+#include "sys/syscall.h"
 #endif
 
-afs_mount(afsp, path, data)
-    char *path;
-    caddr_t data; 
-    struct vfs *afsp;
+int
+afs_mount(struct vfs *afsp, char *path, void *data)
 {
     AFS_STATCNT(afs_mount);
 
     if (afs_globalVFS) {
        /* Don't allow remounts since some system (like AIX) don't handle it well */
-       return (setuerror(EBUSY));
+       return (setuerror(EBUSY));
     }
     afs_globalVFS = afsp;
     afsp->vfs_bsize = 8192;
-    afsp->vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */
-    afsp->vfs_fsid.val[1] = (afs_int32) AFS_VFSFSID; 
+    afsp->vfs_fsid.val[0] = AFS_VFSMAGIC;      /* magic */
+    afsp->vfs_fsid.val[1] = (intptr_t)AFS_VFSFSID;
 
     return 0;
 }
 
-afs_unmount (afsp)
-    struct vfs *afsp; {
+int
+afs_unmount(struct vfs *afsp)
+{
     AFS_STATCNT(afs_unmount);
     afs_globalVFS = 0;
     afs_shutdown();
     return 0;
 }
 
-afs_root (OSI_VFS_ARG(afsp), avpp)
-    OSI_VFS_DECL(afsp);
-    struct vnode **avpp; {
-    register afs_int32 code = 0;
+int
+afs_root(OSI_VFS_DECL(afsp), struct vnode **avpp)
+{
+    afs_int32 code = 0;
     struct vrequest treq;
-    register struct vcache *tvp=0;
-    OSI_VFS_CONVERT(afsp)
+    struct vcache *tvp = 0;
+    OSI_VFS_CONVERT(afsp);
 
     AFS_STATCNT(afs_root);
-    if (afs_globalVp && (afs_globalVp->states & CStatd)) {
+    if (afs_globalVp && (afs_globalVp->f.states & CStatd)) {
        tvp = afs_globalVp;
     } else {
-       if (!(code = afs_InitReq(&treq, u.u_cred)) &&
-           !(code = afs_CheckInit())) {
-           tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0,
-                               (struct vcache*)0, WRITE_LOCK);
+       if (afs_globalVp) {
+           afs_PutVCache(afs_globalVp);
+           afs_globalVp = NULL;
+       }
+
+       if (!(code = afs_InitReq(&treq, get_user_struct()->u_cred))
+           && !(code = afs_CheckInit())) {
+           tvp = afs_GetVCache(&afs_rootFid, &treq);
            /* we really want this to stay around */
            if (tvp) {
                afs_globalVp = tvp;
            } else
-               code = ENOENT;
+               code = EIO;
        }
     }
     if (tvp) {
-       VN_HOLD((struct vnode *)tvp);
+       VN_HOLD(AFSTOV(tvp));
 
-       tvp->v.v_flag |= VROOT;     /* No-op on Ultrix 2.2 */
+       AFSTOV(tvp)->v_flag |= VROOT;   /* No-op on Ultrix 2.2 */
        afs_globalVFS = afsp;
-       *avpp = (struct vnode *) tvp;
+       *avpp = AFSTOV(tvp);
     }
 
     afs_Trace3(afs_iclSetp, CM_TRACE_GOPEN, ICL_TYPE_POINTER, *avpp,
@@ -98,33 +97,54 @@ afs_root (OSI_VFS_ARG(afsp), avpp)
     return code;
 }
 
-afs_sync(afsp)
-    struct vfs *afsp; 
+int
+afs_sync(struct vfs *afsp)
 {
     AFS_STATCNT(afs_sync);
     return 0;
 }
 
-afs_statfs(afsp, abp)
-    register struct vfs *afsp;
-    struct statfs *abp;
- {
-       AFS_STATCNT(afs_statfs);
-       abp->f_type = 0;
-       abp->f_bsize = afsp->vfs_bsize;
-       abp->f_fsid.val[0] = AFS_VFSMAGIC; /* magic */
-       abp->f_fsid.val[1] = (afs_int32) AFS_VFSFSID;
-       return 0;
+int
+afs_statfs(struct vfs *afsp, struct statfs *abp)
+{
+    AFS_STATCNT(afs_statfs);
+    abp->f_type = 0;
+    abp->f_bsize = afsp->vfs_bsize;
+    abp->f_fsid.val[0] = AFS_VFSMAGIC; /* magic */
+    abp->f_fsid.val[1] = (intptr_t)AFS_VFSFSID;
+    return 0;
+}
+
+int
+afs_statvfs(struct vfs *afsp, struct statvfs *abp)
+{
+    AFS_STATCNT(afs_statfs);
+
+    abp->f_frsize = 1024;
+    abp->f_bsize = afsp->vfs_bsize;
+    abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
+      abp->f_favail = abp->f_ffree = AFS_VFS_FAKEFREE;
+
+#ifdef AFS_USR_AIX_ENV
+    abp->f_fsid.val[0] = AFS_VFSMAGIC;
+    abp->f_fsid.val[1] = AFS_VFSFSID;
+#else
+    abp->f_fsid = (AFS_VFSMAGIC << 16) | AFS_VFSFSID;
+#endif
+
+    return 0;
 }
 
-afs_mountroot()
+int
+afs_mountroot(void)
 {
     AFS_STATCNT(afs_mountroot);
-    return(EINVAL);
+    return (EINVAL);
 }
 
-afs_swapvp() 
+int
+afs_swapvp(void)
 {
     AFS_STATCNT(afs_swapvp);
-    return(EINVAL);
+    return (EINVAL);
 }