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/syscall.h>
15 struct vcache *afs_globalVp = 0;
16 struct mount *afs_globalVFS = 0;
17 int afs_pbuf_freecnt = -1;
20 #define THREAD_OR_PROC struct thread *p
22 #define THREAD_OR_PROC struct proc *p
26 afs_start(struct mount *mp, int flags, THREAD_OR_PROC)
28 afs_pbuf_freecnt = nswbuf / 2 + 1;
29 return (0); /* nothing to do. ? */
33 afs_mount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp,
36 /* ndp contains the mounted-from device. Just ignore it.
37 * we also don't care about our proc struct. */
40 if (mp->mnt_flag & MNT_UPDATE)
44 AFS_STATCNT(afs_mount);
46 if (afs_globalVFS) { /* Don't allow remounts. */
54 mp->mnt_stat.f_iosize = 8192;
56 (void)copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
57 memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
58 memset(mp->mnt_stat.f_mntfromname, 0, MNAMELEN);
59 strcpy(mp->mnt_stat.f_mntfromname, "AFS");
60 /* null terminated string "AFS" will fit, just leave it be. */
61 strcpy(mp->mnt_stat.f_fstypename, "afs");
63 (void)afs_statfs(mp, &mp->mnt_stat, p);
68 afs_unmount(struct mount *mp, int flags, THREAD_OR_PROC)
72 * Release any remaining vnodes on this mount point.
73 * The `1' means that we hold one extra reference on
74 * the root vnode (this is just a guess right now).
75 * This has to be done outside the global lock.
78 vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, p);
80 vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0);
83 AFS_STATCNT(afs_unmount);
92 afs_root(struct mount *mp, struct vnode **vpp)
96 register struct vcache *tvp = 0;
98 struct thread *td = curthread;
99 struct ucred *cr = td->td_ucred;
101 struct proc *p = curproc;
102 struct ucred *cr = p->p_cred->pc_ucred;
106 AFS_STATCNT(afs_root);
108 if (afs_globalVp && (afs_globalVp->states & CStatd)) {
114 afs_PutVCache(afs_globalVp);
115 /* vrele() needed here or not? */
119 if (!(error = afs_InitReq(&treq, cr)) && !(error = afs_CheckInit())) {
120 tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
121 /* we really want this to stay around */
129 struct vnode *vp = AFSTOV(tvp);
131 #ifdef AFS_FBSD50_ENV
132 ASSERT_VI_UNLOCKED(vp, "afs_root");
136 * I'm uncomfortable about this. Shouldn't this happen at a
137 * higher level, and shouldn't we busy the top-level directory
138 * to prevent recycling?
140 #ifdef AFS_FBSD50_ENV
141 error = vget(vp, LK_EXCLUSIVE | LK_RETRY, td);
142 vp->v_vflag |= VV_ROOT;
144 error = vget(vp, LK_EXCLUSIVE | LK_RETRY, p);
155 afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *vpp,
156 ICL_TYPE_INT32, error);
163 afs_statfs(struct mount *mp, struct statfs *abp, THREAD_OR_PROC)
166 AFS_STATCNT(afs_statfs);
168 abp->f_bsize = mp->vfs_bsize;
169 abp->f_iosize = mp->vfs_bsize;
171 /* Fake a high number below to satisfy programs that use the statfs call
172 * to make sure that there's enough space in the device partition before
173 * storing something there.
175 abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
176 abp->f_ffree = 2000000;
178 abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
179 abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];
180 if (abp != &mp->mnt_stat) {
181 abp->f_type = mp->mnt_vfc->vfc_typenum;
182 memcpy((caddr_t) & abp->f_mntonname[0],
183 (caddr_t) mp->mnt_stat.f_mntonname, MNAMELEN);
184 memcpy((caddr_t) & abp->f_mntfromname[0],
185 (caddr_t) mp->mnt_stat.f_mntfromname, MNAMELEN);
193 afs_sync(struct mount *mp, int waitfor, struct ucred *cred, THREAD_OR_PROC)
199 afs_init(struct vfsconf *vfc)
204 struct vfsops afs_vfsops = {
219 #ifdef AFS_FBSD50_ENV