aix mount failure unlock and seterror
[openafs.git] / src / afs / AIX / osi_vfsops.c
index ac1770f..a3dd50f 100644 (file)
  * osi_vfsops.c for AIX
  */
 #include <afsconfig.h>
-#include "../afs/param.h"
+#include "afs/param.h"
 
-RCSID("$Header$");
 
-#include "../afs/sysincludes.h"        /* Standard vendor system headers */
-#include "../afs/afsincludes.h"        /* Afs-based standard headers */
-#include "../afs/afs_stats.h"   /* statistics stuff */
+#include "afs/sysincludes.h"   /* Standard vendor system headers */
+#include "afsincludes.h"       /* Afs-based standard headers */
+#include "afs/afs_stats.h"     /* statistics stuff */
 
 
 #ifdef AFS_AIX_IAUTH_ENV
-#include "../afs/nfsclient.h"
-#include "../afs/exporter.h"
-extern struct afs_exporter     *afs_nfsexporter;
+#include "afs/nfsclient.h"
+#include "afs/exporter.h"
+extern struct afs_exporter *afs_nfsexporter;
 #endif
 
 #define AFS_VFSLOCK_DECL register int glockOwner = ISAFS_GLOCK()
@@ -33,13 +32,13 @@ extern struct afs_exporter  *afs_nfsexporter;
 struct vfs *afs_globalVFS = 0;
 struct vcache *afs_globalVp = 0;
 
+static int afs_root_nolock(struct vfs *afsp, struct vnode **avpp);
 
-static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp);
-
-static int afs_mount(afsp, path, data)
-    char *path;
-    caddr_t data; 
-    struct vfs *afsp;
+static int
+afs_mount(afsp, path, data)
+     char *path;
+     caddr_t data;
+     struct vfs *afsp;
 {
     struct vnode *afsrootvp = NULL;
     int error;
@@ -52,7 +51,7 @@ static int afs_mount(afsp, path, data)
         * it well.
         */
        AFS_VFSUNLOCK();
-       return (setuerror(EBUSY));
+       return (setuerror(EBUSY));
     }
 
 
@@ -63,51 +62,60 @@ static int afs_mount(afsp, path, data)
     afsp->vfs_flag |= VFS_DEVMOUNT;
 #endif /* AFS_64BIT_CLIENT */
 
-    afsp->vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */
-    afsp->vfs_fsid.val[1] = AFS_VFSFSID; 
+    afsp->vfs_fsid.val[0] = AFS_VFSMAGIC;      /* magic */
+    afsp->vfs_fsid.val[1] = AFS_VFSFSID;
 
     /* For AFS, we don't allow file over file mounts. */
-       if (afsp->vfs_mntdover->v_type != VDIR)
-       return(ENOTDIR);
-       /* try to get the root vnode, but don't worry if you don't.  The actual
-       * setting of the root vnode (vfs_mntd) is done in afs_root, so that it
-       * get re-eval'd at the right time if things aren't working when we
-       * first try the mount.
-       */
+    if (afsp->vfs_mntdover->v_type != VDIR) {
+       AFS_VFSUNLOCK();
+       return (setuerror(ENOTDIR));
+    }
+    /* try to get the root vnode, but don't worry if you don't.  The actual
+     * setting of the root vnode (vfs_mntd) is done in afs_root, so that it
+     * get re-eval'd at the right time if things aren't working when we
+     * first try the mount.
+     */
     afs_root_nolock(afsp, &afsrootvp);
 
     afsp->vfs_mntdover->v_mvfsp = afsp;
     afsp->vfs_mdata->vmt_flags |= MNT_REMOTE;
 
+#ifdef AFS_AIX51_ENV
+    afsp->vfs_count = 1;
+    afsp->vfs_mntd->v_count = 1;
+#endif
 #ifdef AFS_AIX_IAUTH_ENV
-    if (afs_iauth_register()<0)
+    if (afs_iauth_register() < 0)
        afs_warn("Can't register AFS iauth interface.\n");
 #endif
     AFS_VFSUNLOCK();
     return 0;
 }
 
-static int afs_unmount (struct vfs *afsp, int flag)
+static int
+afs_unmount(struct vfs *afsp, int flag)
 {
     AFS_VFSLOCK_DECL;
     AFS_VFSLOCK();
     AFS_STATCNT(afs_unmount);
 
     afs_globalVFS = 0;
+    afs_cold_shutdown = 1;
     afs_shutdown();
 
     AFS_VFSUNLOCK();
     return 0;
 }
 
-static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp)
+static int
+afs_root_nolock(struct vfs *afsp, struct vnode **avpp)
 {
     register afs_int32 code = 0;
     struct vrequest treq;
-    register struct vcache *tvp=0;
+    register struct vcache *tvp = 0;
 
     AFS_STATCNT(afs_root);
-    if (afs_globalVp && (afs_globalVp->states & CStatd)) {
+    if (afs_globalVp && (afs_globalVp->f.states & CStatd)) {
        tvp = afs_globalVp;
     } else {
        struct ucred *credp;
@@ -116,8 +124,7 @@ static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp)
            afs_globalVp = NULL;
        }
        credp = crref();
-       if (!(code = afs_InitReq(&treq, credp)) &&
-           !(code = afs_CheckInit())) {
+       if (!(code = afs_InitReq(&treq, credp)) && !(code = afs_CheckInit())) {
            tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
            /* we really want this to stay around */
            if (tvp) {
@@ -131,12 +138,12 @@ static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp)
        VN_HOLD(AFSTOV(tvp));
 
        VN_LOCK(AFSTOV(tvp));
-       AFSTOV(tvp)->v_flag |= VROOT;       /* No-op on Ultrix 2.2 */
+       AFSTOV(tvp)->v_flag |= VROOT;   /* No-op on Ultrix 2.2 */
        VN_UNLOCK(AFSTOV(tvp));
 
        afs_globalVFS = afsp;
        *avpp = AFSTOV(tvp);
-       afsp->vfs_mntd = *avpp;   
+       afsp->vfs_mntd = *avpp;
     }
 
     afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *avpp,
@@ -145,7 +152,8 @@ static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp)
 }
 
 
-static int afs_root (struct vfs *afsp, struct vnode **avpp)
+static int
+afs_root(struct vfs *afsp, struct vnode **avpp)
 {
     int code;
     AFS_VFSLOCK_DECL;
@@ -155,8 +163,8 @@ static int afs_root (struct vfs *afsp, struct vnode **avpp)
     return code;
 }
 
-static int afs_statfs(struct vfs *afsp, struct statfs *abp,
-                     struct ucred *credp)
+static int
+afs_statfs(struct vfs *afsp, struct statfs *abp, struct ucred *credp)
 {
     AFS_VFSLOCK_DECL;
     AFS_VFSLOCK();
@@ -170,17 +178,18 @@ static int afs_statfs(struct vfs *afsp, struct statfs *abp,
     abp->f_vfstype = AFS_VFSFSID;
     abp->f_vfsnumber = afsp->vfs_number;
     abp->f_vfsoff = abp->f_vfslen = abp->f_vfsvers = -1;
-    abp->f_fsize  = 4096;      /* fundamental filesystem block size */
+    abp->f_fsize = 4096;       /* fundamental filesystem block size */
     abp->f_fsid = afsp->vfs_fsid;
-    (void) strcpy(abp->f_fname, "/afs");
-    (void) strcpy(abp->f_fpack, "AFS");
+    (void)strcpy(abp->f_fname, "/afs");
+    (void)strcpy(abp->f_fpack, "AFS");
     abp->f_name_max = 256;
 
     AFS_VFSUNLOCK();
     return 0;
 }
 
-static int afs_sync()
+static int
+afs_sync()
 {
     AFS_VFSLOCK_DECL;
     AFS_VFSLOCK();
@@ -192,7 +201,8 @@ static int afs_sync()
 
 
 /* Note that the cred is only for AIX 4.1.5+ and AIX 4.2+ */
-static int afs_vget(struct vfs *vfsp, struct vnode **avcp, struct fileid *fidp,
+static int
+afs_vget(struct vfs *vfsp, struct vnode **avcp, struct fileid *fidp,
         struct ucred *credp)
 {
     int code;
@@ -210,8 +220,8 @@ static int afs_vget(struct vfs *vfsp, struct vnode **avcp, struct fileid *fidp,
     }
 #endif
 
-    if ((code = afs_InitReq(&treq, credp))==0) {
-       code = afs_osi_vget((struct vcache**)avcp, fidp, &treq);
+    if ((code = afs_InitReq(&treq, credp)) == 0) {
+       code = afs_osi_vget((struct vcache **)avcp, fidp, &treq);
     }
 
     afs_Trace3(afs_iclSetp, CM_TRACE_VGET, ICL_TYPE_POINTER, *avcp,
@@ -221,24 +231,25 @@ static int afs_vget(struct vfs *vfsp, struct vnode **avcp, struct fileid *fidp,
     AFS_VFSUNLOCK();
     return code;
 }
-     
-static int afs_badop()
+
+static int
+afs_badop()
 {
     return EOPNOTSUPP;
 }
 
 
 struct vfsops Afs_vfsops = {
-       afs_mount,
-       afs_unmount,
-       afs_root,
-       afs_statfs,
-       afs_sync,
-       afs_vget,
-       afs_badop,      /* vfs_cntl */
-       afs_badop       /* vfs_quotactl */
+    afs_mount,
+    afs_unmount,
+    afs_root,
+    afs_statfs,
+    afs_sync,
+    afs_vget,
+    afs_badop,                 /* vfs_cntl */
+    afs_badop                  /* vfs_quotactl */
 #ifdef AFS_AIX51_ENV
-       ,afs_badop      /* vfs_syncvfs */
+       , afs_badop             /* vfs_syncvfs */
 #endif
 };