2000-04-20 03:54:27 +00:00
|
|
|
|
/*
|
2000-09-07 16:44:26 +00:00
|
|
|
|
* Copyright (c) 2000 Dag-Erling Co<EFBFBD>dan Sm<EFBFBD>rgrav
|
|
|
|
|
* Copyright (c) 1999 Pierre Beyssac
|
2000-04-20 03:54:27 +00:00
|
|
|
|
* Copyright (c) 1993 Jan-Simon Pendry
|
|
|
|
|
* Copyright (c) 1993
|
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
|
* Jan-Simon Pendry.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
|
* without specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
|
*
|
|
|
|
|
* @(#)procfs_status.c 8.4 (Berkeley) 6/15/94
|
|
|
|
|
*
|
|
|
|
|
* $FreeBSD$
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
#include <sys/blist.h>
|
2000-09-09 11:44:58 +00:00
|
|
|
|
#include <sys/dkstat.h>
|
|
|
|
|
#include <sys/jail.h>
|
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
|
#include <sys/proc.h>
|
2000-04-20 03:54:27 +00:00
|
|
|
|
#include <sys/resourcevar.h>
|
2000-09-09 11:44:58 +00:00
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
#include <sys/tty.h>
|
|
|
|
|
#include <sys/vnode.h>
|
2000-04-20 03:54:27 +00:00
|
|
|
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
|
#include <vm/pmap.h>
|
2000-10-25 22:12:59 +00:00
|
|
|
|
#include <vm/vm_map.h>
|
2000-04-20 03:54:27 +00:00
|
|
|
|
#include <vm/vm_param.h>
|
2000-05-24 07:37:02 +00:00
|
|
|
|
#include <vm/vm_object.h>
|
2000-04-20 03:54:27 +00:00
|
|
|
|
#include <vm/swap_pager.h>
|
2000-12-09 13:25:54 +00:00
|
|
|
|
|
2000-04-20 03:54:27 +00:00
|
|
|
|
#include <sys/exec.h>
|
2000-12-09 13:25:54 +00:00
|
|
|
|
#include <sys/user.h>
|
|
|
|
|
#include <sys/vmmeter.h>
|
2000-04-20 03:54:27 +00:00
|
|
|
|
|
2000-10-25 22:38:23 +00:00
|
|
|
|
#include <machine/clock.h>
|
2000-04-20 03:54:27 +00:00
|
|
|
|
#include <machine/cputypes.h>
|
2000-10-25 22:38:23 +00:00
|
|
|
|
#include <machine/md_var.h>
|
2000-04-20 03:54:27 +00:00
|
|
|
|
|
2000-12-12 22:06:05 +00:00
|
|
|
|
#include <compat/linprocfs/linprocfs.h>
|
2000-09-09 11:44:58 +00:00
|
|
|
|
|
2000-10-25 22:12:59 +00:00
|
|
|
|
/*
|
|
|
|
|
* Various conversion macros
|
|
|
|
|
*/
|
|
|
|
|
#define T2J(x) (((x) * 100) / (stathz ? stathz : hz)) /* ticks to jiffies */
|
|
|
|
|
#define T2S(x) ((x) / (stathz ? stathz : hz)) /* ticks to seconds */
|
|
|
|
|
#define B2K(x) ((x) >> 10) /* bytes to kbytes */
|
2000-12-09 13:25:54 +00:00
|
|
|
|
#define B2P(x) ((x) >> PAGE_SHIFT) /* bytes to pages */
|
2000-10-25 22:12:59 +00:00
|
|
|
|
#define P2B(x) ((x) << PAGE_SHIFT) /* pages to bytes */
|
|
|
|
|
#define P2K(x) ((x) << (PAGE_SHIFT - 10)) /* pages to kbytes */
|
2000-12-09 13:25:54 +00:00
|
|
|
|
|
2000-04-20 03:54:27 +00:00
|
|
|
|
int
|
|
|
|
|
linprocfs_domeminfo(curp, p, pfs, uio)
|
|
|
|
|
struct proc *curp;
|
|
|
|
|
struct proc *p;
|
|
|
|
|
struct pfsnode *pfs;
|
|
|
|
|
struct uio *uio;
|
|
|
|
|
{
|
|
|
|
|
char *ps;
|
|
|
|
|
int xlen;
|
|
|
|
|
char psbuf[512]; /* XXX - conservative */
|
|
|
|
|
unsigned long memtotal; /* total memory in bytes */
|
|
|
|
|
unsigned long memused; /* used memory in bytes */
|
|
|
|
|
unsigned long memfree; /* free memory in bytes */
|
|
|
|
|
unsigned long memshared; /* shared memory ??? */
|
|
|
|
|
unsigned long buffers, cached; /* buffer / cache memory ??? */
|
|
|
|
|
unsigned long swaptotal; /* total swap space in bytes */
|
|
|
|
|
unsigned long swapused; /* used swap space in bytes */
|
|
|
|
|
unsigned long swapfree; /* free swap space in bytes */
|
2000-05-24 07:37:02 +00:00
|
|
|
|
vm_object_t object;
|
2000-04-20 03:54:27 +00:00
|
|
|
|
|
|
|
|
|
if (uio->uio_rw != UIO_READ)
|
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
|
|
|
|
|
|
memtotal = physmem * PAGE_SIZE;
|
|
|
|
|
/*
|
|
|
|
|
* The correct thing here would be:
|
|
|
|
|
*
|
|
|
|
|
memfree = cnt.v_free_count * PAGE_SIZE;
|
|
|
|
|
memused = memtotal - memfree;
|
|
|
|
|
*
|
|
|
|
|
* but it might mislead linux binaries into thinking there
|
|
|
|
|
* is very little memory left, so we cheat and tell them that
|
|
|
|
|
* all memory that isn't wired down is free.
|
|
|
|
|
*/
|
|
|
|
|
memused = cnt.v_wire_count * PAGE_SIZE;
|
|
|
|
|
memfree = memtotal - memused;
|
2000-08-12 21:08:42 +00:00
|
|
|
|
if (swapblist == NULL) {
|
|
|
|
|
swaptotal = 0;
|
|
|
|
|
swapfree = 0;
|
|
|
|
|
} else {
|
|
|
|
|
swaptotal = swapblist->bl_blocks * 1024; /* XXX why 1024? */
|
|
|
|
|
swapfree = swapblist->bl_root->u.bmu_avail * PAGE_SIZE;
|
|
|
|
|
}
|
2000-04-20 03:54:27 +00:00
|
|
|
|
swapused = swaptotal - swapfree;
|
2000-05-24 07:37:02 +00:00
|
|
|
|
memshared = 0;
|
|
|
|
|
for (object = TAILQ_FIRST(&vm_object_list); object != NULL;
|
|
|
|
|
object = TAILQ_NEXT(object, object_list))
|
|
|
|
|
if (object->shadow_count > 1)
|
|
|
|
|
memshared += object->resident_page_count;
|
|
|
|
|
memshared *= PAGE_SIZE;
|
2000-04-20 03:54:27 +00:00
|
|
|
|
/*
|
|
|
|
|
* We'd love to be able to write:
|
|
|
|
|
*
|
|
|
|
|
buffers = bufspace;
|
|
|
|
|
*
|
|
|
|
|
* but bufspace is internal to vfs_bio.c and we don't feel
|
|
|
|
|
* like unstaticizing it just for linprocfs's sake.
|
|
|
|
|
*/
|
|
|
|
|
buffers = 0;
|
|
|
|
|
cached = cnt.v_cache_count * PAGE_SIZE;
|
|
|
|
|
|
|
|
|
|
ps = psbuf;
|
|
|
|
|
ps += sprintf(ps,
|
2000-12-09 13:25:54 +00:00
|
|
|
|
" total: used: free: shared: buffers: cached:\n"
|
|
|
|
|
"Mem: %lu %lu %lu %lu %lu %lu\n"
|
|
|
|
|
"Swap: %lu %lu %lu\n"
|
|
|
|
|
"MemTotal: %9lu kB\n"
|
|
|
|
|
"MemFree: %9lu kB\n"
|
|
|
|
|
"MemShared:%9lu kB\n"
|
|
|
|
|
"Buffers: %9lu kB\n"
|
|
|
|
|
"Cached: %9lu kB\n"
|
|
|
|
|
"SwapTotal:%9lu kB\n"
|
|
|
|
|
"SwapFree: %9lu kB\n",
|
|
|
|
|
memtotal, memused, memfree, memshared, buffers, cached,
|
|
|
|
|
swaptotal, swapused, swapfree,
|
|
|
|
|
B2K(memtotal), B2K(memfree),
|
|
|
|
|
B2K(memshared), B2K(buffers), B2K(cached),
|
|
|
|
|
B2K(swaptotal), B2K(swapfree));
|
2000-04-20 03:54:27 +00:00
|
|
|
|
|
|
|
|
|
xlen = ps - psbuf;
|
|
|
|
|
xlen -= uio->uio_offset;
|
|
|
|
|
ps = psbuf + uio->uio_offset;
|
|
|
|
|
xlen = imin(xlen, uio->uio_resid);
|
2000-09-09 11:44:58 +00:00
|
|
|
|
return (xlen <= 0 ? 0 : uiomove(ps, xlen, uio));
|
2000-04-20 03:54:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linprocfs_docpuinfo(curp, p, pfs, uio)
|
|
|
|
|
struct proc *curp;
|
|
|
|
|
struct proc *p;
|
|
|
|
|
struct pfsnode *pfs;
|
|
|
|
|
struct uio *uio;
|
|
|
|
|
{
|
|
|
|
|
char *ps;
|
|
|
|
|
int xlen;
|
|
|
|
|
char psbuf[512]; /* XXX - conservative */
|
2000-12-09 13:25:54 +00:00
|
|
|
|
int class, i, fqmhz, fqkhz;
|
2000-10-25 22:38:23 +00:00
|
|
|
|
|
2000-12-09 13:25:54 +00:00
|
|
|
|
/*
|
|
|
|
|
* We default the flags to include all non-conflicting flags,
|
|
|
|
|
* and the Intel versions of conflicting flags.
|
|
|
|
|
*/
|
2000-10-25 22:38:23 +00:00
|
|
|
|
static char *flags[] = {
|
|
|
|
|
"fpu", "vme", "de", "pse", "tsc",
|
|
|
|
|
"msr", "pae", "mce", "cx8", "apic",
|
|
|
|
|
"sep", "sep", "mtrr", "pge", "mca",
|
|
|
|
|
"cmov", "pat", "pse36", "pn", "b19",
|
|
|
|
|
"b20", "b21", "mmxext", "mmx", "fxsr",
|
|
|
|
|
"xmm", "b26", "b27", "b28", "b29",
|
|
|
|
|
"3dnowext", "3dnow"
|
|
|
|
|
};
|
2000-04-20 03:54:27 +00:00
|
|
|
|
|
|
|
|
|
if (uio->uio_rw != UIO_READ)
|
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
|
|
|
|
|
|
switch (cpu_class) {
|
|
|
|
|
case CPUCLASS_286:
|
2000-10-25 22:38:23 +00:00
|
|
|
|
class = 2;
|
2000-04-20 03:54:27 +00:00
|
|
|
|
break;
|
|
|
|
|
case CPUCLASS_386:
|
2000-10-25 22:38:23 +00:00
|
|
|
|
class = 3;
|
2000-04-20 03:54:27 +00:00
|
|
|
|
break;
|
|
|
|
|
case CPUCLASS_486:
|
2000-10-25 22:38:23 +00:00
|
|
|
|
class = 4;
|
2000-04-20 03:54:27 +00:00
|
|
|
|
break;
|
|
|
|
|
case CPUCLASS_586:
|
2000-10-25 22:38:23 +00:00
|
|
|
|
class = 5;
|
2000-04-20 03:54:27 +00:00
|
|
|
|
break;
|
|
|
|
|
case CPUCLASS_686:
|
2000-10-25 22:38:23 +00:00
|
|
|
|
class = 6;
|
2000-04-20 03:54:27 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2000-10-25 22:38:23 +00:00
|
|
|
|
class = 0;
|
2000-04-20 03:54:27 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ps = psbuf;
|
|
|
|
|
ps += sprintf(ps,
|
2000-12-09 13:25:54 +00:00
|
|
|
|
"processor\t: %d\n"
|
|
|
|
|
"vendor_id\t: %.20s\n"
|
|
|
|
|
"cpu family\t: %d\n"
|
|
|
|
|
"model\t\t: %d\n"
|
|
|
|
|
"stepping\t: %d\n",
|
|
|
|
|
0, cpu_vendor, class, cpu, cpu_id & 0xf);
|
2000-10-25 22:38:23 +00:00
|
|
|
|
|
|
|
|
|
ps += sprintf(ps,
|
2000-12-09 13:25:54 +00:00
|
|
|
|
"flags\t\t:");
|
2000-04-20 03:54:27 +00:00
|
|
|
|
|
2000-10-25 22:38:23 +00:00
|
|
|
|
if (!strcmp(cpu_vendor, "AuthenticAMD") && (class < 6)) {
|
|
|
|
|
flags[16] = "fcmov";
|
|
|
|
|
} else if (!strcmp(cpu_vendor, "CyrixInstead")) {
|
|
|
|
|
flags[24] = "cxmmx";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
|
if (cpu_feature & (1 << i))
|
|
|
|
|
ps += sprintf(ps, " %s", flags[i]);
|
|
|
|
|
ps += sprintf(ps, "\n");
|
|
|
|
|
if (class >= 5) {
|
2000-12-09 13:25:54 +00:00
|
|
|
|
fqmhz = (tsc_freq + 4999) / 1000000;
|
|
|
|
|
fqkhz = ((tsc_freq + 4999) / 10000) % 100;
|
2000-10-25 22:38:23 +00:00
|
|
|
|
ps += sprintf(ps,
|
2000-12-09 13:25:54 +00:00
|
|
|
|
"cpu MHz\t\t: %d.%02d\n"
|
|
|
|
|
"bogomips\t: %d.%02d\n",
|
|
|
|
|
fqmhz, fqkhz, fqmhz, fqkhz);
|
2000-10-25 22:38:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-20 03:54:27 +00:00
|
|
|
|
xlen = ps - psbuf;
|
|
|
|
|
xlen -= uio->uio_offset;
|
|
|
|
|
ps = psbuf + uio->uio_offset;
|
|
|
|
|
xlen = imin(xlen, uio->uio_resid);
|
2000-09-09 11:44:58 +00:00
|
|
|
|
return (xlen <= 0 ? 0 : uiomove(ps, xlen, uio));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linprocfs_dostat(curp, p, pfs, uio)
|
|
|
|
|
struct proc *curp;
|
|
|
|
|
struct proc *p;
|
|
|
|
|
struct pfsnode *pfs;
|
|
|
|
|
struct uio *uio;
|
|
|
|
|
{
|
|
|
|
|
char *ps;
|
|
|
|
|
char psbuf[512];
|
|
|
|
|
int xlen;
|
|
|
|
|
|
|
|
|
|
ps = psbuf;
|
|
|
|
|
ps += sprintf(ps,
|
2000-12-09 13:25:54 +00:00
|
|
|
|
"cpu %ld %ld %ld %ld\n"
|
|
|
|
|
"disk 0 0 0 0\n"
|
|
|
|
|
"page %u %u\n"
|
|
|
|
|
"swap %u %u\n"
|
|
|
|
|
"intr %u\n"
|
|
|
|
|
"ctxt %u\n"
|
|
|
|
|
"btime %ld\n",
|
|
|
|
|
T2J(cp_time[CP_USER]),
|
|
|
|
|
T2J(cp_time[CP_NICE]),
|
|
|
|
|
T2J(cp_time[CP_SYS] /*+ cp_time[CP_INTR]*/),
|
|
|
|
|
T2J(cp_time[CP_IDLE]),
|
|
|
|
|
cnt.v_vnodepgsin,
|
|
|
|
|
cnt.v_vnodepgsout,
|
|
|
|
|
cnt.v_swappgsin,
|
|
|
|
|
cnt.v_swappgsout,
|
|
|
|
|
cnt.v_intr,
|
|
|
|
|
cnt.v_swtch,
|
|
|
|
|
boottime.tv_sec);
|
2000-09-09 11:44:58 +00:00
|
|
|
|
xlen = ps - psbuf;
|
|
|
|
|
xlen -= uio->uio_offset;
|
|
|
|
|
ps = psbuf + uio->uio_offset;
|
|
|
|
|
xlen = imin(xlen, uio->uio_resid);
|
|
|
|
|
return (xlen <= 0 ? 0 : uiomove(ps, xlen, uio));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linprocfs_douptime(curp, p, pfs, uio)
|
|
|
|
|
struct proc *curp;
|
|
|
|
|
struct proc *p;
|
|
|
|
|
struct pfsnode *pfs;
|
|
|
|
|
struct uio *uio;
|
|
|
|
|
{
|
|
|
|
|
char *ps;
|
|
|
|
|
int xlen;
|
|
|
|
|
char psbuf[64];
|
|
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
|
|
getmicrouptime(&tv);
|
|
|
|
|
ps = psbuf;
|
|
|
|
|
ps += sprintf(ps, "%ld.%02ld %ld.%02ld\n",
|
2000-12-09 13:25:54 +00:00
|
|
|
|
tv.tv_sec, tv.tv_usec / 10000,
|
|
|
|
|
T2S(cp_time[CP_IDLE]), T2J(cp_time[CP_IDLE]) % 100);
|
2000-09-09 11:44:58 +00:00
|
|
|
|
xlen = ps - psbuf;
|
|
|
|
|
xlen -= uio->uio_offset;
|
|
|
|
|
ps = psbuf + uio->uio_offset;
|
|
|
|
|
xlen = imin(xlen, uio->uio_resid);
|
|
|
|
|
return (xlen <= 0 ? 0 : uiomove(ps, xlen, uio));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linprocfs_doversion(curp, p, pfs, uio)
|
|
|
|
|
struct proc *curp;
|
|
|
|
|
struct proc *p;
|
|
|
|
|
struct pfsnode *pfs;
|
|
|
|
|
struct uio *uio;
|
|
|
|
|
{
|
|
|
|
|
char *ps;
|
|
|
|
|
int xlen;
|
|
|
|
|
|
|
|
|
|
ps = version; /* XXX not entirely correct */
|
|
|
|
|
for (xlen = 0; ps[xlen] != '\n'; ++xlen)
|
|
|
|
|
/* nothing */ ;
|
|
|
|
|
++xlen;
|
|
|
|
|
xlen -= uio->uio_offset;
|
|
|
|
|
ps += uio->uio_offset;
|
|
|
|
|
xlen = imin(xlen, uio->uio_resid);
|
|
|
|
|
return (xlen <= 0 ? 0 : uiomove(ps, xlen, uio));
|
2000-04-20 03:54:27 +00:00
|
|
|
|
}
|
2000-09-09 11:44:58 +00:00
|
|
|
|
|
2000-10-25 22:12:59 +00:00
|
|
|
|
int
|
|
|
|
|
linprocfs_doprocstat(curp, p, pfs, uio)
|
|
|
|
|
struct proc *curp;
|
|
|
|
|
struct proc *p;
|
|
|
|
|
struct pfsnode *pfs;
|
|
|
|
|
struct uio *uio;
|
|
|
|
|
{
|
2000-12-09 13:25:54 +00:00
|
|
|
|
struct eproc ep;
|
2000-10-25 22:12:59 +00:00
|
|
|
|
char *ps, psbuf[1024];
|
|
|
|
|
int xlen;
|
|
|
|
|
|
2000-12-09 13:25:54 +00:00
|
|
|
|
fill_eproc(p, &ep);
|
2000-10-25 22:12:59 +00:00
|
|
|
|
ps = psbuf;
|
|
|
|
|
ps += sprintf(ps, "%d", p->p_pid);
|
|
|
|
|
#define PS_ADD(name, fmt, arg) ps += sprintf(ps, " " fmt, arg)
|
|
|
|
|
PS_ADD("comm", "(%s)", p->p_comm);
|
|
|
|
|
PS_ADD("statr", "%c", '0'); /* XXX */
|
2000-11-06 03:23:56 +00:00
|
|
|
|
PS_ADD("ppid", "%d", p->p_pptr ? p->p_pptr->p_pid : 0);
|
2000-10-25 22:12:59 +00:00
|
|
|
|
PS_ADD("pgrp", "%d", p->p_pgid);
|
|
|
|
|
PS_ADD("session", "%d", p->p_session->s_sid);
|
|
|
|
|
PS_ADD("tty", "%d", 0); /* XXX */
|
|
|
|
|
PS_ADD("tpgid", "%d", 0); /* XXX */
|
|
|
|
|
PS_ADD("flags", "%u", 0); /* XXX */
|
|
|
|
|
PS_ADD("minflt", "%u", 0); /* XXX */
|
|
|
|
|
PS_ADD("cminflt", "%u", 0); /* XXX */
|
|
|
|
|
PS_ADD("majflt", "%u", 0); /* XXX */
|
|
|
|
|
PS_ADD("cminflt", "%u", 0); /* XXX */
|
|
|
|
|
PS_ADD("utime", "%d", 0); /* XXX */
|
|
|
|
|
PS_ADD("stime", "%d", 0); /* XXX */
|
|
|
|
|
PS_ADD("cutime", "%d", 0); /* XXX */
|
|
|
|
|
PS_ADD("cstime", "%d", 0); /* XXX */
|
|
|
|
|
PS_ADD("counter", "%d", 0); /* XXX */
|
|
|
|
|
PS_ADD("priority", "%d", 0); /* XXX */
|
|
|
|
|
PS_ADD("timeout", "%u", 0); /* XXX */
|
|
|
|
|
PS_ADD("itrealvalue", "%u", 0); /* XXX */
|
|
|
|
|
PS_ADD("starttime", "%d", 0); /* XXX */
|
2000-12-09 13:25:54 +00:00
|
|
|
|
PS_ADD("vsize", "%u", ep.e_vm.vm_map.size);
|
|
|
|
|
PS_ADD("rss", "%u", P2K(ep.e_vm.vm_rssize));
|
2000-10-25 22:12:59 +00:00
|
|
|
|
PS_ADD("rlim", "%u", 0); /* XXX */
|
2000-12-09 13:25:54 +00:00
|
|
|
|
PS_ADD("startcode", "%u", (unsigned)ep.e_vm.vm_taddr);
|
2000-10-25 22:12:59 +00:00
|
|
|
|
PS_ADD("endcode", "%u", 0); /* XXX */
|
|
|
|
|
PS_ADD("startstack", "%u", 0); /* XXX */
|
2000-12-09 13:25:54 +00:00
|
|
|
|
PS_ADD("esp", "%u", 0); /* XXX */
|
|
|
|
|
PS_ADD("eip", "%u", 0); /* XXX */
|
2000-10-25 22:12:59 +00:00
|
|
|
|
PS_ADD("signal", "%d", 0); /* XXX */
|
|
|
|
|
PS_ADD("blocked", "%d", 0); /* XXX */
|
|
|
|
|
PS_ADD("sigignore", "%d", 0); /* XXX */
|
|
|
|
|
PS_ADD("sigcatch", "%d", 0); /* XXX */
|
|
|
|
|
PS_ADD("wchan", "%u", 0); /* XXX */
|
2000-12-09 13:25:54 +00:00
|
|
|
|
PS_ADD("nswap", "%lu", (long unsigned)0); /* XXX */
|
|
|
|
|
PS_ADD("cnswap", "%lu", (long unsigned)0); /* XXX */
|
|
|
|
|
PS_ADD("exitsignal", "%d", 0); /* XXX */
|
|
|
|
|
PS_ADD("processor", "%d", 0); /* XXX */
|
2000-10-25 22:12:59 +00:00
|
|
|
|
#undef PS_ADD
|
|
|
|
|
ps += sprintf(ps, "\n");
|
|
|
|
|
|
|
|
|
|
xlen = ps - psbuf;
|
|
|
|
|
xlen -= uio->uio_offset;
|
|
|
|
|
ps = psbuf + uio->uio_offset;
|
|
|
|
|
xlen = imin(xlen, uio->uio_resid);
|
|
|
|
|
return (xlen <= 0 ? 0 : uiomove(ps, xlen, uio));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Map process state to descriptive letter. Note that this does not
|
|
|
|
|
* quite correspond to what Linux outputs, but it's close enough.
|
|
|
|
|
*/
|
|
|
|
|
static char *state_str[] = {
|
|
|
|
|
"? (unknown)",
|
|
|
|
|
"I (idle)",
|
|
|
|
|
"R (running)",
|
|
|
|
|
"S (sleeping)",
|
|
|
|
|
"T (stopped)",
|
|
|
|
|
"Z (zombie)",
|
|
|
|
|
"W (waiting)",
|
|
|
|
|
"M (mutex)"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linprocfs_doprocstatus(curp, p, pfs, uio)
|
|
|
|
|
struct proc *curp;
|
|
|
|
|
struct proc *p;
|
|
|
|
|
struct pfsnode *pfs;
|
|
|
|
|
struct uio *uio;
|
|
|
|
|
{
|
2000-12-09 13:25:54 +00:00
|
|
|
|
struct eproc ep;
|
2000-10-25 22:12:59 +00:00
|
|
|
|
char *ps, psbuf[1024];
|
|
|
|
|
char *state;
|
|
|
|
|
int i, xlen;
|
2000-12-09 13:25:54 +00:00
|
|
|
|
segsz_t lsize;
|
2000-10-25 22:12:59 +00:00
|
|
|
|
|
|
|
|
|
ps = psbuf;
|
|
|
|
|
|
2000-12-01 06:34:19 +00:00
|
|
|
|
mtx_enter(&sched_lock, MTX_SPIN);
|
2000-10-25 22:12:59 +00:00
|
|
|
|
if (p->p_stat > sizeof state_str / sizeof *state_str)
|
|
|
|
|
state = state_str[0];
|
|
|
|
|
else
|
|
|
|
|
state = state_str[(int)p->p_stat];
|
2000-12-01 06:34:19 +00:00
|
|
|
|
mtx_exit(&sched_lock, MTX_SPIN);
|
2000-10-25 22:12:59 +00:00
|
|
|
|
|
2000-12-09 13:25:54 +00:00
|
|
|
|
fill_eproc(p, &ep);
|
2000-10-25 22:12:59 +00:00
|
|
|
|
#define PS_ADD ps += sprintf
|
|
|
|
|
PS_ADD(ps, "Name:\t%s\n", p->p_comm); /* XXX escape */
|
|
|
|
|
PS_ADD(ps, "State:\t%s\n", state);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Credentials
|
|
|
|
|
*/
|
|
|
|
|
PS_ADD(ps, "Pid:\t%d\n", p->p_pid);
|
2000-11-06 03:23:56 +00:00
|
|
|
|
PS_ADD(ps, "PPid:\t%d\n", p->p_pptr ? p->p_pptr->p_pid : 0);
|
2000-10-25 22:12:59 +00:00
|
|
|
|
PS_ADD(ps, "Uid:\t%d %d %d %d\n", p->p_cred->p_ruid,
|
|
|
|
|
p->p_ucred->cr_uid,
|
|
|
|
|
p->p_cred->p_svuid,
|
|
|
|
|
/* FreeBSD doesn't have fsuid */
|
|
|
|
|
p->p_ucred->cr_uid);
|
|
|
|
|
PS_ADD(ps, "Gid:\t%d %d %d %d\n", p->p_cred->p_rgid,
|
|
|
|
|
p->p_ucred->cr_gid,
|
|
|
|
|
p->p_cred->p_svgid,
|
|
|
|
|
/* FreeBSD doesn't have fsgid */
|
|
|
|
|
p->p_ucred->cr_gid);
|
|
|
|
|
PS_ADD(ps, "Groups:\t");
|
|
|
|
|
for (i = 0; i < p->p_ucred->cr_ngroups; i++)
|
|
|
|
|
PS_ADD(ps, "%d ", p->p_ucred->cr_groups[i]);
|
|
|
|
|
PS_ADD(ps, "\n");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Memory
|
2000-12-09 13:25:54 +00:00
|
|
|
|
*
|
|
|
|
|
* While our approximation of VmLib may not be accurate (I
|
|
|
|
|
* don't know of a simple way to verify it, and I'm not sure
|
|
|
|
|
* it has much meaning anyway), I believe it's good enough.
|
|
|
|
|
*
|
|
|
|
|
* The same code that could (I think) accurately compute VmLib
|
|
|
|
|
* could also compute VmLck, but I don't really care enough to
|
|
|
|
|
* implement it. Submissions are welcome.
|
2000-10-25 22:12:59 +00:00
|
|
|
|
*/
|
2000-12-09 13:25:54 +00:00
|
|
|
|
PS_ADD(ps, "VmSize:\t%8u kB\n", B2K(ep.e_vm.vm_map.size));
|
2000-10-25 22:12:59 +00:00
|
|
|
|
PS_ADD(ps, "VmLck:\t%8u kB\n", P2K(0)); /* XXX */
|
2000-12-09 13:25:54 +00:00
|
|
|
|
PS_ADD(ps, "VmRss:\t%8u kB\n", P2K(ep.e_vm.vm_rssize));
|
|
|
|
|
PS_ADD(ps, "VmData:\t%8u kB\n", P2K(ep.e_vm.vm_dsize));
|
|
|
|
|
PS_ADD(ps, "VmStk:\t%8u kB\n", P2K(ep.e_vm.vm_ssize));
|
|
|
|
|
PS_ADD(ps, "VmExe:\t%8u kB\n", P2K(ep.e_vm.vm_tsize));
|
|
|
|
|
lsize = B2P(ep.e_vm.vm_map.size) - ep.e_vm.vm_dsize -
|
|
|
|
|
ep.e_vm.vm_ssize - ep.e_vm.vm_tsize - 1;
|
|
|
|
|
PS_ADD(ps, "VmLib:\t%8u kB\n", P2K(lsize));
|
2000-10-25 22:12:59 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Signal masks
|
|
|
|
|
*
|
|
|
|
|
* We support up to 128 signals, while Linux supports 32,
|
|
|
|
|
* but we only define 32 (the same 32 as Linux, to boot), so
|
|
|
|
|
* just show the lower 32 bits of each mask. XXX hack.
|
|
|
|
|
*
|
|
|
|
|
* NB: on certain platforms (Sparc at least) Linux actually
|
|
|
|
|
* supports 64 signals, but this code is a long way from
|
|
|
|
|
* running on anything but i386, so ignore that for now.
|
|
|
|
|
*/
|
|
|
|
|
PS_ADD(ps, "SigPnd:\t%08x\n", p->p_siglist.__bits[0]);
|
2000-12-09 13:25:54 +00:00
|
|
|
|
/*
|
|
|
|
|
* I can't seem to find out where the signal mask is in
|
|
|
|
|
* relation to struct proc, so SigBlk is left unimplemented.
|
|
|
|
|
*/
|
2000-10-25 22:12:59 +00:00
|
|
|
|
PS_ADD(ps, "SigBlk:\t%08x\n", 0); /* XXX */
|
|
|
|
|
PS_ADD(ps, "SigIgn:\t%08x\n", p->p_sigignore.__bits[0]);
|
|
|
|
|
PS_ADD(ps, "SigCgt:\t%08x\n", p->p_sigcatch.__bits[0]);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linux also prints the capability masks, but we don't have
|
|
|
|
|
* capabilities yet, and when we do get them they're likely to
|
|
|
|
|
* be meaningless to Linux programs, so we lie. XXX
|
|
|
|
|
*/
|
|
|
|
|
PS_ADD(ps, "CapInh:\t%016x\n", 0);
|
|
|
|
|
PS_ADD(ps, "CapPrm:\t%016x\n", 0);
|
|
|
|
|
PS_ADD(ps, "CapEff:\t%016x\n", 0);
|
|
|
|
|
#undef PS_ADD
|
|
|
|
|
|
|
|
|
|
xlen = ps - psbuf;
|
|
|
|
|
xlen -= uio->uio_offset;
|
|
|
|
|
ps = psbuf + uio->uio_offset;
|
|
|
|
|
xlen = imin(xlen, uio->uio_resid);
|
|
|
|
|
return (xlen <= 0 ? 0 : uiomove(ps, xlen, uio));
|
|
|
|
|
}
|