2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * osi_vfsops.c for AIX
13 #include "../afs/param.h" /* Should be always first */
14 #include "../afs/sysincludes.h" /* Standard vendor system headers */
15 #include "../afs/afsincludes.h" /* Afs-based standard headers */
16 #include "../afs/afs_stats.h" /* statistics stuff */
19 #ifdef AFS_AIX_IAUTH_ENV
20 #include "../afs/nfsclient.h"
21 #include "../afs/exporter.h"
22 extern struct afs_exporter *afs_nfsexporter;
25 #define AFS_VFSLOCK_DECL register int glockOwner = ISAFS_GLOCK()
26 #define AFS_VFSLOCK() if (!glockOwner) AFS_GLOCK()
27 #define AFS_VFSUNLOCK() if (!glockOwner) AFS_GUNLOCK()
29 struct vfs *afs_globalVFS = 0;
30 struct vcache *afs_globalVp = 0;
33 static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp);
35 static int afs_mount(afsp, path, data)
40 struct vnode *afsrootvp = NULL;
44 AFS_STATCNT(afs_mount);
47 /* Don't allow remounts since some system (like AIX) don't handle
51 return (setuerror(EBUSY));
56 afsp->vfs_bsize = 8192;
58 afsp->vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */
59 afsp->vfs_fsid.val[1] = AFS_VFSFSID;
61 /* For AFS, we don't allow file over file mounts. */
62 if (afsp->vfs_mntdover->v_type != VDIR)
64 /* try to get the root vnode, but don't worry if you don't. The actual
65 * setting of the root vnode (vfs_mntd) is done in afs_root, so that it
66 * get re-eval'd at the right time if things aren't working when we
67 * first try the mount.
69 afs_root_nolock(afsp, &afsrootvp);
71 afsp->vfs_mntdover->v_mvfsp = afsp;
72 afsp->vfs_mdata->vmt_flags |= MNT_REMOTE;
74 #ifdef AFS_AIX_IAUTH_ENV
75 if (afs_iauth_register()<0)
76 afs_warn("Can't register AFS iauth interface.\n");
82 static int afs_unmount (struct vfs *afsp, int flag)
86 AFS_STATCNT(afs_unmount);
95 static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp)
97 register afs_int32 code = 0;
99 register struct vcache *tvp=0;
101 AFS_STATCNT(afs_root);
102 if (afs_globalVp && (afs_globalVp->states & CStatd)) {
107 if (!(code = afs_InitReq(&treq, credp)) &&
108 !(code = afs_CheckInit())) {
109 tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0,
110 (struct vcache*)0, WRITE_LOCK);
111 /* we really want this to stay around */
120 VN_HOLD((struct vnode *)tvp);
122 VN_LOCK((struct vnode *)tvp);
123 tvp->v.v_flag |= VROOT; /* No-op on Ultrix 2.2 */
124 VN_UNLOCK((struct vnode *)tvp);
126 afs_globalVFS = afsp;
127 *avpp = (struct vnode *) tvp;
128 afsp->vfs_mntd = *avpp;
131 afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *avpp,
132 ICL_TYPE_INT32, code);
137 static int afs_root (struct vfs *afsp, struct vnode **avpp)
142 code = afs_root_nolock(afsp, avpp);
147 static int afs_statfs(struct vfs *afsp, struct statfs *abp,
152 AFS_STATCNT(afs_statfs);
156 abp->f_bsize = afsp->vfs_bsize;
157 abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
158 abp->f_ffree = 9000000;
159 abp->f_vfstype = AFS_VFSFSID;
160 abp->f_vfsnumber = afsp->vfs_number;
161 abp->f_vfsoff = abp->f_vfslen = abp->f_vfsvers = -1;
162 abp->f_fsize = 4096; /* fundamental filesystem block size */
163 abp->f_fsid = afsp->vfs_fsid;
164 (void) strcpy(abp->f_fname, "/afs");
165 (void) strcpy(abp->f_fpack, "AFS");
166 abp->f_name_max = 256;
172 static int afs_sync()
176 AFS_STATCNT(afs_sync);
183 /* Note that the cred is only for AIX 4.1.5+ and AIX 4.2+ */
184 static int afs_vget(struct vfs *vfsp, struct vnode **avcp, struct fileid *fidp,
188 struct vrequest treq;
191 AFS_STATCNT(afs_vget);
194 #ifdef AFS_AIX_IAUTH_ENV
195 /* If the exporter is off and this is an nfsd, fail immediately. */
196 if (AFS_NFSXLATORREQ(credp)
197 && !(afs_nfsexporter->exp_states & EXP_EXPORTED)) {
202 if ((code = afs_InitReq(&treq, credp))==0) {
203 code = afs_osi_vget((struct vcache**)avcp, fidp, &treq);
206 afs_Trace3(afs_iclSetp, CM_TRACE_VGET, ICL_TYPE_POINTER, *avcp,
207 ICL_TYPE_INT32, treq.uid, ICL_TYPE_FID, fidp);
208 code = afs_CheckCode(code, &treq, 42);
214 static int afs_badop()
220 struct vfsops Afs_vfsops = {
227 afs_badop, /* vfs_cntl */
228 afs_badop /* vfs_quotactl */
232 * VFS is initialized in osi_config.c