summaryrefslogtreecommitdiffstats
path: root/sys/fs/procfs
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-03-28 11:52:56 +0000
committerjhb <jhb@FreeBSD.org>2001-03-28 11:52:56 +0000
commit79cf991a6bd845fad54bd6a15892cb5aaf74b223 (patch)
tree1cee6a483c3c79f058207ee2c66c63c38f2ad20a /sys/fs/procfs
parent673f3af133009642ca79479ec4db4a25a4ea86d6 (diff)
downloadFreeBSD-src-79cf991a6bd845fad54bd6a15892cb5aaf74b223.zip
FreeBSD-src-79cf991a6bd845fad54bd6a15892cb5aaf74b223.tar.gz
Convert the allproc and proctree locks from lockmgr locks to sx locks.
Diffstat (limited to 'sys/fs/procfs')
-rw-r--r--sys/fs/procfs/procfs_ctl.c22
-rw-r--r--sys/fs/procfs/procfs_vnops.c5
2 files changed, 14 insertions, 13 deletions
diff --git a/sys/fs/procfs/procfs_ctl.c b/sys/fs/procfs/procfs_ctl.c
index 0130795..6a20cc6 100644
--- a/sys/fs/procfs/procfs_ctl.c
+++ b/sys/fs/procfs/procfs_ctl.c
@@ -46,6 +46,7 @@
#include <sys/vnode.h>
#include <sys/ptrace.h>
#include <sys/signalvar.h>
+#include <sys/sx.h>
#include <miscfs/procfs/procfs.h>
#include <vm/vm.h>
@@ -108,7 +109,7 @@ procfs_control(curp, p, op)
struct proc *p;
int op;
{
- int error;
+ int error = 0;
/*
* Authorization check: rely on normal debugging protection, except
@@ -125,20 +126,18 @@ procfs_control(curp, p, op)
* by the calling process.
*/
if (op == PROCFS_CTL_ATTACH) {
- PROCTREE_LOCK(PT_EXCLUSIVE);
+ sx_xlock(&proctree_lock);
PROC_LOCK(p);
/* check whether already being traced */
if (p->p_flag & P_TRACED) {
- PROC_UNLOCK(p);
- PROCTREE_LOCK(PT_RELEASE);
- return (EBUSY);
+ error = EBUSY;
+ goto out;
}
/* can't trace yourself! */
if (p->p_pid == curp->p_pid) {
- PROC_UNLOCK(p);
- PROCTREE_LOCK(PT_RELEASE);
- return (EINVAL);
+ error = EINVAL;
+ goto out;
}
/*
@@ -157,8 +156,9 @@ procfs_control(curp, p, op)
proc_reparent(p, curp);
}
psignal(p, SIGSTOP);
+ out:
PROC_UNLOCK(p);
- PROCTREE_LOCK(PT_RELEASE);
+ sx_xunlock(&proctree_lock);
return (0);
}
@@ -221,7 +221,7 @@ procfs_control(curp, p, op)
PROC_UNLOCK(p);
/* give process back to original parent */
- PROCTREE_LOCK(PT_EXCLUSIVE);
+ sx_xlock(&proctree_lock);
if (p->p_oppid != p->p_pptr->p_pid) {
struct proc *pp;
@@ -234,7 +234,7 @@ procfs_control(curp, p, op)
p->p_oppid = 0;
p->p_flag &= ~P_WAITED; /* XXX ? */
PROC_UNLOCK(p);
- PROCTREE_LOCK(PT_RELEASE);
+ sx_xunlock(&proctree_lock);
wakeup((caddr_t) curp); /* XXX for CTL_WAIT below ? */
diff --git a/sys/fs/procfs/procfs_vnops.c b/sys/fs/procfs/procfs_vnops.c
index b715ab3..01e73ac 100644
--- a/sys/fs/procfs/procfs_vnops.c
+++ b/sys/fs/procfs/procfs_vnops.c
@@ -51,6 +51,7 @@
#include <sys/fcntl.h>
#include <sys/proc.h>
#include <sys/signalvar.h>
+#include <sys/sx.h>
#include <sys/vnode.h>
#include <sys/uio.h>
#include <sys/mount.h>
@@ -858,7 +859,7 @@ procfs_readdir(ap)
int pcnt = 0;
struct proc *p;
- ALLPROC_LOCK(AP_SHARED);
+ sx_slock(&allproc_lock);
p = LIST_FIRST(&allproc);
for (; p && uio->uio_resid >= delen; i++, pcnt++) {
bzero((char *) dp, delen);
@@ -916,7 +917,7 @@ procfs_readdir(ap)
}
#endif
- ALLPROC_LOCK(AP_RELEASE);
+ sx_sunlock(&allproc_lock);
break;
}
OpenPOWER on IntegriCloud