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;
20 extern int Afs_xsetgroups();
21 extern int afs_xioctl();
23 static sy_call_t *old_handler;
27 afs_init(struct vfsconf *vfc)
29 if (sysent[AFS_SYSCALL].sy_call != nosys
30 && sysent[AFS_SYSCALL].sy_call != lkmnosys) {
31 printf("AFS_SYSCALL in use. aborting\n");
35 afs_pbuf_freecnt = nswbuf / 2 + 1;
37 sysent[SYS_setgroups].sy_call = Afs_xsetgroups;
38 sysent[SYS_ioctl].sy_call = afs_xioctl;
40 old_handler = sysent[AFS_SYSCALL].sy_call;
41 sysent[AFS_SYSCALL].sy_call = afs3_syscall;
42 sysent[AFS_SYSCALL].sy_narg = 5;
47 afs_uninit(struct vfsconf *vfc)
52 sysent[SYS_ioctl].sy_call = ioctl;
53 sysent[SYS_setgroups].sy_call = setgroups;
55 sysent[AFS_SYSCALL].sy_narg = 0;
56 sysent[AFS_SYSCALL].sy_call = old_handler;
61 afs_start(struct mount *mp, int flags, struct thread *p)
63 return (0); /* nothing to do. ? */
67 #if defined(AFS_FBSD80_ENV)
68 afs_omount(struct mount *mp, char *path, caddr_t data)
69 #elif defined(AFS_FBSD53_ENV)
70 afs_omount(struct mount *mp, char *path, caddr_t data, struct thread *p)
72 afs_omount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp,
76 /* ndp contains the mounted-from device. Just ignore it.
77 * we also don't care about our thread struct. */
80 if (mp->mnt_flag & MNT_UPDATE)
84 AFS_STATCNT(afs_mount);
86 if (afs_globalVFS) { /* Don't allow remounts. */
94 #ifdef AFS_FBSD70_ENV /* XXX 70? */
96 mp->mnt_flag &= ~MNT_LOCAL;
97 mp->mnt_kern_flag |= MNTK_MPSAFE; /* solid steel */
99 mp->mnt_stat.f_iosize = 8192;
102 copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
104 bcopy("/afs", mp->mnt_stat.f_mntonname, size = 4);
105 memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
106 memset(mp->mnt_stat.f_mntfromname, 0, MNAMELEN);
107 strcpy(mp->mnt_stat.f_mntfromname, "AFS");
108 /* null terminated string "AFS" will fit, just leave it be. */
109 strcpy(mp->mnt_stat.f_fstypename, "afs");
110 #ifdef AFS_FBSD70_ENV
114 #ifdef AFS_FBSD80_ENV
115 afs_statfs(mp, &mp->mnt_stat);
117 afs_statfs(mp, &mp->mnt_stat, p);
123 #ifdef AFS_FBSD53_ENV
125 #ifdef AFS_FBSD80_ENV
126 afs_mount(struct mount *mp)
128 afs_mount(struct mount *mp, struct thread *td)
131 #ifdef AFS_FBSD80_ENV
132 return afs_omount(mp, NULL, NULL);
134 return afs_omount(mp, NULL, NULL, td);
139 #ifdef AFS_FBSD60_ENV
141 #ifdef AFS_FBSD80_ENV
142 afs_cmount(struct mntarg *ma, void *data, int flags)
144 afs_cmount(struct mntarg *ma, void *data, int flags, struct thread *td)
147 return kernel_mount(ma, flags);
152 #ifdef AFS_FBSD80_ENV
153 afs_unmount(struct mount *mp, int flags)
155 afs_unmount(struct mount *mp, int flags, struct thread *p)
161 * Release any remaining vnodes on this mount point.
162 * The `1' means that we hold one extra reference on
163 * the root vnode (this is just a guess right now).
164 * This has to be done outside the global lock.
166 #if defined(AFS_FBSD80_ENV)
167 error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, curthread);
168 #elif defined(AFS_FBSD53_ENV)
169 error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, p);
171 error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0);
176 AFS_STATCNT(afs_unmount);
186 #if defined(AFS_FBSD80_ENV)
187 afs_root(struct mount *mp, int flags, struct vnode **vpp)
188 #elif defined(AFS_FBSD60_ENV)
189 afs_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td)
190 #elif defined(AFS_FBSD53_ENV)
191 afs_root(struct mount *mp, struct vnode **vpp, struct thread *td)
193 afs_root(struct mount *mp, struct vnode **vpp)
197 struct vrequest treq;
198 struct vcache *tvp = 0;
199 #if !defined(AFS_FBSD53_ENV) || defined(AFS_FBSD80_ENV)
200 struct thread *td = curthread;
202 struct ucred *cr = osi_curcred();
205 AFS_STATCNT(afs_root);
207 if (afs_globalVp && (afs_globalVp->f.states & CStatd)) {
213 afs_PutVCache(afs_globalVp);
214 /* vrele() needed here or not? */
217 if (!(error = afs_InitReq(&treq, cr)) && !(error = afs_CheckInit())) {
218 tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
219 /* we really want this to stay around */
227 struct vnode *vp = AFSTOV(tvp);
229 ASSERT_VI_UNLOCKED(vp, "afs_root");
232 * I'm uncomfortable about this. Shouldn't this happen at a
233 * higher level, and shouldn't we busy the top-level directory
234 * to prevent recycling?
236 error = vget(vp, LK_EXCLUSIVE | LK_RETRY, td);
237 vp->v_vflag |= VV_ROOT;
246 afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, tvp ? AFSTOV(tvp) : NULL,
247 ICL_TYPE_INT32, error);
254 #ifdef AFS_FBSD80_ENV
255 afs_statfs(struct mount *mp, struct statfs *abp)
257 afs_statfs(struct mount *mp, struct statfs *abp, struct thread *p)
261 AFS_STATCNT(afs_statfs);
263 abp->f_bsize = mp->vfs_bsize;
264 abp->f_iosize = mp->vfs_bsize;
266 /* Fake a high number below to satisfy programs that use the statfs call
267 * to make sure that there's enough space in the device partition before
268 * storing something there.
270 abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
271 abp->f_ffree = 2000000;
273 abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
274 abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];
275 if (abp != &mp->mnt_stat) {
276 abp->f_type = mp->mnt_vfc->vfc_typenum;
277 memcpy((caddr_t) & abp->f_mntonname[0],
278 (caddr_t) mp->mnt_stat.f_mntonname, MNAMELEN);
279 memcpy((caddr_t) & abp->f_mntfromname[0],
280 (caddr_t) mp->mnt_stat.f_mntfromname, MNAMELEN);
288 #if defined(AFS_FBSD80_ENV)
289 afs_sync(struct mount *mp, int waitfor)
290 #elif defined(AFS_FBSD60_ENV)
291 afs_sync(struct mount *mp, int waitfor, struct thread *td)
293 afs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct thread *p)
299 #ifdef AFS_FBSD60_ENV
300 struct vfsops afs_vfsops = {
301 .vfs_init = afs_init,
302 .vfs_mount = afs_mount,
303 .vfs_cmount = afs_cmount,
304 .vfs_root = afs_root,
305 .vfs_statfs = afs_statfs,
306 .vfs_sync = afs_sync,
307 .vfs_uninit = afs_uninit,
308 .vfs_unmount = afs_unmount,
309 .vfs_sysctl = vfs_stdsysctl,
312 struct vfsops afs_vfsops = {
313 #ifdef AFS_FBSD53_ENV