*** empty log message ***

This commit is contained in:
Martin Baulig
1998-08-16 13:40:15 +00:00
parent b40e08fb74
commit 77f56522c5
6 changed files with 106 additions and 7 deletions

View File

@@ -7,6 +7,20 @@
#define NR_TASKS 512
#endif
#define TABLE_KERN_PROC_ALL 0 /* all processes */
#define TABLE_KERN_PROC_PID 1
#define TABLE_KERN_PROC_PGRP 2
#define TABLE_KERN_PROC_SESSION 3
#define TABLE_KERN_PROC_TTY 4
#define TABLE_KERN_PROC_UID 5
#define TABLE_KERN_PROC_RUID 6
#define TABLE_KERN_PROC_MASK 15
#define TABLE_EXCLUDE_IDLE 0x1000
#define TABLE_EXCLUDE_SYSTEM 0x2000
#define TABLE_EXCLUDE_NOTTY 0x4000
#define TABLE_VERSION 0
#define TABLE_CPU 1
#define TABLE_MEM 2
@@ -77,6 +91,11 @@ struct table_uptime
/* Process list. */
struct proclist_args
{
int which, arg;
};
struct table_proclist
{
int nr_running, nr_tasks, last_pid;
@@ -90,6 +109,7 @@ struct table_proc_state
long state;
unsigned long flags;
char comm[16];
int uid, gid;
};
struct table_proc_uid

View File

@@ -189,6 +189,9 @@ sys_table (int type, union table *buf, const void *param)
union table tbl;
struct sysinfo i;
struct task_struct *tsk = NULL;
struct ip_chain *chain;
struct ip_fwkernel *rule;
char devname [9];
int index, err;
pid_t pid;
@@ -219,6 +222,14 @@ sys_table (int type, union table *buf, const void *param)
if (tsk == NULL)
return -ESRCH;
break;
case TABLE_NETACCT:
err = verify_area (VERIFY_READ, param, 5);
if (err)
return err;
copy_from_user (devname, param, 5);
devname [5] = 0;
break;
}
/* Main function dispatcher */
@@ -426,6 +437,24 @@ sys_table (int type, union table *buf, const void *param)
tbl.proc_kernel.wchan = get_wchan (tsk);
break;
case TABLE_NETACCT:
for (chain = ip_fw_chains; chain; chain = chain->next) {
for (rule = chain->chain; rule; rule = rule->next) {
const char *name = rule->ipfw.fw_vianame;
int k;
if (name [0] && !strncmp (param, name, 5))
continue;
for (k = 0; k < NUM_SLOTS; k++) {
tbl.netacct.packets +=
rule->counters[k].pcnt;
tbl.netacct.bytes +=
rule->counters[k].bcnt;
}
}
}
break;
default:
return -EINVAL;
}

View File

@@ -304,8 +304,9 @@ table_fkt (int type, union table *buf, const void *param)
union table tbl;
struct sysinfo i;
struct task_struct *tsk = NULL;
struct proclist_args plistargs;
int index, tindex, err, tty;
sigset_t sigign, sigcatch;
int index, tindex, err;
pid_t pid;
if (type == TABLE_VERSION)
@@ -339,6 +340,14 @@ table_fkt (int type, union table *buf, const void *param)
if (tsk == NULL)
return -ESRCH;
break;
case TABLE_PROCLIST:
err = verify_area (VERIFY_READ, param,
sizeof (struct proclist_args));
if (err)
return err;
copy_from_user (&plistargs, param,
sizeof (struct proclist_args));
break;
}
/* Main function dispatcher */
@@ -347,10 +356,40 @@ table_fkt (int type, union table *buf, const void *param)
case TABLE_PROCLIST:
tsk = task [0];
read_lock (&tasklist_lock);
for (index = tindex = 0; index < nr_tasks; index++) {
if (tsk->pid)
for (index = tindex = 0; index < nr_tasks;
index++, tsk = tsk->next_task) {
if (tsk->pid == 0) continue;
switch (plistargs.which & TABLE_KERN_PROC_MASK) {
case TABLE_KERN_PROC_PID:
if (tsk->pid != plistargs.arg) continue;
break;
case TABLE_KERN_PROC_PGRP:
if (tsk->pgrp != plistargs.arg) continue;
break;
case TABLE_KERN_PROC_SESSION:
if (tsk->session != plistargs.arg) continue;
case TABLE_KERN_PROC_TTY:
tty = tsk->tty ?
kdev_t_to_nr (tsk->tty->device) : 0;
if (tty != plistargs.arg) continue;
break;
case TABLE_KERN_PROC_UID:
if (tsk->uid != plistargs.arg) continue;
break;
case TABLE_KERN_PROC_RUID:
if (tsk->euid != plistargs.arg) continue;
break;
}
if ((plistargs.which & TABLE_EXCLUDE_IDLE) &&
(tsk->state != 0))
continue;
if ((plistargs.which & TABLE_EXCLUDE_NOTTY) &&
(tsk->tty == NULL))
continue;
tbl.proclist.pids [tindex++] = tsk->pid;
tsk = tsk->next_task;
}
tbl.proclist.nr_running = nr_running;
tbl.proclist.last_pid = last_pid;
@@ -395,6 +434,8 @@ table_fkt (int type, union table *buf, const void *param)
task[0]->times.tms_stime;
break;
case TABLE_PROC_STATE:
tbl.proc_state.uid = tsk->uid;
tbl.proc_state.gid = tsk->gid;
tbl.proc_state.state = tsk->state;
tbl.proc_state.flags = tsk->flags;
memcpy (tbl.proc_state.comm, tsk->comm,

1
kernel/version.h Normal file
View File

@@ -0,0 +1 @@
#define _TABLE_VERSION 1

View File

@@ -59,12 +59,16 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
{
union table tbl;
unsigned *pids_chain;
struct proclist_args args;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROCLIST, 0);
memset (buf, 0, sizeof (glibtop_proclist));
if (table (TABLE_PROCLIST, &tbl, NULL))
args.which = which;
args.arg = arg;
if (table (TABLE_PROCLIST, &tbl, &args))
glibtop_error_io_r (server, "table(TABLE_PROCLIST)");
buf->size = sizeof (unsigned);

View File

@@ -26,7 +26,8 @@
#include "kernel.h"
static const unsigned long _glibtop_sysdeps_proc_state =
(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_STATE);
(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_STATE) +
(1 << GLIBTOP_PROC_STATE_UID) + (1 << GLIBTOP_PROC_STATE_GID);
/* Init function. */
@@ -60,6 +61,9 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf,
memcpy (buf->cmd, tbl.proc_state.comm, sizeof (tbl.proc_state.comm));
buf->uid = tbl.proc_state.uid;
buf->gid = tbl.proc_state.state;
state = (unsigned) tbl.proc_state.state;
if (state >= NR_STATES)