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 = NULL;
16 struct mount *afs_globalVFS = NULL;
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. ? */
34 afs_mount(struct mount *mp, struct thread *td)
36 int afs_omount(struct mount *mp, char *path, caddr_t data, struct thread *p);
38 return afs_omount(mp, NULL, NULL, td);
44 afs_omount(struct mount *mp, char *path, caddr_t data, struct thread *p)
46 afs_omount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp,
50 /* ndp contains the mounted-from device. Just ignore it.
51 * we also don't care about our proc struct. */
54 if (mp->mnt_flag & MNT_UPDATE)
58 AFS_STATCNT(afs_mount);
60 if (afs_globalVFS) { /* Don't allow remounts. */
68 mp->mnt_stat.f_iosize = 8192;
71 (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
72 memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
73 memset(mp->mnt_stat.f_mntfromname, 0, MNAMELEN);
74 strcpy(mp->mnt_stat.f_mntfromname, "AFS");
75 /* null terminated string "AFS" will fit, just leave it be. */
76 strcpy(mp->mnt_stat.f_fstypename, "afs");
78 (void)afs_statfs(mp, &mp->mnt_stat, p);
84 afs_cmount(struct mntarg *ma, void *data, int flags, struct thread *td)
86 return kernel_mount(ma, flags);
91 afs_unmount(struct mount *mp, int flags, THREAD_OR_PROC)
95 * Release any remaining vnodes on this mount point.
96 * The `1' means that we hold one extra reference on
97 * the root vnode (this is just a guess right now).
98 * This has to be done outside the global lock.
100 #ifdef AFS_FBSD53_ENV
101 vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, p);
103 vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0);
106 AFS_STATCNT(afs_unmount);
115 #ifdef AFS_FBSD53_ENV
116 afs_root(struct mount *mp, struct vnode **vpp, struct thread *td)
118 afs_root(struct mount *mp, struct vnode **vpp)
122 struct vrequest treq;
123 register struct vcache *tvp = 0;
124 #ifdef AFS_FBSD50_ENV
125 #ifndef AFS_FBSD53_ENV
126 struct thread *td = curthread;
128 struct ucred *cr = td->td_ucred;
130 struct proc *p = curproc;
131 struct ucred *cr = p->p_cred->pc_ucred;
135 AFS_STATCNT(afs_root);
137 if (afs_globalVp && (afs_globalVp->states & CStatd)) {
143 afs_PutVCache(afs_globalVp);
144 /* vrele() needed here or not? */
148 if (!(error = afs_InitReq(&treq, cr)) && !(error = afs_CheckInit())) {
149 tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
150 /* we really want this to stay around */
158 struct vnode *vp = AFSTOV(tvp);
160 #ifdef AFS_FBSD50_ENV
161 ASSERT_VI_UNLOCKED(vp, "afs_root");
165 * I'm uncomfortable about this. Shouldn't this happen at a
166 * higher level, and shouldn't we busy the top-level directory
167 * to prevent recycling?
169 #ifdef AFS_FBSD50_ENV
170 error = vget(vp, LK_EXCLUSIVE | LK_RETRY, td);
171 vp->v_vflag |= VV_ROOT;
173 error = vget(vp, LK_EXCLUSIVE | LK_RETRY, p);
184 afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *vpp,
185 ICL_TYPE_INT32, error);
192 afs_statfs(struct mount *mp, struct statfs *abp, THREAD_OR_PROC)
195 AFS_STATCNT(afs_statfs);
197 abp->f_bsize = mp->vfs_bsize;
198 abp->f_iosize = mp->vfs_bsize;
200 /* Fake a high number below to satisfy programs that use the statfs call
201 * to make sure that there's enough space in the device partition before
202 * storing something there.
204 abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
205 abp->f_ffree = 2000000;
207 abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
208 abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];
209 if (abp != &mp->mnt_stat) {
210 abp->f_type = mp->mnt_vfc->vfc_typenum;
211 memcpy((caddr_t) & abp->f_mntonname[0],
212 (caddr_t) mp->mnt_stat.f_mntonname, MNAMELEN);
213 memcpy((caddr_t) & abp->f_mntfromname[0],
214 (caddr_t) mp->mnt_stat.f_mntfromname, MNAMELEN);
222 #ifdef AFS_FBSD60_ENV
223 afs_sync(struct mount *mp, int waitfor, struct thread *td)
225 afs_sync(struct mount *mp, int waitfor, struct ucred *cred, THREAD_OR_PROC)
232 afs_init(struct vfsconf *vfc)
237 #ifdef AFS_FBSD60_ENV
238 struct vfsops afs_vfsops = {
239 .vfs_init = afs_init,
240 .vfs_mount = afs_mount,
241 .vfs_cmount = afs_cmount,
242 .vfs_root = afs_root,
243 .vfs_statfs = afs_statfs,
244 .vfs_sync = afs_sync,
245 .vfs_uninit = vfs_stduninit,
246 .vfs_unmount = afs_unmount,
247 .vfs_sysctl = vfs_stdsysctl,
250 struct vfsops afs_vfsops = {
251 #ifdef AFS_FBSD53_ENV
268 #ifdef AFS_FBSD50_ENV