From be9be179a2cde041fbe042362ee80f9874233953 Mon Sep 17 00:00:00 2001 From: antrik Date: Sat, 20 Jun 2009 12:29:06 +0200 Subject: Obtain number of ports in proc and libps Add (and implement) a proc RPC to obtain the number of Mach ports used by the target task. Add infrastructure in libps to read this information. * hurd/process.defs (proc_getnports): New RPC. * hurd/process_request.defs (proc_getnports_request): New RPC. * libps/procstat.c (proc_stat_set_flags): Call proc_getnports RPC if needed. * libps/ps.h (proc_stat): New `num_ports' field. (PSTAT_NUM_PORTS): New macro. (proc_stat_num_ports): New macro. * libps/spec.c (ps_get_num_ports): New function. (ps_num_ports_getter): New variable. (specs): New entry for `ps_num_ports_getter'. * proc/info.c (S_proc_getnports): New function. --- libps/spec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libps/spec.c') diff --git a/libps/spec.c b/libps/spec.c index da1e372a..5499bc15 100644 --- a/libps/spec.c +++ b/libps/spec.c @@ -349,6 +349,14 @@ ps_get_zero_fills (struct proc_stat *ps) const struct ps_getter ps_zero_fills_getter = {"zero_fills", PSTAT_TASK_EVENTS, (vf) ps_get_zero_fills}; +static int +ps_get_num_ports (struct proc_stat *ps) +{ + return proc_stat_num_ports (ps); +} +const struct ps_getter ps_num_ports_getter = +{"num_ports", PSTAT_NUM_PORTS, (vf) ps_get_num_ports}; + /* ---------------------------------------------------------------- */ /* some printing functions */ @@ -1155,6 +1163,8 @@ static const struct ps_fmt_spec specs[] = &ps_msgs_sent_getter, ps_emit_int, ps_cmp_ints, ps_nominal_zint}, {"ZFills", 0, -5, -1, 0, &ps_zero_fills_getter, ps_emit_int, ps_cmp_ints, ps_nominal_zint}, + {"Ports", 0, -5, -1, 0, + &ps_num_ports_getter, ps_emit_int, ps_cmp_ints, 0}, {0} }; -- cgit v1.2.3