Home | History | Annotate | Line # | Download | only in procfs
procfs_subr.c revision 1.28.2.6
      1  1.28.2.6    bouyer /*	$NetBSD: procfs_subr.c,v 1.28.2.6 2001/04/21 17:46:35 bouyer Exp $	*/
      2      1.13       cgd 
      3       1.1        pk /*
      4      1.20   thorpej  * Copyright (c) 1994 Christopher G. Demetriou.  All rights reserved.
      5       1.5       cgd  * Copyright (c) 1993 Jan-Simon Pendry
      6      1.11   mycroft  * Copyright (c) 1993
      7      1.11   mycroft  *	The Regents of the University of California.  All rights reserved.
      8       1.2        pk  *
      9       1.5       cgd  * This code is derived from software contributed to Berkeley by
     10       1.5       cgd  * Jan-Simon Pendry.
     11       1.5       cgd  *
     12       1.2        pk  * Redistribution and use in source and binary forms, with or without
     13       1.2        pk  * modification, are permitted provided that the following conditions
     14       1.2        pk  * are met:
     15       1.2        pk  * 1. Redistributions of source code must retain the above copyright
     16       1.2        pk  *    notice, this list of conditions and the following disclaimer.
     17       1.2        pk  * 2. Redistributions in binary form must reproduce the above copyright
     18       1.2        pk  *    notice, this list of conditions and the following disclaimer in the
     19       1.2        pk  *    documentation and/or other materials provided with the distribution.
     20       1.2        pk  * 3. All advertising materials mentioning features or use of this software
     21       1.2        pk  *    must display the following acknowledgement:
     22       1.5       cgd  *	This product includes software developed by the University of
     23       1.5       cgd  *	California, Berkeley and its contributors.
     24       1.5       cgd  * 4. Neither the name of the University nor the names of its contributors
     25       1.5       cgd  *    may be used to endorse or promote products derived from this software
     26       1.5       cgd  *    without specific prior written permission.
     27       1.5       cgd  *
     28       1.5       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29       1.5       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30       1.5       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31       1.5       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32       1.5       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33       1.5       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34       1.5       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35       1.5       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36       1.5       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37       1.5       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38       1.5       cgd  * SUCH DAMAGE.
     39       1.2        pk  *
     40      1.23      fvdl  *	@(#)procfs_subr.c	8.6 (Berkeley) 5/14/95
     41       1.1        pk  */
     42       1.5       cgd 
     43       1.4   mycroft #include <sys/param.h>
     44       1.4   mycroft #include <sys/systm.h>
     45       1.4   mycroft #include <sys/time.h>
     46       1.4   mycroft #include <sys/kernel.h>
     47       1.4   mycroft #include <sys/proc.h>
     48       1.4   mycroft #include <sys/vnode.h>
     49      1.11   mycroft #include <sys/malloc.h>
     50      1.18   mycroft #include <sys/stat.h>
     51      1.18   mycroft 
     52       1.5       cgd #include <miscfs/procfs/procfs.h>
     53       1.1        pk 
     54  1.28.2.1    bouyer void procfs_hashins __P((struct pfsnode *));
     55  1.28.2.1    bouyer void procfs_hashrem __P((struct pfsnode *));
     56  1.28.2.1    bouyer struct vnode *procfs_hashget __P((pid_t, pfstype, struct mount *));
     57  1.28.2.1    bouyer 
     58  1.28.2.1    bouyer LIST_HEAD(pfs_hashhead, pfsnode) *pfs_hashtbl;
     59  1.28.2.1    bouyer u_long	pfs_ihash;	/* size of hash table - 1 */
     60  1.28.2.1    bouyer #define PFSPIDHASH(pid)	(&pfs_hashtbl[(pid) & pfs_ihash])
     61  1.28.2.1    bouyer 
     62  1.28.2.1    bouyer struct lock pfs_hashlock;
     63  1.28.2.1    bouyer struct simplelock pfs_hash_slock;
     64       1.1        pk 
     65      1.20   thorpej #define	ISSET(t, f)	((t) & (f))
     66      1.20   thorpej 
     67       1.1        pk /*
     68       1.5       cgd  * allocate a pfsnode/vnode pair.  the vnode is
     69      1.27  wrstuden  * referenced, and locked.
     70       1.5       cgd  *
     71       1.5       cgd  * the pid, pfs_type, and mount point uniquely
     72       1.5       cgd  * identify a pfsnode.  the mount point is needed
     73       1.5       cgd  * because someone might mount this filesystem
     74       1.5       cgd  * twice.
     75       1.5       cgd  *
     76       1.5       cgd  * all pfsnodes are maintained on a singly-linked
     77       1.5       cgd  * list.  new nodes are only allocated when they cannot
     78       1.5       cgd  * be found on this list.  entries on the list are
     79       1.5       cgd  * removed when the vfs reclaim entry is called.
     80       1.5       cgd  *
     81       1.5       cgd  * a single lock is kept for the entire list.  this is
     82       1.5       cgd  * needed because the getnewvnode() function can block
     83       1.5       cgd  * waiting for a vnode to become free, in which case there
     84       1.5       cgd  * may be more than one process trying to get the same
     85       1.5       cgd  * vnode.  this lock is only taken if we are going to
     86       1.5       cgd  * call getnewvnode, since the kernel itself is single-threaded.
     87       1.5       cgd  *
     88       1.5       cgd  * if an entry is found on the list, then call vget() to
     89       1.5       cgd  * take a reference.  this is done because there may be
     90       1.5       cgd  * zero references to it and so it needs to removed from
     91       1.5       cgd  * the vnode free list.
     92       1.1        pk  */
     93      1.11   mycroft int
     94       1.5       cgd procfs_allocvp(mp, vpp, pid, pfs_type)
     95       1.5       cgd 	struct mount *mp;
     96       1.5       cgd 	struct vnode **vpp;
     97       1.5       cgd 	long pid;
     98       1.5       cgd 	pfstype pfs_type;
     99       1.1        pk {
    100      1.12   mycroft 	struct pfsnode *pfs;
    101      1.12   mycroft 	struct vnode *vp;
    102       1.5       cgd 	int error;
    103       1.5       cgd 
    104  1.28.2.1    bouyer 	do {
    105  1.28.2.1    bouyer 		if ((*vpp = procfs_hashget(pid, pfs_type, mp)) != NULL)
    106       1.5       cgd 			return (0);
    107  1.28.2.1    bouyer 	} while (lockmgr(&pfs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
    108       1.1        pk 
    109  1.28.2.1    bouyer 	if ((error = getnewvnode(VT_PROCFS, mp, procfs_vnodeop_p, vpp)) != 0) {
    110  1.28.2.1    bouyer 		*vpp = NULL;
    111  1.28.2.3    bouyer 		lockmgr(&pfs_hashlock, LK_RELEASE, NULL);
    112  1.28.2.1    bouyer 		return (error);
    113       1.5       cgd 	}
    114      1.11   mycroft 	vp = *vpp;
    115       1.5       cgd 
    116      1.11   mycroft 	MALLOC(pfs, void *, sizeof(struct pfsnode), M_TEMP, M_WAITOK);
    117      1.11   mycroft 	vp->v_data = pfs;
    118       1.5       cgd 
    119       1.5       cgd 	pfs->pfs_pid = (pid_t) pid;
    120       1.5       cgd 	pfs->pfs_type = pfs_type;
    121      1.11   mycroft 	pfs->pfs_vnode = vp;
    122       1.5       cgd 	pfs->pfs_flags = 0;
    123       1.5       cgd 	pfs->pfs_fileno = PROCFS_FILENO(pid, pfs_type);
    124       1.5       cgd 
    125       1.5       cgd 	switch (pfs_type) {
    126      1.11   mycroft 	case Proot:	/* /proc = dr-xr-xr-x */
    127      1.17   mycroft 		pfs->pfs_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
    128      1.11   mycroft 		vp->v_type = VDIR;
    129      1.11   mycroft 		vp->v_flag = VROOT;
    130      1.11   mycroft 		break;
    131      1.11   mycroft 
    132      1.22   mycroft 	case Pcurproc:	/* /proc/curproc = lr-xr-xr-x */
    133      1.28   thorpej 	case Pself:	/* /proc/self    = lr-xr-xr-x */
    134      1.22   mycroft 		pfs->pfs_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
    135      1.11   mycroft 		vp->v_type = VLNK;
    136       1.5       cgd 		break;
    137       1.5       cgd 
    138      1.17   mycroft 	case Pproc:	/* /proc/N = dr-xr-xr-x */
    139      1.17   mycroft 		pfs->pfs_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
    140       1.6        ws 		vp->v_type = VDIR;
    141       1.5       cgd 		break;
    142       1.5       cgd 
    143      1.17   mycroft 	case Pfile:	/* /proc/N/file = -rw------- */
    144      1.17   mycroft 	case Pmem:	/* /proc/N/mem = -rw------- */
    145      1.17   mycroft 	case Pregs:	/* /proc/N/regs = -rw------- */
    146      1.17   mycroft 	case Pfpregs:	/* /proc/N/fpregs = -rw------- */
    147      1.17   mycroft 		pfs->pfs_mode = S_IRUSR|S_IWUSR;
    148       1.9       cgd 		vp->v_type = VREG;
    149       1.9       cgd 		break;
    150       1.9       cgd 
    151      1.17   mycroft 	case Pctl:	/* /proc/N/ctl = --w------ */
    152      1.17   mycroft 	case Pnote:	/* /proc/N/note = --w------ */
    153      1.17   mycroft 	case Pnotepg:	/* /proc/N/notepg = --w------ */
    154      1.17   mycroft 		pfs->pfs_mode = S_IWUSR;
    155       1.6        ws 		vp->v_type = VREG;
    156       1.5       cgd 		break;
    157       1.5       cgd 
    158      1.25   msaitoh 	case Pmap:	/* /proc/N/map = -r--r--r-- */
    159  1.28.2.6    bouyer 	case Pmaps:	/* /proc/N/maps = -r--r--r-- */
    160      1.17   mycroft 	case Pstatus:	/* /proc/N/status = -r--r--r-- */
    161      1.26  christos 	case Pcmdline:	/* /proc/N/cmdline = -r--r--r-- */
    162  1.28.2.4    bouyer 	case Pmeminfo:	/* /proc/meminfo = -r--r--r-- */
    163  1.28.2.4    bouyer 	case Pcpuinfo:	/* /proc/cpuinfo = -r--r--r-- */
    164      1.17   mycroft 		pfs->pfs_mode = S_IRUSR|S_IRGRP|S_IROTH;
    165       1.6        ws 		vp->v_type = VREG;
    166       1.5       cgd 		break;
    167       1.5       cgd 
    168       1.5       cgd 	default:
    169      1.11   mycroft 		panic("procfs_allocvp");
    170       1.5       cgd 	}
    171      1.27  wrstuden 
    172  1.28.2.1    bouyer 	procfs_hashins(pfs);
    173  1.28.2.3    bouyer 	uvm_vnp_setsize(vp, 0);
    174  1.28.2.3    bouyer 	lockmgr(&pfs_hashlock, LK_RELEASE, NULL);
    175       1.1        pk 
    176       1.5       cgd 	return (error);
    177       1.1        pk }
    178       1.1        pk 
    179      1.11   mycroft int
    180       1.5       cgd procfs_freevp(vp)
    181       1.5       cgd 	struct vnode *vp;
    182       1.1        pk {
    183       1.5       cgd 	struct pfsnode *pfs = VTOPFS(vp);
    184       1.5       cgd 
    185  1.28.2.1    bouyer 	procfs_hashrem(pfs);
    186       1.1        pk 
    187      1.11   mycroft 	FREE(vp->v_data, M_TEMP);
    188      1.11   mycroft 	vp->v_data = 0;
    189       1.5       cgd 	return (0);
    190       1.1        pk }
    191       1.1        pk 
    192      1.11   mycroft int
    193      1.15  christos procfs_rw(v)
    194      1.15  christos 	void *v;
    195       1.1        pk {
    196      1.15  christos 	struct vop_read_args *ap = v;
    197      1.11   mycroft 	struct vnode *vp = ap->a_vp;
    198      1.11   mycroft 	struct uio *uio = ap->a_uio;
    199       1.5       cgd 	struct proc *curp = uio->uio_procp;
    200       1.5       cgd 	struct pfsnode *pfs = VTOPFS(vp);
    201       1.5       cgd 	struct proc *p;
    202       1.5       cgd 
    203       1.5       cgd 	p = PFIND(pfs->pfs_pid);
    204       1.5       cgd 	if (p == 0)
    205       1.1        pk 		return (EINVAL);
    206      1.19   mycroft 
    207      1.19   mycroft 	switch (pfs->pfs_type) {
    208      1.19   mycroft 	case Pregs:
    209      1.19   mycroft 	case Pfpregs:
    210      1.19   mycroft 	case Pmem:
    211      1.19   mycroft 		/*
    212      1.19   mycroft 		 * Do not allow init to be modified while in secure mode; it
    213      1.19   mycroft 		 * could be duped into changing the security level.
    214      1.19   mycroft 		 */
    215      1.19   mycroft 		if (uio->uio_rw == UIO_WRITE &&
    216      1.19   mycroft 		    p == initproc && securelevel > -1)
    217      1.19   mycroft 			return (EPERM);
    218      1.19   mycroft 		break;
    219      1.19   mycroft 
    220      1.19   mycroft 	default:
    221      1.19   mycroft 		break;
    222      1.19   mycroft 	}
    223       1.1        pk 
    224       1.5       cgd 	switch (pfs->pfs_type) {
    225       1.5       cgd 	case Pnote:
    226       1.5       cgd 	case Pnotepg:
    227      1.11   mycroft 		return (procfs_donote(curp, p, pfs, uio));
    228       1.5       cgd 
    229       1.5       cgd 	case Pregs:
    230      1.11   mycroft 		return (procfs_doregs(curp, p, pfs, uio));
    231       1.9       cgd 
    232       1.9       cgd 	case Pfpregs:
    233      1.11   mycroft 		return (procfs_dofpregs(curp, p, pfs, uio));
    234       1.5       cgd 
    235       1.5       cgd 	case Pctl:
    236      1.11   mycroft 		return (procfs_doctl(curp, p, pfs, uio));
    237       1.5       cgd 
    238       1.5       cgd 	case Pstatus:
    239      1.11   mycroft 		return (procfs_dostatus(curp, p, pfs, uio));
    240      1.25   msaitoh 
    241      1.25   msaitoh 	case Pmap:
    242  1.28.2.6    bouyer 		return (procfs_domap(curp, p, pfs, uio, 0));
    243  1.28.2.6    bouyer 
    244  1.28.2.6    bouyer 	case Pmaps:
    245  1.28.2.6    bouyer 		return (procfs_domap(curp, p, pfs, uio, 1));
    246       1.1        pk 
    247       1.5       cgd 	case Pmem:
    248      1.11   mycroft 		return (procfs_domem(curp, p, pfs, uio));
    249      1.26  christos 
    250      1.26  christos 	case Pcmdline:
    251      1.26  christos 		return (procfs_docmdline(curp, p, pfs, uio));
    252  1.28.2.4    bouyer 
    253  1.28.2.4    bouyer 	case Pmeminfo:
    254  1.28.2.4    bouyer 		return (procfs_domeminfo(curp, p, pfs, uio));
    255  1.28.2.4    bouyer 	case Pcpuinfo:
    256  1.28.2.4    bouyer 		return (procfs_docpuinfo(curp, p, pfs, uio));
    257       1.1        pk 
    258       1.5       cgd 	default:
    259       1.5       cgd 		return (EOPNOTSUPP);
    260       1.5       cgd 	}
    261       1.1        pk }
    262       1.1        pk 
    263       1.5       cgd /*
    264       1.5       cgd  * Get a string from userland into (buf).  Strip a trailing
    265       1.5       cgd  * nl character (to allow easy access from the shell).
    266      1.11   mycroft  * The buffer should be *buflenp + 1 chars long.  vfs_getuserstr
    267       1.5       cgd  * will automatically add a nul char at the end.
    268       1.5       cgd  *
    269       1.5       cgd  * Returns 0 on success or the following errors
    270       1.5       cgd  *
    271       1.5       cgd  * EINVAL:    file offset is non-zero.
    272       1.5       cgd  * EMSGSIZE:  message is longer than kernel buffer
    273       1.5       cgd  * EFAULT:    user i/o buffer is not addressable
    274       1.5       cgd  */
    275      1.11   mycroft int
    276      1.11   mycroft vfs_getuserstr(uio, buf, buflenp)
    277       1.5       cgd 	struct uio *uio;
    278       1.5       cgd 	char *buf;
    279       1.5       cgd 	int *buflenp;
    280       1.1        pk {
    281       1.5       cgd 	int xlen;
    282       1.5       cgd 	int error;
    283       1.5       cgd 
    284      1.11   mycroft 	if (uio->uio_offset != 0)
    285      1.11   mycroft 		return (EINVAL);
    286      1.11   mycroft 
    287       1.5       cgd 	xlen = *buflenp;
    288       1.1        pk 
    289       1.5       cgd 	/* must be able to read the whole string in one go */
    290       1.5       cgd 	if (xlen < uio->uio_resid)
    291       1.5       cgd 		return (EMSGSIZE);
    292       1.5       cgd 	xlen = uio->uio_resid;
    293       1.5       cgd 
    294      1.14  christos 	if ((error = uiomove(buf, xlen, uio)) != 0)
    295       1.5       cgd 		return (error);
    296       1.5       cgd 
    297      1.11   mycroft 	/* allow multiple writes without seeks */
    298      1.11   mycroft 	uio->uio_offset = 0;
    299      1.11   mycroft 
    300       1.5       cgd 	/* cleanup string and remove trailing newline */
    301       1.5       cgd 	buf[xlen] = '\0';
    302       1.5       cgd 	xlen = strlen(buf);
    303       1.5       cgd 	if (xlen > 0 && buf[xlen-1] == '\n')
    304       1.5       cgd 		buf[--xlen] = '\0';
    305       1.5       cgd 	*buflenp = xlen;
    306       1.1        pk 
    307       1.5       cgd 	return (0);
    308       1.1        pk }
    309       1.1        pk 
    310  1.28.2.5    bouyer const vfs_namemap_t *
    311      1.11   mycroft vfs_findname(nm, buf, buflen)
    312  1.28.2.5    bouyer 	const vfs_namemap_t *nm;
    313  1.28.2.5    bouyer 	const char *buf;
    314       1.5       cgd 	int buflen;
    315       1.1        pk {
    316      1.11   mycroft 
    317       1.5       cgd 	for (; nm->nm_name; nm++)
    318      1.24     perry 		if (memcmp(buf, nm->nm_name, buflen+1) == 0)
    319       1.5       cgd 			return (nm);
    320       1.5       cgd 
    321       1.5       cgd 	return (0);
    322  1.28.2.1    bouyer }
    323  1.28.2.1    bouyer 
    324  1.28.2.1    bouyer /*
    325  1.28.2.1    bouyer  * Initialize pfsnode hash table.
    326  1.28.2.1    bouyer  */
    327  1.28.2.1    bouyer void
    328  1.28.2.1    bouyer procfs_hashinit()
    329  1.28.2.1    bouyer {
    330  1.28.2.1    bouyer 	lockinit(&pfs_hashlock, PINOD, "pfs_hashlock", 0, 0);
    331  1.28.2.2    bouyer 	pfs_hashtbl = hashinit(desiredvnodes / 4, HASH_LIST, M_UFSMNT,
    332  1.28.2.2    bouyer 	    M_WAITOK, &pfs_ihash);
    333  1.28.2.1    bouyer 	simple_lock_init(&pfs_hash_slock);
    334  1.28.2.1    bouyer }
    335  1.28.2.1    bouyer 
    336  1.28.2.1    bouyer /*
    337  1.28.2.1    bouyer  * Free pfsnode hash table.
    338  1.28.2.1    bouyer  */
    339  1.28.2.1    bouyer void
    340  1.28.2.1    bouyer procfs_hashdone()
    341  1.28.2.1    bouyer {
    342  1.28.2.1    bouyer 	hashdone(pfs_hashtbl, M_UFSMNT);
    343  1.28.2.1    bouyer }
    344  1.28.2.1    bouyer 
    345  1.28.2.1    bouyer struct vnode *
    346  1.28.2.1    bouyer procfs_hashget(pid, type, mp)
    347  1.28.2.1    bouyer 	pid_t pid;
    348  1.28.2.1    bouyer 	pfstype type;
    349  1.28.2.1    bouyer 	struct mount *mp;
    350  1.28.2.1    bouyer {
    351  1.28.2.1    bouyer 	struct pfsnode *pp;
    352  1.28.2.1    bouyer 	struct vnode *vp;
    353  1.28.2.1    bouyer 
    354  1.28.2.1    bouyer loop:
    355  1.28.2.1    bouyer 	simple_lock(&pfs_hash_slock);
    356  1.28.2.1    bouyer 	for (pp = PFSPIDHASH(pid)->lh_first; pp; pp = pp->pfs_hash.le_next) {
    357  1.28.2.1    bouyer 		vp = PFSTOV(pp);
    358  1.28.2.1    bouyer 		if (pid == pp->pfs_pid && pp->pfs_type == type &&
    359  1.28.2.1    bouyer 		    vp->v_mount == mp) {
    360  1.28.2.1    bouyer 			simple_lock(&vp->v_interlock);
    361  1.28.2.1    bouyer 			simple_unlock(&pfs_hash_slock);
    362  1.28.2.1    bouyer 			if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK))
    363  1.28.2.1    bouyer 				goto loop;
    364  1.28.2.1    bouyer 			return (vp);
    365  1.28.2.1    bouyer 		}
    366  1.28.2.1    bouyer 	}
    367  1.28.2.1    bouyer 	simple_unlock(&pfs_hash_slock);
    368  1.28.2.1    bouyer 	return (NULL);
    369  1.28.2.1    bouyer }
    370  1.28.2.1    bouyer 
    371  1.28.2.1    bouyer /*
    372  1.28.2.1    bouyer  * Insert the pfsnode into the hash table and lock it.
    373  1.28.2.1    bouyer  */
    374  1.28.2.1    bouyer void
    375  1.28.2.1    bouyer procfs_hashins(pp)
    376  1.28.2.1    bouyer 	struct pfsnode *pp;
    377  1.28.2.1    bouyer {
    378  1.28.2.1    bouyer 	struct pfs_hashhead *ppp;
    379  1.28.2.1    bouyer 
    380  1.28.2.1    bouyer 	/* lock the pfsnode, then put it on the appropriate hash list */
    381  1.28.2.1    bouyer 	lockmgr(&pp->pfs_vnode->v_lock, LK_EXCLUSIVE, (struct simplelock *)0);
    382  1.28.2.1    bouyer 
    383  1.28.2.1    bouyer 	simple_lock(&pfs_hash_slock);
    384  1.28.2.1    bouyer 	ppp = PFSPIDHASH(pp->pfs_pid);
    385  1.28.2.1    bouyer 	LIST_INSERT_HEAD(ppp, pp, pfs_hash);
    386  1.28.2.1    bouyer 	simple_unlock(&pfs_hash_slock);
    387  1.28.2.1    bouyer }
    388  1.28.2.1    bouyer 
    389  1.28.2.1    bouyer /*
    390  1.28.2.1    bouyer  * Remove the pfsnode from the hash table.
    391  1.28.2.1    bouyer  */
    392  1.28.2.1    bouyer void
    393  1.28.2.1    bouyer procfs_hashrem(pp)
    394  1.28.2.1    bouyer 	struct pfsnode *pp;
    395  1.28.2.1    bouyer {
    396  1.28.2.1    bouyer 	simple_lock(&pfs_hash_slock);
    397  1.28.2.1    bouyer 	LIST_REMOVE(pp, pfs_hash);
    398  1.28.2.1    bouyer 	simple_unlock(&pfs_hash_slock);
    399  1.28.2.1    bouyer }
    400  1.28.2.1    bouyer 
    401  1.28.2.1    bouyer void
    402  1.28.2.1    bouyer procfs_revoke_vnodes(p, arg)
    403  1.28.2.1    bouyer 	struct proc *p;
    404  1.28.2.1    bouyer 	void *arg;
    405  1.28.2.1    bouyer {
    406  1.28.2.1    bouyer 	struct pfsnode *pfs, *pnext;
    407  1.28.2.1    bouyer 	struct vnode *vp;
    408  1.28.2.1    bouyer 	struct mount *mp = (struct mount *)arg;
    409  1.28.2.1    bouyer 
    410  1.28.2.1    bouyer 	if (!(p->p_flag & P_SUGID))
    411  1.28.2.1    bouyer 		return;
    412  1.28.2.1    bouyer 
    413  1.28.2.1    bouyer 	for (pfs = PFSPIDHASH(p->p_pid)->lh_first; pfs; pfs = pnext) {
    414  1.28.2.1    bouyer 		vp = PFSTOV(pfs);
    415  1.28.2.1    bouyer 		pnext = pfs->pfs_hash.le_next;
    416  1.28.2.1    bouyer 		if (vp->v_usecount > 0 && pfs->pfs_pid == p->p_pid &&
    417  1.28.2.1    bouyer 		    vp->v_mount == mp)
    418  1.28.2.1    bouyer 			VOP_REVOKE(vp, REVOKEALL);
    419  1.28.2.1    bouyer 	}
    420       1.1        pk }
    421