diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2001-06-22 14:14:12 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2001-06-22 14:14:12 +0000 |
commit | 0feae2b086084ce16940249793f7b5ecabe85c52 (patch) | |
tree | 98fa9664da9fd8be22e369584c568625bc15f799 /sys/kern/vfs_subr.c | |
parent | a49f87d13c19deac6e87761b349d96038b3acdfc (diff) |
KNF
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r-- | sys/kern/vfs_subr.c | 122 |
1 files changed, 58 insertions, 64 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index e80f0e6d0d6..7d22512d8cf 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.61 2001/06/05 21:47:07 provos Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.62 2001/06/22 14:14:10 deraadt Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -94,7 +94,7 @@ int suid_clear = 1; /* 1 => clear SUID / SGID on owner change */ #define bufremvn(bp) { \ LIST_REMOVE(bp, b_vnbufs); \ (bp)->b_vnbufs.le_next = NOLIST; \ -} +} struct freelst vnode_hold_list; /* list of vnodes referencing buffers */ struct freelst vnode_free_list; /* vnode free list */ @@ -186,7 +186,7 @@ vfs_busy(mp, flags, interlkp, p) lkflags |= LK_INTERLOCK; if (lockmgr(&mp->mnt_lock, lkflags, interlkp, p)) panic("vfs_busy: unexpected lock failure"); - return (0); + return (0); } @@ -217,7 +217,7 @@ vfs_rootmountalloc(fstypename, devname, mpp) struct proc *p = curproc; /* XXX */ struct vfsconf *vfsp; struct mount *mp; - + for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) if (!strcmp(vfsp->vfc_name, fstypename)) break; @@ -253,7 +253,7 @@ vfs_mountroot() struct vfsconf *vfsp; extern int (*mountroot)(void); int error; - + if (mountroot != NULL) return ((*mountroot)()); for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) { @@ -265,7 +265,7 @@ vfs_mountroot() } return (ENODEV); } - + /* * Lookup a mount point by filesystem identifier. */ @@ -403,7 +403,7 @@ getnewvnode(tag, mp, vops, vpp) s = splbio(); if ((numvnodes < desiredvnodes) || ((TAILQ_FIRST(listhd = &vnode_free_list) == NULL) && - ((TAILQ_FIRST(listhd = &vnode_hold_list) == NULL) || toggle))) { + ((TAILQ_FIRST(listhd = &vnode_hold_list) == NULL) || toggle))) { splx(s); simple_unlock(&vnode_free_list_slock); vp = pool_get(&vnode_pool, PR_WAITOK); @@ -411,7 +411,7 @@ getnewvnode(tag, mp, vops, vpp) numvnodes++; } else { for (vp = TAILQ_FIRST(listhd); vp != NULLVP; - vp = TAILQ_NEXT(vp, v_freelist)) { + vp = TAILQ_NEXT(vp, v_freelist)) { if (simple_lock_try(&vp->v_interlock)) break; } @@ -481,7 +481,7 @@ insmntque(vp, mp) /* * Delete from old mount point vnode list, if on one. */ - + if (vp->v_mount != NULL) LIST_REMOVE(vp, v_mntvnodes); /* @@ -599,8 +599,7 @@ loop: break; } - - /* + /* * Common case is actually in the if statement */ if (vp == NULL || !(vp->v_tag == VT_NON && vp->v_type == VBLK)) { @@ -621,14 +620,14 @@ loop: return (NULLVP); } - /* + /* * This code is the uncommon case. It is called in case * we found an alias that was VT_NON && vtype of VBLK * This means we found a block device that was created * using bdevvp. * An example of such a vnode is the root partition device vnode * craeted in ffs_mountroot. - * + * * The vnodes created by bdevvp should not be aliased (why?). */ @@ -653,7 +652,7 @@ loop: */ int vget(vp, flags, p) - struct vnode *vp; + struct vnode *vp; int flags; struct proc *p; { @@ -721,17 +720,16 @@ vref(vp) static __inline__ void vputonfreelist(vp) - struct vnode *vp; - + struct vnode *vp; { - int s; + int s; struct freelst *lst; s = splbio(); #ifdef DIAGNOSTIC if (vp->v_usecount != 0) panic("Use count is not zero!"); - + if (vp->v_bioflag & VBIOONFREELIST) { vprint("vnode already on free list: ", vp); panic("vnode already on free list"); @@ -740,11 +738,11 @@ vputonfreelist(vp) vp->v_bioflag |= VBIOONFREELIST; - if (vp->v_holdcnt > 0) + if (vp->v_holdcnt > 0) lst = &vnode_hold_list; else lst = &vnode_free_list; - + if (vp->v_type == VBAD) TAILQ_INSERT_HEAD(lst, vp, v_freelist); else @@ -769,7 +767,7 @@ vput(vp) simple_lock(&vp->v_interlock); #ifdef DIAGNOSTIC - if (vp->v_usecount == 0) { + if (vp->v_usecount == 0) { vprint("vrele: bad ref count", vp); panic("vrele: ref cnt"); } @@ -786,7 +784,7 @@ vput(vp) vprint("vrele: bad writecount", vp); panic("vrele: v_writecount != 0"); } -#endif +#endif vputonfreelist(vp); simple_unlock(&vp->v_interlock); @@ -810,7 +808,7 @@ vrele(vp) #endif simple_lock(&vp->v_interlock); #ifdef DIAGNOSTIC - if (vp->v_usecount == 0) { + if (vp->v_usecount == 0) { vprint("vrele: bad ref count", vp); panic("vrele: ref cnt"); } @@ -893,7 +891,7 @@ loop: */ if (vp == skipvp) continue; - + simple_lock(&vp->v_interlock); /* * Skip over a vnodes marked VSYSTEM. @@ -1129,7 +1127,7 @@ vgonel(vp, p) if (vp->v_mount != NULL) insmntque(vp, (struct mount *)0); /* - * If special device, remove it from special device alias list + * If special device, remove it from special device alias list * if it is on one. */ if ((vp->v_type == VBLK || vp->v_type == VCHR) && vp->v_specinfo != 0) { @@ -1168,7 +1166,7 @@ vgonel(vp, p) } /* * If it is on the freelist and not already at the head, - * move it to the head of the list. + * move it to the head of the list. */ vp->v_type = VBAD; @@ -1179,7 +1177,8 @@ vgonel(vp, p) if (vp->v_usecount == 0 && (vp->v_bioflag & VBIOONFREELIST)) { int s; - simple_lock(&vnode_free_list_slock); + + simple_lock(&vnode_free_list_slock); s = splbio(); if (vp->v_holdcnt > 0) @@ -1190,7 +1189,7 @@ vgonel(vp, p) TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist); } splx(s); - simple_unlock(&vnode_free_list_slock); + simple_unlock(&vnode_free_list_slock); } } @@ -1325,14 +1324,13 @@ printlockedvnodes() printf("Locked vnodes\n"); simple_lock(&mountlist_slock); for (mp = CIRCLEQ_FIRST(&mountlist); mp != CIRCLEQ_END(&mountlist); - mp = nmp) { - if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { + mp = nmp) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { nmp = CIRCLEQ_NEXT(mp, mnt_list); continue; } - for (vp = mp->mnt_vnodelist.lh_first; - vp != NULL; - vp = vp->v_mntvnodes.le_next) { + for (vp = mp->mnt_vnodelist.lh_first; vp; + vp = vp->v_mntvnodes.le_next) { if (VOP_ISLOCKED(vp)) vprint((char *)0, vp); } @@ -1417,19 +1415,18 @@ sysctl_vnode(where, sizep, p) return (0); } ewhere = where + *sizep; - + simple_lock(&mountlist_slock); for (mp = CIRCLEQ_FIRST(&mountlist); mp != CIRCLEQ_END(&mountlist); - mp = nmp) { + mp = nmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { nmp = CIRCLEQ_NEXT(mp, mnt_list); continue; } savebp = bp; again: - for (vp = mp->mnt_vnodelist.lh_first; - vp != NULL; - vp = nvp) { + for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; + vp = nvp) { /* * Check that the vp is still associated with * this filesystem. RACE: could have been @@ -1644,7 +1641,7 @@ vfs_export_lookup(mp, nep, nam) if (rnh != NULL) { np = (struct netcred *) (*rnh->rnh_matchaddr)((caddr_t)saddr, - rnh); + rnh); if (np && np->netc_rnodes->rn_flags & RNF_ROOT) np = NULL; } @@ -1672,13 +1669,13 @@ vaccess(file_mode, uid, gid, acc_mode, cred) struct ucred *cred; { mode_t mask; - + /* User id 0 always gets access. */ if (cred->cr_uid == 0) return 0; - + mask = 0; - + /* Otherwise, check the owner. */ if (cred->cr_uid == uid) { if (acc_mode & VEXEC) @@ -1689,7 +1686,7 @@ vaccess(file_mode, uid, gid, acc_mode, cred) mask |= S_IWUSR; return (file_mode & mask) == mask ? 0 : EACCES; } - + /* Otherwise, check the groups. */ if (cred->cr_gid == gid || groupmember(gid, cred)) { if (acc_mode & VEXEC) @@ -1700,7 +1697,7 @@ vaccess(file_mode, uid, gid, acc_mode, cred) mask |= S_IWGRP; return (file_mode & mask) == mask ? 0 : EACCES; } - + /* Otherwise, check everyone else. */ if (acc_mode & VEXEC) mask |= S_IXOTH; @@ -1725,7 +1722,7 @@ vfs_unmountall() retry: allerror = 0; for (mp = CIRCLEQ_LAST(&mountlist); mp != CIRCLEQ_END(&mountlist); - mp = nmp) { + mp = nmp) { nmp = CIRCLEQ_PREV(mp, mnt_list); if ((error = dounmount(mp, MNT_FORCE, curproc)) != 0) { printf("unmount of %s failed with error %d\n", @@ -1792,7 +1789,7 @@ vfs_syncwait(verbose) p = curproc? curproc : &proc0; sys_sync(p, (void *)0, (register_t *)0); - + /* Wait for sync to finish. */ dcount = 10000; for (iter = 0; iter < 20; iter++) { @@ -1824,7 +1821,7 @@ vfs_syncwait(verbose) if (verbose) printf("%d ", nbusy); DELAY(40000 * iter); - } + } return nbusy; } @@ -1883,8 +1880,8 @@ fs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) } -/* - * Routines dealing with vnodes and buffers +/* + * Routines dealing with vnodes and buffers */ /* @@ -1964,7 +1961,7 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo) loop: s = splbio(); for (;;) { - if ((blist = vp->v_cleanblkhd.lh_first) && + if ((blist = vp->v_cleanblkhd.lh_first) && (flags & V_SAVEMETA)) while (blist && blist->b_lblkno < 0) blist = blist->b_vnbufs.le_next; @@ -2080,7 +2077,7 @@ bgetvp(vp, bp) /* * Disassociate a buffer from a vnode. - * + * * Manipulates vnode buffer queues. Must be called at splbio(). */ void @@ -2112,7 +2109,7 @@ brelvp(bp) /* * If it is on the holdlist and the hold count drops to - * zero, move it to the free list. + * zero, move it to the free list. */ if ((vp->v_bioflag & VBIOONFREELIST) && vp->v_holdcnt == 0 && vp->v_usecount == 0) { @@ -2142,7 +2139,7 @@ buf_replacevnode(bp, newvp) if (oldvp) brelvp(bp); - + if ((bp->b_flags & (B_READ | B_DONE)) == 0) { newvp->v_numoutput++; /* put it on swapdev */ vwakeup(oldvp); @@ -2223,9 +2220,8 @@ vfs_register(vfs) #endif /* Check if filesystem already known */ - for (vfspp = &vfsconf, vfsp = vfsconf; - vfsp; - vfspp = &vfsp->vfc_next, vfsp = vfsp->vfc_next) + for (vfspp = &vfsconf, vfsp = vfsconf; vfsp; + vfspp = &vfsp->vfc_next, vfsp = vfsp->vfc_next) if (strcmp(vfsp->vfc_name, vfs->vfc_name) == 0) return (EEXIST); @@ -2243,7 +2239,7 @@ vfs_register(vfs) return 0; } - + int vfs_unregister(vfs) struct vfsconf *vfs; @@ -2253,20 +2249,19 @@ vfs_unregister(vfs) int maxtypenum; /* Find our vfsconf struct */ - for (vfspp = &vfsconf, vfsp = vfsconf; - vfsp; - vfspp = &vfsp->vfc_next, vfsp = vfsp->vfc_next) { + for (vfspp = &vfsconf, vfsp = vfsconf; vfsp; + vfspp = &vfsp->vfc_next, vfsp = vfsp->vfc_next) { if (strcmp(vfsp->vfc_name, vfs->vfc_name) == 0) break; } - if (!vfsp) /* Not found */ + if (!vfsp) /* Not found */ return (ENOENT); - if (vfsp->vfc_refcount) /* In use */ + if (vfsp->vfc_refcount) /* In use */ return (EBUSY); - /* Remove from list and free */ + /* Remove from list and free */ *vfspp = vfsp->vfc_next; maxtypenum = 0; @@ -2276,7 +2271,6 @@ vfs_unregister(vfs) maxtypenum = vfsp->vfc_typenum; maxvfsconf = maxtypenum; - return 0; } |