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 <afsconfig.h>
14 #include "afs/param.h"
17 #include "afs/sysincludes.h" /* Standard vendor system headers */
18 #include "afsincludes.h" /* Afs-based standard headers */
19 #include "afs/afs_stats.h" /* statistics stuff */
22 #ifdef AFS_AIX_IAUTH_ENV
23 #include "afs/nfsclient.h"
24 #include "afs/exporter.h"
25 extern struct afs_exporter
*afs_nfsexporter
;
28 #define AFS_VFSLOCK_DECL int glockOwner = ISAFS_GLOCK()
29 #define AFS_VFSLOCK() if (!glockOwner) AFS_GLOCK()
30 #define AFS_VFSUNLOCK() if (!glockOwner) AFS_GUNLOCK()
32 struct vfs
*afs_globalVFS
= 0;
33 struct vcache
*afs_globalVp
= 0;
35 static int afs_root_nolock(struct vfs
*afsp
, struct vnode
**avpp
);
38 afs_mount(afsp
, path
, data
)
43 struct vnode
*afsrootvp
= NULL
;
47 AFS_STATCNT(afs_mount
);
50 /* Don't allow remounts since some system (like AIX) don't handle
54 return (setuerror(EBUSY
));
59 afsp
->vfs_bsize
= 8192;
61 #ifdef AFS_64BIT_CLIENT
62 afsp
->vfs_flag
|= VFS_DEVMOUNT
;
63 #endif /* AFS_64BIT_CLIENT */
65 afsp
->vfs_fsid
.val
[0] = AFS_VFSMAGIC
; /* magic */
66 afsp
->vfs_fsid
.val
[1] = AFS_VFSFSID
;
68 /* For AFS, we don't allow file over file mounts. */
69 if (afsp
->vfs_mntdover
->v_type
!= VDIR
) {
71 return (setuerror(ENOTDIR
));
73 /* try to get the root vnode, but don't worry if you don't. The actual
74 * setting of the root vnode (vfs_mntd) is done in afs_root, so that it
75 * get re-eval'd at the right time if things aren't working when we
76 * first try the mount.
78 afs_root_nolock(afsp
, &afsrootvp
);
80 afsp
->vfs_mntdover
->v_mvfsp
= afsp
;
81 afsp
->vfs_mdata
->vmt_flags
|= MNT_REMOTE
;
85 afsp
->vfs_mntd
->v_count
= 1;
87 #ifdef AFS_AIX_IAUTH_ENV
88 if (afs_iauth_register() < 0)
89 afs_warn("Can't register AFS iauth interface.\n");
96 afs_unmount(struct vfs
*afsp
, int flag
)
100 AFS_STATCNT(afs_unmount
);
103 afs_cold_shutdown
= 1;
111 afs_root_nolock(struct vfs
*afsp
, struct vnode
**avpp
)
114 struct vrequest treq
;
115 struct vcache
*tvp
= 0;
117 AFS_STATCNT(afs_root
);
118 if (afs_globalVp
&& (afs_globalVp
->f
.states
& CStatd
)) {
123 afs_PutVCache(afs_globalVp
);
127 if (!(code
= afs_InitReq(&treq
, credp
)) && !(code
= afs_CheckInit())) {
128 tvp
= afs_GetVCache(&afs_rootFid
, &treq
, NULL
, NULL
);
129 /* we really want this to stay around */
138 VN_HOLD(AFSTOV(tvp
));
140 VN_LOCK(AFSTOV(tvp
));
141 AFSTOV(tvp
)->v_flag
|= VROOT
; /* No-op on Ultrix 2.2 */
142 VN_UNLOCK(AFSTOV(tvp
));
144 afs_globalVFS
= afsp
;
146 afsp
->vfs_mntd
= *avpp
;
149 afs_Trace2(afs_iclSetp
, CM_TRACE_VFSROOT
, ICL_TYPE_POINTER
, *avpp
,
150 ICL_TYPE_INT32
, code
);
156 afs_root(struct vfs
*afsp
, struct vnode
**avpp
)
161 code
= afs_root_nolock(afsp
, avpp
);
167 afs_statfs(struct vfs
*afsp
, struct statfs
*abp
, struct ucred
*credp
)
171 AFS_STATCNT(afs_statfs
);
175 abp
->f_bsize
= afsp
->vfs_bsize
;
176 abp
->f_blocks
= abp
->f_bfree
= abp
->f_bavail
= abp
->f_files
=
177 abp
->f_ffree
= AFS_VFS_FAKEFREE
;
178 abp
->f_vfstype
= AFS_VFSFSID
;
179 abp
->f_vfsnumber
= afsp
->vfs_number
;
180 abp
->f_vfsoff
= abp
->f_vfslen
= abp
->f_vfsvers
= -1;
181 abp
->f_fsize
= 4096; /* fundamental filesystem block size */
182 abp
->f_fsid
= afsp
->vfs_fsid
;
183 (void)strcpy(abp
->f_fname
, "/afs");
184 (void)strcpy(abp
->f_fpack
, "AFS");
185 abp
->f_name_max
= 256;
196 AFS_STATCNT(afs_sync
);
203 /* Note that the cred is only for AIX 4.1.5+ and AIX 4.2+ */
205 afs_vget(struct vfs
*vfsp
, struct vnode
**avcp
, struct fileid
*fidp
,
209 struct vrequest treq
;
212 AFS_STATCNT(afs_vget
);
215 #ifdef AFS_AIX_IAUTH_ENV
216 /* If the exporter is off and this is an nfsd, fail immediately. */
217 if (AFS_NFSXLATORREQ(credp
)
218 && !(afs_nfsexporter
->exp_states
& EXP_EXPORTED
)) {
223 if ((code
= afs_InitReq(&treq
, credp
)) == 0) {
224 code
= afs_osi_vget((struct vcache
**)avcp
, fidp
, &treq
);
227 afs_Trace3(afs_iclSetp
, CM_TRACE_VGET
, ICL_TYPE_POINTER
, *avcp
,
228 ICL_TYPE_INT32
, treq
.uid
, ICL_TYPE_FID
, fidp
);
229 code
= afs_CheckCode(code
, &treq
, 42);
242 struct vfsops Afs_vfsops
= {
249 afs_badop
, /* vfs_cntl */
250 afs_badop
/* vfs_quotactl */
252 , afs_badop
/* vfs_syncvfs */
257 * VFS is initialized in osi_config.c