diff options
-rw-r--r-- | sys/fs/procfs/procfs.h | 6 | ||||
-rw-r--r-- | sys/fs/procfs/procfs_status.c | 39 | ||||
-rw-r--r-- | sys/fs/procfs/procfs_subr.c | 7 | ||||
-rw-r--r-- | sys/fs/procfs/procfs_vnops.c | 4 | ||||
-rw-r--r-- | sys/miscfs/procfs/procfs.h | 6 | ||||
-rw-r--r-- | sys/miscfs/procfs/procfs_status.c | 39 | ||||
-rw-r--r-- | sys/miscfs/procfs/procfs_subr.c | 7 | ||||
-rw-r--r-- | sys/miscfs/procfs/procfs_vnops.c | 4 |
8 files changed, 102 insertions, 10 deletions
diff --git a/sys/fs/procfs/procfs.h b/sys/fs/procfs/procfs.h index b727e16..619e1b2 100644 --- a/sys/fs/procfs/procfs.h +++ b/sys/fs/procfs/procfs.h @@ -37,7 +37,7 @@ * @(#)procfs.h 8.9 (Berkeley) 5/14/95 * * From: - * $Id: procfs.h,v 1.19 1998/05/19 00:00:13 tegge Exp $ + * $Id: procfs.h,v 1.20 1998/07/07 04:08:44 bde Exp $ */ /* @@ -56,7 +56,8 @@ typedef enum { Pnote, /* process notifier */ Pnotepg, /* process group notifier */ Pmap, /* memory map */ - Ptype /* executable type */ + Ptype, /* executable type */ + Pcmdline /* command line */ } pfstype; /* @@ -154,6 +155,7 @@ int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); int procfs_domap __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); int procfs_dotype __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); +int procfs_docmdline __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); /* Return 1 if process has special kernel digging privileges */ int procfs_kmemaccess __P((struct proc *)); diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c index 3f1cccf..3176a64 100644 --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -37,7 +37,7 @@ * @(#)procfs_status.c 8.4 (Berkeley) 6/15/94 * * From: - * $Id: procfs_status.c,v 1.10 1997/08/02 14:32:17 bde Exp $ + * $Id: procfs_status.c,v 1.11 1998/07/11 07:45:45 bde Exp $ */ #include <sys/param.h> @@ -147,3 +147,40 @@ procfs_dostatus(curp, p, pfs, uio) return (error); } + +int +procfs_docmdline(curp, p, pfs, uio) + struct proc *curp; + struct proc *p; + struct pfsnode *pfs; + struct uio *uio; +{ + char *ps; + int xlen; + int error; + char psbuf[256]; + + if (uio->uio_rw != UIO_READ) + return (EOPNOTSUPP); + + /* + * For now, this is a hack. To implement this fully would require + * groping around in the process address space to follow argv etc. + */ + ps = psbuf; + bcopy(p->p_comm, ps, MAXCOMLEN); + ps[MAXCOMLEN] = '\0'; + ps += strlen(ps); + + ps += sprintf(ps, "\n"); + + xlen = ps - psbuf; + xlen -= uio->uio_offset; + ps = psbuf + uio->uio_offset; + xlen = min(xlen, uio->uio_resid); + if (xlen <= 0) + error = 0; + else + error = uiomove(ps, xlen, uio); + return (error); +} diff --git a/sys/fs/procfs/procfs_subr.c b/sys/fs/procfs/procfs_subr.c index 2156b12..813232c 100644 --- a/sys/fs/procfs/procfs_subr.c +++ b/sys/fs/procfs/procfs_subr.c @@ -36,7 +36,7 @@ * * @(#)procfs_subr.c 8.6 (Berkeley) 5/14/95 * - * $Id: procfs_subr.c,v 1.20 1997/12/09 05:03:41 sef Exp $ + * $Id: procfs_subr.c,v 1.21 1997/12/12 03:33:43 sef Exp $ */ #include <sys/param.h> @@ -181,6 +181,7 @@ loop: case Ptype: case Pmap: case Pstatus: + case Pcmdline: pfs->pfs_mode = (VREAD) | (VREAD >> 3) | (VREAD >> 6); @@ -282,6 +283,10 @@ procfs_rw(ap) rtval = procfs_dotype(curp, p, pfs, uio); break; + case Pcmdline: + rtval = procfs_docmdline(curp, p, pfs, uio); + break; + default: rtval = EOPNOTSUPP; break; diff --git a/sys/fs/procfs/procfs_vnops.c b/sys/fs/procfs/procfs_vnops.c index 6879b08..daab08f 100644 --- a/sys/fs/procfs/procfs_vnops.c +++ b/sys/fs/procfs/procfs_vnops.c @@ -36,7 +36,7 @@ * * @(#)procfs_vnops.c 8.18 (Berkeley) 5/21/95 * - * $Id: procfs_vnops.c,v 1.61 1998/07/11 07:45:46 bde Exp $ + * $Id: procfs_vnops.c,v 1.62 1998/12/04 22:54:51 archie Exp $ */ /* @@ -101,6 +101,7 @@ static struct proc_target { { DT_REG, N("notepg"), Pnotepg, NULL }, { DT_REG, N("map"), Pmap, procfs_validmap }, { DT_REG, N("etype"), Ptype, procfs_validtype }, + { DT_REG, N("cmdline"), Pcmdline, NULL }, #undef N }; static const int nproc_targets = sizeof(proc_targets) / sizeof(proc_targets[0]); @@ -573,6 +574,7 @@ procfs_getattr(ap) case Pstatus: case Pnote: case Pnotepg: + case Pcmdline: vap->va_nlink = 1; vap->va_uid = procp->p_ucred->cr_uid; vap->va_gid = procp->p_ucred->cr_gid; diff --git a/sys/miscfs/procfs/procfs.h b/sys/miscfs/procfs/procfs.h index b727e16..619e1b2 100644 --- a/sys/miscfs/procfs/procfs.h +++ b/sys/miscfs/procfs/procfs.h @@ -37,7 +37,7 @@ * @(#)procfs.h 8.9 (Berkeley) 5/14/95 * * From: - * $Id: procfs.h,v 1.19 1998/05/19 00:00:13 tegge Exp $ + * $Id: procfs.h,v 1.20 1998/07/07 04:08:44 bde Exp $ */ /* @@ -56,7 +56,8 @@ typedef enum { Pnote, /* process notifier */ Pnotepg, /* process group notifier */ Pmap, /* memory map */ - Ptype /* executable type */ + Ptype, /* executable type */ + Pcmdline /* command line */ } pfstype; /* @@ -154,6 +155,7 @@ int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); int procfs_domap __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); int procfs_dotype __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); +int procfs_docmdline __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); /* Return 1 if process has special kernel digging privileges */ int procfs_kmemaccess __P((struct proc *)); diff --git a/sys/miscfs/procfs/procfs_status.c b/sys/miscfs/procfs/procfs_status.c index 3f1cccf..3176a64 100644 --- a/sys/miscfs/procfs/procfs_status.c +++ b/sys/miscfs/procfs/procfs_status.c @@ -37,7 +37,7 @@ * @(#)procfs_status.c 8.4 (Berkeley) 6/15/94 * * From: - * $Id: procfs_status.c,v 1.10 1997/08/02 14:32:17 bde Exp $ + * $Id: procfs_status.c,v 1.11 1998/07/11 07:45:45 bde Exp $ */ #include <sys/param.h> @@ -147,3 +147,40 @@ procfs_dostatus(curp, p, pfs, uio) return (error); } + +int +procfs_docmdline(curp, p, pfs, uio) + struct proc *curp; + struct proc *p; + struct pfsnode *pfs; + struct uio *uio; +{ + char *ps; + int xlen; + int error; + char psbuf[256]; + + if (uio->uio_rw != UIO_READ) + return (EOPNOTSUPP); + + /* + * For now, this is a hack. To implement this fully would require + * groping around in the process address space to follow argv etc. + */ + ps = psbuf; + bcopy(p->p_comm, ps, MAXCOMLEN); + ps[MAXCOMLEN] = '\0'; + ps += strlen(ps); + + ps += sprintf(ps, "\n"); + + xlen = ps - psbuf; + xlen -= uio->uio_offset; + ps = psbuf + uio->uio_offset; + xlen = min(xlen, uio->uio_resid); + if (xlen <= 0) + error = 0; + else + error = uiomove(ps, xlen, uio); + return (error); +} diff --git a/sys/miscfs/procfs/procfs_subr.c b/sys/miscfs/procfs/procfs_subr.c index 2156b12..813232c 100644 --- a/sys/miscfs/procfs/procfs_subr.c +++ b/sys/miscfs/procfs/procfs_subr.c @@ -36,7 +36,7 @@ * * @(#)procfs_subr.c 8.6 (Berkeley) 5/14/95 * - * $Id: procfs_subr.c,v 1.20 1997/12/09 05:03:41 sef Exp $ + * $Id: procfs_subr.c,v 1.21 1997/12/12 03:33:43 sef Exp $ */ #include <sys/param.h> @@ -181,6 +181,7 @@ loop: case Ptype: case Pmap: case Pstatus: + case Pcmdline: pfs->pfs_mode = (VREAD) | (VREAD >> 3) | (VREAD >> 6); @@ -282,6 +283,10 @@ procfs_rw(ap) rtval = procfs_dotype(curp, p, pfs, uio); break; + case Pcmdline: + rtval = procfs_docmdline(curp, p, pfs, uio); + break; + default: rtval = EOPNOTSUPP; break; diff --git a/sys/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c index 6879b08..daab08f 100644 --- a/sys/miscfs/procfs/procfs_vnops.c +++ b/sys/miscfs/procfs/procfs_vnops.c @@ -36,7 +36,7 @@ * * @(#)procfs_vnops.c 8.18 (Berkeley) 5/21/95 * - * $Id: procfs_vnops.c,v 1.61 1998/07/11 07:45:46 bde Exp $ + * $Id: procfs_vnops.c,v 1.62 1998/12/04 22:54:51 archie Exp $ */ /* @@ -101,6 +101,7 @@ static struct proc_target { { DT_REG, N("notepg"), Pnotepg, NULL }, { DT_REG, N("map"), Pmap, procfs_validmap }, { DT_REG, N("etype"), Ptype, procfs_validtype }, + { DT_REG, N("cmdline"), Pcmdline, NULL }, #undef N }; static const int nproc_targets = sizeof(proc_targets) / sizeof(proc_targets[0]); @@ -573,6 +574,7 @@ procfs_getattr(ap) case Pstatus: case Pnote: case Pnotepg: + case Pcmdline: vap->va_nlink = 1; vap->va_uid = procp->p_ucred->cr_uid; vap->va_gid = procp->p_ucred->cr_gid; |