aboutsummaryrefslogtreecommitdiff
path: root/sys/miscfs/procfs
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2001-03-28 11:52:56 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2001-03-28 11:52:56 +0000
commit1005a129e5ff4af4709d281023e8a101a28fcb82 (patch)
tree0e149b4a15299675308712c4196c45b696f76c14 /sys/miscfs/procfs
parent11f1917f8ae19359d8672d966f4cf966e115c7a7 (diff)
Notes
Diffstat (limited to 'sys/miscfs/procfs')
-rw-r--r--sys/miscfs/procfs/procfs_ctl.c22
-rw-r--r--sys/miscfs/procfs/procfs_vnops.c5
2 files changed, 14 insertions, 13 deletions
diff --git a/sys/miscfs/procfs/procfs_ctl.c b/sys/miscfs/procfs/procfs_ctl.c
index 01307958e59b..6a20cc641bed 100644
--- a/sys/miscfs/procfs/procfs_ctl.c
+++ b/sys/miscfs/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/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c
index b715ab3995a7..01e73ac96c6c 100644
--- a/sys/miscfs/procfs/procfs_vnops.c
+++ b/sys/miscfs/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;
}