6 #include <afs/sysincludes.h> /* Standard vendor system headers */
7 #include <afs/afsincludes.h> /* Afs-based standard headers */
8 #include <afs/afs_stats.h> /* statistics */
9 #include <sys/malloc.h>
10 #include <sys/namei.h>
12 #include <sys/syscall.h>
14 struct vcache *afs_globalVp = 0;
15 struct mount *afs_globalVFS = 0;
24 afs_fhtovp(mp, fhp, vpp)
43 afs_start(mp, flags, p)
48 return (0); /* nothing to do. ? */
52 afs_mount(mp, path, data, ndp, p)
53 register struct mount *mp;
56 struct nameidata *ndp;
59 /* ndp contains the mounted-from device. Just ignore it.
60 we also don't care about our proc struct. */
64 if (mp->mnt_flag & MNT_UPDATE)
68 AFS_STATCNT(afs_mount);
70 if (afs_globalVFS) { /* Don't allow remounts. */
78 mp->mnt_stat.f_iosize=8192;
80 (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN-1, &size);
81 bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
82 bzero(mp->mnt_stat.f_mntfromname, MNAMELEN);
83 strcpy(mp->mnt_stat.f_mntfromname, "AFS");
84 /* null terminated string "AFS" will fit, just leave it be. */
85 strcpy(mp->mnt_stat.f_fstypename, "afs");
87 (void) afs_statfs(mp, &mp->mnt_stat, p);
92 afs_unmount(mp, flags, p)
99 AFS_STATCNT(afs_unmount);
108 afs_root(struct mount *mp,
112 struct vrequest treq;
113 register struct vcache *tvp=0;
114 struct proc *p=current_proc();
118 cr=*p->p_cred->pc_ucred;
121 AFS_STATCNT(afs_root);
122 if (afs_globalVp && (afs_globalVp->states & CStatd)) {
127 if (!(error = afs_InitReq(&treq, &cr)) &&
128 !(error = afs_CheckInit())) {
129 tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0,
130 (struct vcache*)0, WRITE_LOCK);
131 /* we really want this to stay around */
141 vn_lock((struct vnode *)tvp, LK_EXCLUSIVE | LK_RETRY, p);
144 *vpp = (struct vnode *) tvp;
145 tvp->v.v_flag |= VROOT;
148 afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *vpp,
149 ICL_TYPE_INT32, error);
155 afs_vget(mp, lfl, vp)
161 printf("vget called. help!\n");
162 if (vp->v_usecount < 0) {
163 vprint("bad usecount", vp);
166 error = vget(vp, lfl, current_proc());
168 insmntque(vp, afs_globalVFS); /* take off free list */
172 int afs_statfs(struct mount *mp, struct statfs *abp, struct proc *p)
175 AFS_STATCNT(afs_statfs);
178 abp->f_type = MOUNT_AFS;
180 abp->f_bsize = mp->vfs_bsize;
181 abp->f_iosize = mp->vfs_bsize;
183 /* Fake a high number below to satisfy programs that use the statfs call
184 * to make sure that there's enough space in the device partition before
185 * storing something there.
187 abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
188 abp->f_ffree = 2000000;
190 abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
191 abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];
192 if (abp != &mp->mnt_stat) {
193 abp->f_type = mp->mnt_vfc->vfc_typenum;
194 bcopy((caddr_t)mp->mnt_stat.f_mntonname,
195 (caddr_t)&abp->f_mntonname[0], MNAMELEN);
196 bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
197 (caddr_t)&abp->f_mntfromname[0], MNAMELEN);
204 int afs_sync(mp, waitfor, cred, p)
219 extern int vfs_opv_numops; /* The total number of defined vnode operations */
220 extern struct vnodeopv_desc afs_vnodeop_opv_desc;
221 int afs_init(struct vfsconf *vfc) {
223 int (**opv_desc_vector)();
224 struct vnodeopv_entry_desc *opve_descp;
228 MALLOC(afs_vnodeop_p, PFI *, vfs_opv_numops*sizeof(PFI), M_TEMP, M_WAITOK);
230 bzero (afs_vnodeop_p, vfs_opv_numops*sizeof(PFI));
232 opv_desc_vector = afs_vnodeop_p;
233 for (j=0; afs_vnodeop_opv_desc.opv_desc_ops[j].opve_op; j++) {
234 opve_descp = &(afs_vnodeop_opv_desc.opv_desc_ops[j]);
237 * Sanity check: is this operation listed
238 * in the list of operations? We check this
239 * by seeing if its offest is zero. Since
240 * the default routine should always be listed
241 * first, it should be the only one with a zero
242 * offset. Any other operation with a zero
243 * offset is probably not listed in
244 * vfs_op_descs, and so is probably an error.
246 * A panic here means the layer programmer
247 * has committed the all-too common bug
248 * of adding a new operation to the layer's
249 * list of vnode operations but
250 * not adding the operation to the system-wide
251 * list of supported operations.
253 if (opve_descp->opve_op->vdesc_offset == 0 &&
254 opve_descp->opve_op->vdesc_offset != VOFFSET(vop_default)) {
255 printf("afs_init: operation %s not listed in %s.\n",
256 opve_descp->opve_op->vdesc_name,
258 panic ("load_afs: bad operation");
261 * Fill in this entry.
263 opv_desc_vector[opve_descp->opve_op->vdesc_offset] =
264 opve_descp->opve_impl;
268 * Finally, go back and replace unfilled routines
269 * with their default. (Sigh, an O(n^3) algorithm. I
270 * could make it better, but that'd be work, and n is small.)
274 * Force every operations vector to have a default routine.
276 opv_desc_vector = afs_vnodeop_p;
277 if (opv_desc_vector[VOFFSET(vop_default)]==NULL) {
278 panic("afs_init: operation vector without default routine.");
280 for (j = 0;j<vfs_opv_numops; j++)
281 if (opv_desc_vector[j] == NULL)
283 opv_desc_vector[VOFFSET(vop_default)];
286 struct vfsops afs_vfsops = {