5 #include <afs/sysincludes.h> /* Standard vendor system headers */
6 #include <afsincludes.h> /* Afs-based standard headers */
7 #include <afs/afs_stats.h> /* statistics */
8 #include <sys/malloc.h>
11 #include <sys/module.h>
12 #include <sys/sysproto.h>
13 #include <sys/syscall.h>
14 #include <sys/sysent.h>
16 struct vcache *afs_globalVp = NULL;
17 struct mount *afs_globalVFS = NULL;
18 int afs_pbuf_freecnt = -1;
21 #define THREAD_OR_PROC struct thread *p
23 #define THREAD_OR_PROC struct proc *p
26 extern int Afs_xsetgroups();
27 extern int afs_xioctl();
29 static sy_call_t *old_handler;
33 afs_init(struct vfsconf *vfc)
35 if (sysent[AFS_SYSCALL].sy_call != nosys
36 && sysent[AFS_SYSCALL].sy_call != lkmnosys) {
37 printf("AFS_SYSCALL in use. aborting\n");
41 afs_pbuf_freecnt = nswbuf / 2 + 1;
43 sysent[SYS_setgroups].sy_call = Afs_xsetgroups;
44 sysent[SYS_ioctl].sy_call = afs_xioctl;
46 old_handler = sysent[AFS_SYSCALL].sy_call;
47 sysent[AFS_SYSCALL].sy_call = afs3_syscall;
48 sysent[AFS_SYSCALL].sy_narg = 5;
53 afs_uninit(struct vfsconf *vfc)
58 sysent[SYS_ioctl].sy_call = ioctl;
59 sysent[SYS_setgroups].sy_call = setgroups;
61 sysent[AFS_SYSCALL].sy_narg = 0;
62 sysent[AFS_SYSCALL].sy_call = old_handler;
67 afs_start(struct mount *mp, int flags, THREAD_OR_PROC)
69 return (0); /* nothing to do. ? */
73 #if defined(AFS_FBSD80_ENV)
74 afs_omount(struct mount *mp, char *path, caddr_t data)
75 #elif defined(AFS_FBSD53_ENV)
76 afs_omount(struct mount *mp, char *path, caddr_t data, struct thread *p)
78 afs_omount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp,
82 /* ndp contains the mounted-from device. Just ignore it.
83 * we also don't care about our proc struct. */
86 if (mp->mnt_flag & MNT_UPDATE)
90 AFS_STATCNT(afs_mount);
92 if (afs_globalVFS) { /* Don't allow remounts. */
100 #ifdef AFS_FBSD70_ENV /* XXX 70? */
102 mp->mnt_flag &= ~MNT_LOCAL;
103 mp->mnt_kern_flag |= MNTK_MPSAFE; /* solid steel */
105 mp->mnt_stat.f_iosize = 8192;
108 copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
110 bcopy("/afs", mp->mnt_stat.f_mntonname, size = 4);
111 memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
112 memset(mp->mnt_stat.f_mntfromname, 0, MNAMELEN);
113 strcpy(mp->mnt_stat.f_mntfromname, "AFS");
114 /* null terminated string "AFS" will fit, just leave it be. */
115 strcpy(mp->mnt_stat.f_fstypename, "afs");
116 #ifdef AFS_FBSD70_ENV
120 #ifdef AFS_FBSD80_ENV
121 afs_statfs(mp, &mp->mnt_stat);
123 afs_statfs(mp, &mp->mnt_stat, p);
129 #ifdef AFS_FBSD53_ENV
131 #ifdef AFS_FBSD80_ENV
132 afs_mount(struct mount *mp)
134 afs_mount(struct mount *mp, struct thread *td)
137 #ifdef AFS_FBSD80_ENV
138 return afs_omount(mp, NULL, NULL);
140 return afs_omount(mp, NULL, NULL, td);
145 #ifdef AFS_FBSD60_ENV
147 #ifdef AFS_FBSD80_ENV
148 afs_cmount(struct mntarg *ma, void *data, int flags)
150 afs_cmount(struct mntarg *ma, void *data, int flags, struct thread *td)
153 return kernel_mount(ma, flags);
158 #ifdef AFS_FBSD80_ENV
159 afs_unmount(struct mount *mp, int flags)
161 afs_unmount(struct mount *mp, int flags, THREAD_OR_PROC)
166 * Release any remaining vnodes on this mount point.
167 * The `1' means that we hold one extra reference on
168 * the root vnode (this is just a guess right now).
169 * This has to be done outside the global lock.
171 #if defined(AFS_FBSD80_ENV)
173 #elif defined(AFS_FBSD53_ENV)
174 vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, p);
176 vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0);
179 AFS_STATCNT(afs_unmount);
188 #if defined(AFS_FBSD80_ENV)
189 afs_root(struct mount *mp, int flags, struct vnode **vpp)
190 #elif defined(AFS_FBSD60_ENV)
191 afs_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td)
192 #elif defined(AFS_FBSD53_ENV)
193 afs_root(struct mount *mp, struct vnode **vpp, struct thread *td)
195 afs_root(struct mount *mp, struct vnode **vpp)
199 struct vrequest treq;
200 register struct vcache *tvp = 0;
201 #ifdef AFS_FBSD50_ENV
202 #if !defined(AFS_FBSD53_ENV) || defined(AFS_FBSD80_ENV)
203 struct thread *td = curthread;
205 struct ucred *cr = osi_curcred();
207 struct proc *p = curproc;
208 struct ucred *cr = p->p_cred->pc_ucred;
212 AFS_STATCNT(afs_root);
214 if (afs_globalVp && (afs_globalVp->f.states & CStatd)) {
219 #ifndef AFS_FBSD80_ENV
221 afs_PutVCache(afs_globalVp);
222 /* vrele() needed here or not? */
226 if (!(error = afs_InitReq(&treq, cr)) && !(error = afs_CheckInit())) {
227 tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
228 /* we really want this to stay around */
236 struct vnode *vp = AFSTOV(tvp);
238 #ifdef AFS_FBSD50_ENV
239 ASSERT_VI_UNLOCKED(vp, "afs_root");
243 * I'm uncomfortable about this. Shouldn't this happen at a
244 * higher level, and shouldn't we busy the top-level directory
245 * to prevent recycling?
247 #ifdef AFS_FBSD50_ENV
248 error = vget(vp, LK_EXCLUSIVE | LK_RETRY, td);
249 vp->v_vflag |= VV_ROOT;
251 error = vget(vp, LK_EXCLUSIVE | LK_RETRY, p);
262 afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, tvp ? AFSTOV(tvp) : NULL,
263 ICL_TYPE_INT32, error);
270 #ifdef AFS_FBSD80_ENV
271 afs_statfs(struct mount *mp, struct statfs *abp)
273 afs_statfs(struct mount *mp, struct statfs *abp, THREAD_OR_PROC)
277 AFS_STATCNT(afs_statfs);
279 abp->f_bsize = mp->vfs_bsize;
280 abp->f_iosize = mp->vfs_bsize;
282 /* Fake a high number below to satisfy programs that use the statfs call
283 * to make sure that there's enough space in the device partition before
284 * storing something there.
286 abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
287 abp->f_ffree = 2000000;
289 abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
290 abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];
291 if (abp != &mp->mnt_stat) {
292 abp->f_type = mp->mnt_vfc->vfc_typenum;
293 memcpy((caddr_t) & abp->f_mntonname[0],
294 (caddr_t) mp->mnt_stat.f_mntonname, MNAMELEN);
295 memcpy((caddr_t) & abp->f_mntfromname[0],
296 (caddr_t) mp->mnt_stat.f_mntfromname, MNAMELEN);
304 #if defined(AFS_FBSD80_ENV)
305 afs_sync(struct mount *mp, int waitfor)
306 #elif defined(AFS_FBSD60_ENV)
307 afs_sync(struct mount *mp, int waitfor, struct thread *td)
309 afs_sync(struct mount *mp, int waitfor, struct ucred *cred, THREAD_OR_PROC)
315 #ifdef AFS_FBSD60_ENV
316 struct vfsops afs_vfsops = {
317 .vfs_init = afs_init,
318 .vfs_mount = afs_mount,
319 .vfs_cmount = afs_cmount,
320 .vfs_root = afs_root,
321 .vfs_statfs = afs_statfs,
322 .vfs_sync = afs_sync,
323 .vfs_uninit = afs_uninit,
324 .vfs_unmount = afs_unmount,
325 .vfs_sysctl = vfs_stdsysctl,
328 struct vfsops afs_vfsops = {
329 #ifdef AFS_FBSD53_ENV
346 #ifdef AFS_FBSD50_ENV