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);
83 afs_unmount(struct mount *mp, int flags, THREAD_OR_PROC)
87 * Release any remaining vnodes on this mount point.
88 * The `1' means that we hold one extra reference on
89 * the root vnode (this is just a guess right now).
90 * This has to be done outside the global lock.
93 vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, p);
95 vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0);
98 AFS_STATCNT(afs_unmount);
107 #ifdef AFS_FBSD53_ENV
108 afs_root(struct mount *mp, struct vnode **vpp, struct thread *td)
110 afs_root(struct mount *mp, struct vnode **vpp)
114 struct vrequest treq;
115 register struct vcache *tvp = 0;
116 #ifdef AFS_FBSD50_ENV
117 #ifndef AFS_FBSD53_ENV
118 struct thread *td = curthread;
120 struct ucred *cr = td->td_ucred;
122 struct proc *p = curproc;
123 struct ucred *cr = p->p_cred->pc_ucred;
127 AFS_STATCNT(afs_root);
129 if (afs_globalVp && (afs_globalVp->states & CStatd)) {
135 afs_PutVCache(afs_globalVp);
136 /* vrele() needed here or not? */
140 if (!(error = afs_InitReq(&treq, cr)) && !(error = afs_CheckInit())) {
141 tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
142 /* we really want this to stay around */
150 struct vnode *vp = AFSTOV(tvp);
152 #ifdef AFS_FBSD50_ENV
153 ASSERT_VI_UNLOCKED(vp, "afs_root");
157 * I'm uncomfortable about this. Shouldn't this happen at a
158 * higher level, and shouldn't we busy the top-level directory
159 * to prevent recycling?
161 #ifdef AFS_FBSD50_ENV
162 error = vget(vp, LK_EXCLUSIVE | LK_RETRY, td);
163 vp->v_vflag |= VV_ROOT;
165 error = vget(vp, LK_EXCLUSIVE | LK_RETRY, p);
176 afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *vpp,
177 ICL_TYPE_INT32, error);
184 afs_statfs(struct mount *mp, struct statfs *abp, THREAD_OR_PROC)
187 AFS_STATCNT(afs_statfs);
189 abp->f_bsize = mp->vfs_bsize;
190 abp->f_iosize = mp->vfs_bsize;
192 /* Fake a high number below to satisfy programs that use the statfs call
193 * to make sure that there's enough space in the device partition before
194 * storing something there.
196 abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
197 abp->f_ffree = 2000000;
199 abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
200 abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];
201 if (abp != &mp->mnt_stat) {
202 abp->f_type = mp->mnt_vfc->vfc_typenum;
203 memcpy((caddr_t) & abp->f_mntonname[0],
204 (caddr_t) mp->mnt_stat.f_mntonname, MNAMELEN);
205 memcpy((caddr_t) & abp->f_mntfromname[0],
206 (caddr_t) mp->mnt_stat.f_mntfromname, MNAMELEN);
214 afs_sync(struct mount *mp, int waitfor, struct ucred *cred, THREAD_OR_PROC)
220 afs_init(struct vfsconf *vfc)
225 struct vfsops afs_vfsops = {
226 #ifdef AFS_FBSD53_ENV
243 #ifdef AFS_FBSD50_ENV