diff options
Diffstat (limited to 'sys/fs/procfs')
-rw-r--r-- | sys/fs/procfs/procfs.h | 7 | ||||
-rw-r--r-- | sys/fs/procfs/procfs_ctl.c | 11 | ||||
-rw-r--r-- | sys/fs/procfs/procfs_fpregs.c | 14 | ||||
-rw-r--r-- | sys/fs/procfs/procfs_mem.c | 11 | ||||
-rw-r--r-- | sys/fs/procfs/procfs_regs.c | 14 | ||||
-rw-r--r-- | sys/fs/procfs/procfs_vnops.c | 53 |
6 files changed, 88 insertions, 22 deletions
diff --git a/sys/fs/procfs/procfs.h b/sys/fs/procfs/procfs.h index ddb5757..964c667 100644 --- a/sys/fs/procfs/procfs.h +++ b/sys/fs/procfs/procfs.h @@ -36,7 +36,7 @@ * * @(#)procfs.h 8.6 (Berkeley) 2/3/94 * - * $Id: procfs.h,v 1.7 1995/11/09 08:16:01 bde Exp $ + * $Id: procfs.h,v 1.8 1995/11/16 11:39:09 bde Exp $ */ /* @@ -134,6 +134,11 @@ extern int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *pfsp, extern int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); extern int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); +/* check to see if the process has the "items" (regs/file) */ +int procfs_validfile __P((struct proc *)); +int procfs_validfpregs __P((struct proc *)); +int procfs_validregs __P((struct proc *)); + #define PROCFS_LOCKED 0x01 #define PROCFS_WANT 0x02 diff --git a/sys/fs/procfs/procfs_ctl.c b/sys/fs/procfs/procfs_ctl.c index d11a296..78d4ac2 100644 --- a/sys/fs/procfs/procfs_ctl.c +++ b/sys/fs/procfs/procfs_ctl.c @@ -36,7 +36,7 @@ * * @(#)procfs_ctl.c 8.3 (Berkeley) 1/21/94 * - * $Id: procfs_ctl.c,v 1.7 1995/12/03 14:54:34 bde Exp $ + * $Id: procfs_ctl.c,v 1.8 1995/12/07 12:47:14 davidg Exp $ */ #include <sys/param.h> @@ -72,8 +72,6 @@ procfs_fix_sstep(p); \ } \ } -#else -#define FIX_SSTEP(p) #endif #define PROCFS_CTL_ATTACH 1 @@ -171,10 +169,13 @@ procfs_control(curp, p, op) return (EBUSY); } + +#ifdef FIX_SSTEP /* * do single-step fixup if needed */ FIX_SSTEP(p); +#endif /* * Don't deliver any signal by default. @@ -218,7 +219,9 @@ procfs_control(curp, p, op) * Step. Let the target process execute a single instruction. */ case PROCFS_CTL_STEP: + PHOLD(p); procfs_sstep(p); + PRELE(p); break; /* @@ -301,7 +304,9 @@ procfs_doctl(curp, p, pfs, uio) if (nm) { if (TRACE_WAIT_P(curp, p)) { p->p_xstat = nm->nm_val; +#ifdef FIX_SSTEP FIX_SSTEP(p); +#endif setrunnable(p); } else { psignal(p, nm->nm_val); diff --git a/sys/fs/procfs/procfs_fpregs.c b/sys/fs/procfs/procfs_fpregs.c index 331a671..3f233bd 100644 --- a/sys/fs/procfs/procfs_fpregs.c +++ b/sys/fs/procfs/procfs_fpregs.c @@ -36,7 +36,7 @@ * * @(#)procfs_fpregs.c 8.1 (Berkeley) 1/27/94 * - * $Id: procfs_fpregs.c,v 1.1.1.1 1994/05/24 10:05:09 rgrimes Exp $ + * $Id: procfs_fpregs.c,v 1.2 1994/08/02 07:45:12 davidg Exp $ */ #include <sys/param.h> @@ -47,6 +47,8 @@ #include <sys/vnode.h> #include <machine/reg.h> #include <miscfs/procfs/procfs.h> +#include <vm/vm.h> +#include <vm/vm_extern.h> int procfs_dofpregs(curp, p, pfs, uio) @@ -68,6 +70,8 @@ procfs_dofpregs(curp, p, pfs, uio) if (kl > uio->uio_resid) kl = uio->uio_resid; + PHOLD(p); + if (kl < 0) error = EINVAL; else @@ -80,7 +84,15 @@ procfs_dofpregs(curp, p, pfs, uio) else error = procfs_write_fpregs(p, &r); } + PRELE(p); uio->uio_offset = 0; return (error); } + +int +procfs_validfpregs(p) + struct proc *p; +{ + return ((p->p_flag & P_SYSTEM) == 0); +} diff --git a/sys/fs/procfs/procfs_mem.c b/sys/fs/procfs/procfs_mem.c index b536055..f772c4b 100644 --- a/sys/fs/procfs/procfs_mem.c +++ b/sys/fs/procfs/procfs_mem.c @@ -37,7 +37,7 @@ * * @(#)procfs_mem.c 8.4 (Berkeley) 1/21/94 * - * $Id: procfs_mem.c,v 1.14 1995/12/17 07:19:24 bde Exp $ + * $Id: procfs_mem.c,v 1.15 1996/01/19 03:58:32 dyson Exp $ */ /* @@ -62,6 +62,7 @@ #include <vm/vm_object.h> #include <vm/vm_page.h> #include <vm/vm_extern.h> +#include <sys/user.h> static int procfs_rwmem __P((struct proc *p, struct uio *uio)); @@ -96,10 +97,18 @@ procfs_rwmem(p, uio) uva = (vm_offset_t) uio->uio_offset; if (uva >= VM_MAXUSER_ADDRESS) { + if (writing || (uva >= (VM_MAXUSER_ADDRESS + UPAGES * PAGE_SIZE))) { error = 0; break; } + /* we are reading the "U area", fill it in */ + PHOLD(p); + if (p->p_flag & P_INMEM) { + p->p_addr->u_kproc.kp_proc = *p; + fill_eproc (p, &p->p_addr->u_kproc.kp_eproc); + } + PRELE(p); } /* diff --git a/sys/fs/procfs/procfs_regs.c b/sys/fs/procfs/procfs_regs.c index 8b0600a..bc5520c 100644 --- a/sys/fs/procfs/procfs_regs.c +++ b/sys/fs/procfs/procfs_regs.c @@ -36,7 +36,7 @@ * * @(#)procfs_regs.c 8.3 (Berkeley) 1/27/94 * - * $Id: procfs_regs.c,v 1.1.1.1 1994/05/24 10:05:08 rgrimes Exp $ + * $Id: procfs_regs.c,v 1.2 1994/08/02 07:45:18 davidg Exp $ */ #include <sys/param.h> @@ -47,6 +47,8 @@ #include <sys/vnode.h> #include <machine/reg.h> #include <miscfs/procfs/procfs.h> +#include <vm/vm.h> +#include <vm/vm_extern.h> int procfs_doregs(curp, p, pfs, uio) @@ -68,6 +70,8 @@ procfs_doregs(curp, p, pfs, uio) if (kl > uio->uio_resid) kl = uio->uio_resid; + PHOLD(p); + if (kl < 0) error = EINVAL; else @@ -80,7 +84,15 @@ procfs_doregs(curp, p, pfs, uio) else error = procfs_write_regs(p, &r); } + PRELE(p); uio->uio_offset = 0; return (error); } + +int +procfs_validregs(p) + struct proc *p; +{ + return ((p->p_flag & P_SYSTEM) == 0); +} diff --git a/sys/fs/procfs/procfs_vnops.c b/sys/fs/procfs/procfs_vnops.c index 24638fe..df57932 100644 --- a/sys/fs/procfs/procfs_vnops.c +++ b/sys/fs/procfs/procfs_vnops.c @@ -36,7 +36,7 @@ * * @(#)procfs_vnops.c 8.6 (Berkeley) 2/7/94 * - * $Id: procfs_vnops.c,v 1.18 1995/11/09 08:16:04 bde Exp $ + * $Id: procfs_vnops.c,v 1.19 1995/11/16 11:39:11 bde Exp $ */ /* @@ -81,21 +81,20 @@ static struct pfsnames { u_short d_namlen; char d_name[PROCFS_NAMELEN]; pfstype d_pfstype; + int (*d_valid) __P((struct proc *)); } procent[] = { #define N(s) sizeof(s)-1, s - /* namlen, nam, type */ - { N("."), Pproc }, - { N(".."), Proot }, -#if 0 - { N("file"), Pfile }, -#endif - { N("mem"), Pmem }, - { N("regs"), Pregs }, - { N("fpregs"), Pfpregs }, - { N("ctl"), Pctl }, - { N("status"), Pstatus }, - { N("note"), Pnote }, - { N("notepg"), Pnotepg }, + /* namlen, nam, type validp */ + { N("."), Pproc, NULL }, + { N(".."), Proot, NULL }, + { N("file"), Pfile, procfs_validfile }, + { N("mem"), Pmem, NULL }, + { N("regs"), Pregs, procfs_validregs }, + { N("fpregs"), Pfpregs, procfs_validfpregs }, + { N("ctl"), Pctl, NULL }, + { N("status"), Pstatus, NULL }, + { N("note"), Pnote, NULL }, + { N("notepg"), Pnotepg, NULL }, #undef N }; #define Nprocent (sizeof(procent)/sizeof(procent[0])) @@ -356,6 +355,7 @@ procfs_getattr(ap) * that only root can gain access. */ switch (pfs->pfs_type) { + case Pctl: case Pregs: case Pfpregs: if (procp->p_flag & P_SUGID) @@ -599,7 +599,8 @@ procfs_lookup(ap) struct pfsnames *dp = &procent[i]; if (cnp->cn_namelen == dp->d_namlen && - bcmp(pname, dp->d_name, dp->d_namlen) == 0) { + bcmp(pname, dp->d_name, dp->d_namlen) == 0 && + (dp->d_valid == NULL || (*dp->d_valid)(procp))) { pfs_type = dp->d_pfstype; goto found; } @@ -633,6 +634,16 @@ procfs_lookup(ap) } /* + * Does this process have a text file? + */ +int +procfs_validfile(p) + struct proc *p; +{ + return (procfs_findtextvp(p) != NULLVP); +} + +/* * readdir returns directory entries from pfsnode (vp). * * the strategy here with procfs is to generate a single @@ -676,6 +687,12 @@ procfs_readdir(ap) * from the procent[] table (top of this file). */ case Pproc: { + struct proc *p; + + p = PFIND(pfs->pfs_pid); + if (p == NULL) + break; + while (uio->uio_resid >= UIO_MX) { struct pfsnames *dt; @@ -684,6 +701,12 @@ procfs_readdir(ap) dt = &procent[i]; + /* see if we should show this one. */ + if (dt->d_valid && (*dt->d_valid)(p) == 0) { + i++; + continue; + } + dp->d_reclen = UIO_MX; dp->d_fileno = PROCFS_FILENO(pfs->pfs_pid, dt->d_pfstype); dp->d_type = DT_REG; |