7 #include <afs/sysincludes.h> /* Standard vendor system headers */
8 #include <afsincludes.h> /* Afs-based standard headers */
9 #include <afs/afs_stats.h> /* statistics */
10 #include <sys/malloc.h>
11 #include <sys/namei.h>
13 #include <sys/module.h>
14 #include <sys/sysproto.h>
15 #include <sys/syscall.h>
16 #include <sys/sysent.h>
18 struct vcache *afs_globalVp = NULL;
19 struct mount *afs_globalVFS = NULL;
20 int afs_pbuf_freecnt = -1;
23 #define THREAD_OR_PROC struct thread *p
25 #define THREAD_OR_PROC struct proc *p
28 extern int afs3_syscall();
29 extern int Afs_xsetgroups();
30 extern int afs_xioctl();
32 static sy_call_t *old_handler;
36 afs_init(struct vfsconf *vfc)
38 if (sysent[AFS_SYSCALL].sy_call != nosys
39 && sysent[AFS_SYSCALL].sy_call != lkmnosys) {
40 printf("AFS_SYSCALL in use. aborting\n");
44 afs_pbuf_freecnt = nswbuf / 2 + 1;
46 sysent[SYS_setgroups].sy_call = Afs_xsetgroups;
47 sysent[SYS_ioctl].sy_call = afs_xioctl;
49 old_handler = sysent[AFS_SYSCALL].sy_call;
50 sysent[AFS_SYSCALL].sy_call = afs3_syscall;
51 sysent[AFS_SYSCALL].sy_narg = 5;
56 afs_uninit(struct vfsconf *vfc)
61 sysent[SYS_ioctl].sy_call = ioctl;
62 sysent[SYS_setgroups].sy_call = setgroups;
64 sysent[AFS_SYSCALL].sy_narg = 0;
65 sysent[AFS_SYSCALL].sy_call = old_handler;
70 afs_start(struct mount *mp, int flags, THREAD_OR_PROC)
72 return (0); /* nothing to do. ? */
77 afs_omount(struct mount *mp, char *path, caddr_t data, struct thread *p)
79 afs_omount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp,
83 /* ndp contains the mounted-from device. Just ignore it.
84 * we also don't care about our proc struct. */
87 if (mp->mnt_flag & MNT_UPDATE)
91 AFS_STATCNT(afs_mount);
93 if (afs_globalVFS) { /* Don't allow remounts. */
101 mp->mnt_stat.f_iosize = 8192;
104 copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
106 bcopy("/afs", mp->mnt_stat.f_mntonname, size = 4);
107 memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
108 memset(mp->mnt_stat.f_mntfromname, 0, MNAMELEN);
109 strcpy(mp->mnt_stat.f_mntfromname, "AFS");
110 /* null terminated string "AFS" will fit, just leave it be. */
111 strcpy(mp->mnt_stat.f_fstypename, "afs");
113 afs_statfs(mp, &mp->mnt_stat, p);
117 #ifdef AFS_FBSD53_ENV
119 afs_mount(struct mount *mp, struct thread *td)
121 return afs_omount(mp, NULL, NULL, td);
125 #ifdef AFS_FBSD60_ENV
127 afs_cmount(struct mntarg *ma, void *data, int flags, struct thread *td)
129 return kernel_mount(ma, flags);
134 afs_unmount(struct mount *mp, int flags, THREAD_OR_PROC)
138 * Release any remaining vnodes on this mount point.
139 * The `1' means that we hold one extra reference on
140 * the root vnode (this is just a guess right now).
141 * This has to be done outside the global lock.
143 #ifdef AFS_FBSD53_ENV
144 vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, p);
146 vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0);
149 AFS_STATCNT(afs_unmount);
158 #ifdef AFS_FBSD53_ENV
159 afs_root(struct mount *mp, struct vnode **vpp, struct thread *td)
161 afs_root(struct mount *mp, struct vnode **vpp)
165 struct vrequest treq;
166 register struct vcache *tvp = 0;
167 #ifdef AFS_FBSD50_ENV
168 #ifndef AFS_FBSD53_ENV
169 struct thread *td = curthread;
171 struct ucred *cr = td->td_ucred;
173 struct proc *p = curproc;
174 struct ucred *cr = p->p_cred->pc_ucred;
178 AFS_STATCNT(afs_root);
180 if (afs_globalVp && (afs_globalVp->states & CStatd)) {
186 afs_PutVCache(afs_globalVp);
187 /* vrele() needed here or not? */
191 if (!(error = afs_InitReq(&treq, cr)) && !(error = afs_CheckInit())) {
192 tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
193 /* we really want this to stay around */
201 struct vnode *vp = AFSTOV(tvp);
203 #ifdef AFS_FBSD50_ENV
204 ASSERT_VI_UNLOCKED(vp, "afs_root");
208 * I'm uncomfortable about this. Shouldn't this happen at a
209 * higher level, and shouldn't we busy the top-level directory
210 * to prevent recycling?
212 #ifdef AFS_FBSD50_ENV
213 error = vget(vp, LK_EXCLUSIVE | LK_RETRY, td);
214 vp->v_vflag |= VV_ROOT;
216 error = vget(vp, LK_EXCLUSIVE | LK_RETRY, p);
227 afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *vpp,
228 ICL_TYPE_INT32, error);
235 afs_statfs(struct mount *mp, struct statfs *abp, THREAD_OR_PROC)
238 AFS_STATCNT(afs_statfs);
240 abp->f_bsize = mp->vfs_bsize;
241 abp->f_iosize = mp->vfs_bsize;
243 /* Fake a high number below to satisfy programs that use the statfs call
244 * to make sure that there's enough space in the device partition before
245 * storing something there.
247 abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
248 abp->f_ffree = 2000000;
250 abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
251 abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];
252 if (abp != &mp->mnt_stat) {
253 abp->f_type = mp->mnt_vfc->vfc_typenum;
254 memcpy((caddr_t) & abp->f_mntonname[0],
255 (caddr_t) mp->mnt_stat.f_mntonname, MNAMELEN);
256 memcpy((caddr_t) & abp->f_mntfromname[0],
257 (caddr_t) mp->mnt_stat.f_mntfromname, MNAMELEN);
265 #ifdef AFS_FBSD60_ENV
266 afs_sync(struct mount *mp, int waitfor, struct thread *td)
268 afs_sync(struct mount *mp, int waitfor, struct ucred *cred, THREAD_OR_PROC)
274 #ifdef AFS_FBSD60_ENV
275 struct vfsops afs_vfsops = {
276 .vfs_init = afs_init,
277 .vfs_mount = afs_mount,
278 .vfs_cmount = afs_cmount,
279 .vfs_root = afs_root,
280 .vfs_statfs = afs_statfs,
281 .vfs_sync = afs_sync,
282 .vfs_uninit = afs_uninit,
283 .vfs_unmount = afs_unmount,
284 .vfs_sysctl = vfs_stdsysctl,
287 struct vfsops afs_vfsops = {
288 #ifdef AFS_FBSD53_ENV
305 #ifdef AFS_FBSD50_ENV