From bdc4e08454cb6d175f4e6e36e5a63aa46dae09b5 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 26 Oct 1998 09:53:08 +0000 Subject: [PATCH] Added new feature (proc_args) to get command line arguments: typedef struct _glibtop_proc_args glibtop_proc_args; struct _glibtop_proc_args { u_int64_t flags, size; /* GLIBTOP_PROC_ARGS_SIZE */ }; Returns a string containing all command line arguments of the process, the `unsigned' parameter is the maximum length of this string; if it is zero then no limit will be set. extern const char *glibtop_get_proc_args_l __P((glibtop *, glibtop_proc_args *, pid_t, unsigned)); --- ChangeLog | 10 ++++ examples/ChangeLog | 5 ++ examples/first.c | 35 +++++++++++- examples/second.c | 12 +++++ features.def | 1 + include/glibtop/Makefile.am | 2 +- include/glibtop/command.h | 11 ++-- include/glibtop/procargs.h | 73 +++++++++++++++++++++++++ include/glibtop/sysdeps.h | 12 +++-- include/glibtop/union.h | 2 + lib/lib.awk | 11 ++-- lib/sysdeps.c | 3 ++ src/daemon/main.c | 9 +++- src/daemon/server.c | 1 + src/daemon/slave.c | 17 +++++- sysdeps/common/sysdeps_suid.c | 3 ++ sysdeps/freebsd/ChangeLog | 4 ++ sysdeps/freebsd/Makefile.am | 2 +- sysdeps/freebsd/glibtop_server.h | 1 + sysdeps/freebsd/procargs.c | 91 ++++++++++++++++++++++++++++++++ sysdeps/kernel/ChangeLog | 4 ++ sysdeps/kernel/Makefile.am | 3 +- sysdeps/kernel/procargs.c | 45 ++++++++++++++++ sysdeps/linux/ChangeLog | 4 ++ sysdeps/linux/Makefile.am | 4 +- sysdeps/linux/procargs.c | 45 ++++++++++++++++ sysdeps/names/Makefile.am | 2 +- sysdeps/names/procargs.c | 42 +++++++++++++++ sysdeps/stub/ChangeLog | 4 ++ sysdeps/stub/Makefile.am | 2 +- sysdeps/stub/procargs.c | 45 ++++++++++++++++ sysdeps/stub_suid/ChangeLog | 5 ++ sysdeps/stub_suid/Makefile.am | 2 +- sysdeps/stub_suid/procargs.c | 45 ++++++++++++++++ sysdeps/stub_suid/procmap.c | 44 +++++++++++++++ 35 files changed, 575 insertions(+), 26 deletions(-) create mode 100644 include/glibtop/procargs.h create mode 100644 sysdeps/freebsd/procargs.c create mode 100644 sysdeps/kernel/procargs.c create mode 100644 sysdeps/linux/procargs.c create mode 100644 sysdeps/names/procargs.c create mode 100644 sysdeps/stub/procargs.c create mode 100644 sysdeps/stub_suid/procargs.c create mode 100644 sysdeps/stub_suid/procmap.c diff --git a/ChangeLog b/ChangeLog index 09681f92..47a0e905 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +1998-10-26 Martin Baulig + + Added `Command Line Parameters' feature (proc_args). + + * include/glibtop/proc_args.h: New file. + * features.def: Added new feature `proc_args'. + + * lib/lib.awk: New type `unsigned' for the features.def which + is `unsigned'. + 1998-10-25 Martin Baulig Added PPP/ISDN support. diff --git a/examples/ChangeLog b/examples/ChangeLog index 1d8905ba..0931a08b 100644 --- a/examples/ChangeLog +++ b/examples/ChangeLog @@ -1,3 +1,8 @@ +1998-10-26 Martin Baulig + + * first.c (glibtop_get_proc_args): Get command line arguments. + * second.c: Likewise. + 1998-10-25 Martin Baulig * first.c (glibtop_get_ppp): Get PPP/ISDN statistics. diff --git a/examples/first.c b/examples/first.c index 547b78a0..87b69a6f 100644 --- a/examples/first.c +++ b/examples/first.c @@ -43,7 +43,7 @@ main (int argc, char *argv []) glibtop_union data; glibtop_sysdeps sysdeps; unsigned c, method, count, port, i, *ptr; - char buffer [BUFSIZ]; + char buffer [BUFSIZ], *args; pid_t pid, ppid; count = PROFILE_COUNT; @@ -324,6 +324,17 @@ main (int argc, char *argv []) printf ("\n"); + args = glibtop_get_proc_args (&data.proc_args, pid, 0); + + printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", (int) pid, + (unsigned long) data.proc_args.flags, + (unsigned long) data.proc_args.size, + args); + + glibtop_free (args); + + printf ("\n"); + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_state (&data.proc_state, ppid); @@ -418,6 +429,17 @@ main (int argc, char *argv []) printf ("\n"); + args = glibtop_get_proc_args (&data.proc_args, ppid, 0); + + printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", (int) ppid, + (unsigned long) data.proc_args.flags, + (unsigned long) data.proc_args.size, + args); + + glibtop_free (args); + + printf ("\n"); + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_state (&data.proc_state, 1); @@ -511,6 +533,17 @@ main (int argc, char *argv []) (unsigned long) data.proc_kernel.nwchan, data.proc_kernel.wchan); + printf ("\n"); + + args = glibtop_get_proc_args (&data.proc_args, 1, 0); + + printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", 1, + (unsigned long) data.proc_args.flags, + (unsigned long) data.proc_args.size, + args); + + glibtop_free (args); + glibtop_close (); exit (0); diff --git a/examples/second.c b/examples/second.c index 96b8e0b4..faa658fa 100644 --- a/examples/second.c +++ b/examples/second.c @@ -35,6 +35,7 @@ static void output (pid_t pid) { glibtop_union data; + char *args; #if HAVE_LIBGTOP_SMP unsigned long total; double p_total, p_utime, p_stime; @@ -135,6 +136,17 @@ output (pid_t pid) printf ("\n"); + args = glibtop_get_proc_args (&data.proc_args, pid, 0); + + printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", (int) pid, + (unsigned long) data.proc_args.flags, + (unsigned long) data.proc_args.size, + args); + + glibtop_free (args); + + printf ("\n"); + #if HAVE_LIBGTOP_SMP ncpu = glibtop_global_server->ncpu; diff --git a/features.def b/features.def index 170f3e4d..6480dac8 100644 --- a/features.def +++ b/features.def @@ -14,6 +14,7 @@ void|proc_time|long(start_time,rtime,utime,stime,cutime,cstime,timeout,it_real_v void|proc_signal|ulong(signal[2],blocked[2],sigignore[2],sigcatch[2])|pid_t(pid) void|proc_kernel|ulong(k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt,kstk_esp,kstk_eip,nwchan):str(wchan)|pid_t(pid) void|proc_segment|ulong(text_rss,shlib_rss,data_rss,stack_rss,dirty_size,start_code,end_code,start_stack)|pid_t(pid) +const char *|proc_args|ulong(size)|pid_t(pid):unsigned(max_len) glibtop_map_entry *|proc_map|ulong(number,size,total)|pid_t(pid) glibtop_mountentry *|@mountlist|ulong(number,size,total)|int(all_fs) void|@fsusage|ulong(blocks,bfree,bavail,files,ffree)|string|mount_dir diff --git a/include/glibtop/Makefile.am b/include/glibtop/Makefile.am index 95558e52..35ef25dd 100644 --- a/include/glibtop/Makefile.am +++ b/include/glibtop/Makefile.am @@ -7,4 +7,4 @@ glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \ procsegment.h read.h sysdeps.h xmalloc.h global.h \ procsignal.h read_data.h union.h types.h gnuserv.h \ parameter.h mountlist.h fsusage.h procmap.h signal.h \ - inodedb.h sysinfo.h ppp.h + inodedb.h sysinfo.h ppp.h procargs.h diff --git a/include/glibtop/command.h b/include/glibtop/command.h index f543b842..9064e3df 100644 --- a/include/glibtop/command.h +++ b/include/glibtop/command.h @@ -48,13 +48,14 @@ __BEGIN_DECLS #define GLIBTOP_CMND_PROC_SIGNAL 15 #define GLIBTOP_CMND_PROC_KERNEL 16 #define GLIBTOP_CMND_PROC_SEGMENT 17 -#define GLIBTOP_CMND_PROC_MAP 18 +#define GLIBTOP_CMND_PROC_ARGS 18 +#define GLIBTOP_CMND_PROC_MAP 19 -#define GLIBTOP_CMND_MOUNTLIST 19 -#define GLIBTOP_CMND_FSUSAGE 20 -#define GLIBTOP_CMND_PPP 21 +#define GLIBTOP_CMND_MOUNTLIST 20 +#define GLIBTOP_CMND_FSUSAGE 21 +#define GLIBTOP_CMND_PPP 22 -#define GLIBTOP_MAX_CMND 22 +#define GLIBTOP_MAX_CMND 23 #define _GLIBTOP_PARAM_SIZE 16 diff --git a/include/glibtop/procargs.h b/include/glibtop/procargs.h new file mode 100644 index 00000000..1ec6f5b7 --- /dev/null +++ b/include/glibtop/procargs.h @@ -0,0 +1,73 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef __GLIBTOP_PROC_ARGS_H__ +#define __GLIBTOP_PROC_ARGS_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_PROC_ARGS_SIZE 0 + +#define GLIBTOP_MAX_PROC_ARGS 1 + +typedef struct _glibtop_proc_args glibtop_proc_args; + +struct _glibtop_proc_args +{ + u_int64_t flags, + size; /* GLIBTOP_PROC_ARGS_SIZE */ +}; + +#define glibtop_get_proc_args(proc_args,pid,max_len) glibtop_get_proc_args_l(glibtop_global_server, proc_args, pid, max_len) + +#if GLIBTOP_SUID_PROC_ARGS +#define glibtop_get_proc_args_r glibtop_get_proc_args_p +#else +#define glibtop_get_proc_args_r glibtop_get_proc_args_s +#endif + +extern const char *glibtop_get_proc_args_l __P((glibtop *, glibtop_proc_args *, pid_t, unsigned)); + +#if GLIBTOP_SUID_PROC_ARGS +extern void glibtop_init_proc_args_p __P((glibtop *)); +extern const char *glibtop_get_proc_args_p __P((glibtop *, glibtop_proc_args *, pid_t, unsigned)); +#else +extern void glibtop_init_proc_args_s __P((glibtop *)); +extern const char *glibtop_get_proc_args_s __P((glibtop *, glibtop_proc_args *, pid_t, unsigned)); +#endif + +#ifdef GLIBTOP_NAMES + +/* You need to link with -lgtop_names to get this stuff here. */ + +extern const char *glibtop_names_proc_args []; +extern const unsigned glibtop_types_proc_args []; +extern const char *glibtop_labels_proc_args []; +extern const char *glibtop_descriptions_proc_args []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/sysdeps.h b/include/glibtop/sysdeps.h index 1d94bbab..9ec277b9 100644 --- a/include/glibtop/sysdeps.h +++ b/include/glibtop/sysdeps.h @@ -43,12 +43,13 @@ __BEGIN_DECLS #define GLIBTOP_SYSDEPS_PROC_SIGNAL 14 #define GLIBTOP_SYSDEPS_PROC_KERNEL 15 #define GLIBTOP_SYSDEPS_PROC_SEGMENT 16 -#define GLIBTOP_SYSDEPS_PROC_MAP 17 -#define GLIBTOP_SYSDEPS_MOUNTLIST 18 -#define GLIBTOP_SYSDEPS_FSUSAGE 19 -#define GLIBTOP_SYSDEPS_PPP 20 +#define GLIBTOP_SYSDEPS_PROC_ARGS 17 +#define GLIBTOP_SYSDEPS_PROC_MAP 18 +#define GLIBTOP_SYSDEPS_MOUNTLIST 19 +#define GLIBTOP_SYSDEPS_FSUSAGE 20 +#define GLIBTOP_SYSDEPS_PPP 21 -#define GLIBTOP_MAX_SYSDEPS 21 +#define GLIBTOP_MAX_SYSDEPS 22 #define GLIBTOP_SYSDEPS_ALL ((1 << GLIBTOP_MAX_SYSDEPS) - 1) @@ -78,6 +79,7 @@ struct _glibtop_sysdeps proc_signal, /* glibtop_proc_signal */ proc_kernel, /* glibtop_proc_kernel */ proc_segment, /* glibtop_proc_segment */ + proc_args, /* glibtop_proc_args */ proc_map, /* glibtop_proc_map */ mountlist, /* glibtop_mountlist */ fsusage, /* glibtop_fsusage */ diff --git a/include/glibtop/union.h b/include/glibtop/union.h index aa420f2f..68e30e2e 100644 --- a/include/glibtop/union.h +++ b/include/glibtop/union.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -68,6 +69,7 @@ union _glibtop_union glibtop_proc_signal proc_signal; glibtop_proc_kernel proc_kernel; glibtop_proc_segment proc_segment; + glibtop_proc_args proc_args; glibtop_proc_map proc_map; glibtop_mountlist mountlist; glibtop_fsusage fsusage; diff --git a/lib/lib.awk b/lib/lib.awk index 4937b0a3..31a07008 100644 --- a/lib/lib.awk +++ b/lib/lib.awk @@ -41,11 +41,12 @@ BEGIN { print "/* Library functions. */"; print ""; - convert["long"] = "int64_t"; - convert["ulong"] = "u_int64_t"; - convert["pid_t"] = "pid_t"; - convert["int"] = "int"; - convert["ushort"] = "unsigned short"; + convert["long"] = "int64_t"; + convert["ulong"] = "u_int64_t"; + convert["pid_t"] = "pid_t"; + convert["int"] = "int"; + convert["ushort"] = "unsigned short"; + convert["unsigned"] = "unsigned"; } function output(line) { diff --git a/lib/sysdeps.c b/lib/sysdeps.c index c7052166..da147d6a 100644 --- a/lib/sysdeps.c +++ b/lib/sysdeps.c @@ -90,6 +90,9 @@ glibtop_init_func_t _glibtop_init_hook_s [] = { #if !GLIBTOP_SUID_PROC_SEGMENT glibtop_init_proc_segment_s, #endif +#if !GLIBTOP_SUID_PROC_ARGS + glibtop_init_proc_args_s, +#endif #if !GLIBTOP_SUID_PROC_MAP glibtop_init_proc_map_s, #endif diff --git a/src/daemon/main.c b/src/daemon/main.c index 69c2caf4..3eddfee8 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -29,6 +29,7 @@ handle_parent_connection (int s) glibtop_command _cmnd, *cmnd = &_cmnd; glibtop_mountentry *mount_list; char parameter [BUFSIZ]; + unsigned short device; int64_t *param_ptr; int all_fs; pid_t pid; @@ -193,7 +194,7 @@ handle_parent_connection (int s) do_output (s, resp, _offset_data (proc_segment), 0, NULL); break; case GLIBTOP_CMND_MOUNTLIST: - memcpy (&all_fs, parameter, sizeof (all_fs)); + memcpy (&all_fs, parameter, sizeof (all_fs)); mount_list = glibtop_get_mountlist_l (server, &resp->u.data.mountlist, all_fs); do_output (s, resp, _offset_data (mountlist), @@ -206,6 +207,12 @@ handle_parent_connection (int s) do_output (s, resp, _offset_data (fsusage), 0, NULL); break; + case GLIBTOP_CMND_PPP: + memcpy (&device, parameter, sizeof (device)); + glibtop_get_ppp_l + (server, &resp->u.data.ppp, device); + do_output (s, resp, _offset_data (ppp), 0, NULL); + break; default: glibtop_warn ("Parent received unknown command %u", cmnd->command); diff --git a/src/daemon/server.c b/src/daemon/server.c index bd05e548..aac4cf74 100644 --- a/src/daemon/server.c +++ b/src/daemon/server.c @@ -45,6 +45,7 @@ GLIBTOP_SUID_PROC_TIME + GLIBTOP_SUID_PROC_SIGNAL + GLIBTOP_SUID_PROC_KERNEL + GLIBTOP_SUID_PROC_SEGMENT + +GLIBTOP_SUID_PROC_ARGS + GLIBTOP_SUID_PROC_MAP + GLIBTOP_SUID_PPP; diff --git a/src/daemon/slave.c b/src/daemon/slave.c index 5fdaac49..bf83c30f 100644 --- a/src/daemon/slave.c +++ b/src/daemon/slave.c @@ -27,6 +27,8 @@ handle_slave_connection (int input, int output) glibtop *server = glibtop_global_server; int64_t *param_ptr; void *ptr; + + unsigned short max_len; pid_t pid; glibtop_response _resp, *resp = &_resp; @@ -77,6 +79,19 @@ handle_slave_connection (int input, int output) glibtop_free_r (server, ptr); break; #endif +#if GLIBTOP_SUID_PROC_ARGS + case GLIBTOP_CMND_PROC_ARGS: + memcpy (&pid, parameter, sizeof (pid_t)); + memcpy (&max_len, parameter + sizeof (pid_t), + sizeof (max_len)); + ptr = glibtop_get_proc_args_p (server, + &resp->u.data.proc_args, + pid, max_len); + do_output (output, resp, _offset_data (proc_args), + resp->u.data.proc_args.size, ptr); + glibtop_free_r (server, ptr); + break; +#endif #if GLIBTOP_SUID_PROC_MAP case GLIBTOP_CMND_PROC_MAP: memcpy (&pid, parameter, sizeof (pid_t)); @@ -101,7 +116,7 @@ handle_slave_command (glibtop_command *cmnd, glibtop_response *resp, const void *parameter) { glibtop *server = glibtop_global_server; - unsigned short device; + unsigned device; pid_t pid; switch (cmnd->command) { diff --git a/sysdeps/common/sysdeps_suid.c b/sysdeps/common/sysdeps_suid.c index 05c6224e..dea87167 100644 --- a/sysdeps/common/sysdeps_suid.c +++ b/sysdeps/common/sysdeps_suid.c @@ -71,6 +71,9 @@ glibtop_init_func_t _glibtop_init_hook_p [] = { #if GLIBTOP_SUID_PROC_SEGMENT glibtop_init_proc_segment_p, #endif +#if GLIBTOP_SUID_PROC_ARGS + glibtop_init_proc_args_p, +#endif #if GLIBTOP_SUID_PROC_MAP glibtop_init_proc_map_p, #endif diff --git a/sysdeps/freebsd/ChangeLog b/sysdeps/freebsd/ChangeLog index d2f847ac..17bb517a 100644 --- a/sysdeps/freebsd/ChangeLog +++ b/sysdeps/freebsd/ChangeLog @@ -1,3 +1,7 @@ +1998-10-26 Martin Baulig + + * procargs.c: New file to get command line arguments. + 1998-10-25 Martin Baulig * ppp.c: New file to get PPP/ISDN statistics. Currently this only diff --git a/sysdeps/freebsd/Makefile.am b/sysdeps/freebsd/Makefile.am index 7d508540..0e84b8ff 100644 --- a/sysdeps/freebsd/Makefile.am +++ b/sysdeps/freebsd/Makefile.am @@ -10,7 +10,7 @@ libgtop_sysdeps_suid_la_SOURCES = open.c close.c siglist.c cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c procmap.c ppp.c + procsegment.c procargs.c procmap.c ppp.c libgtop_sysdeps_suid_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/freebsd/glibtop_server.h b/sysdeps/freebsd/glibtop_server.h index 8ade7f5f..a87a1ffb 100644 --- a/sysdeps/freebsd/glibtop_server.h +++ b/sysdeps/freebsd/glibtop_server.h @@ -40,6 +40,7 @@ __BEGIN_DECLS #define GLIBTOP_SUID_PROC_SIGNAL (1 << GLIBTOP_SYSDEPS_PROC_SIGNAL) #define GLIBTOP_SUID_PROC_KERNEL (1 << GLIBTOP_SYSDEPS_PROC_KERNEL) #define GLIBTOP_SUID_PROC_SEGMENT (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT) +#define GLIBTOP_SUID_PROC_ARGS (1 << GLIBTOP_SYSDEPS_PROC_ARGS) #define GLIBTOP_SUID_PROC_MAP (1 << GLIBTOP_SYSDEPS_PROC_MAP) #define GLIBTOP_SUID_PPP (1 << GLIBTOP_SYSDEPS_PPP) diff --git a/sysdeps/freebsd/procargs.c b/sysdeps/freebsd/procargs.c new file mode 100644 index 00000000..e7d00e40 --- /dev/null +++ b/sysdeps/freebsd/procargs.c @@ -0,0 +1,91 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Joshua Sled , July 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include + +#include + +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_proc_args = +(1 << GLIBTOP_PROC_ARGS_SIZE); + +/* Init function. */ + +void +glibtop_init_proc_args_p (glibtop *server) +{ + server->sysdeps.proc_args = _glibtop_sysdeps_proc_args; +} + +/* Provides detailed information about a process. */ + +const char * +glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf, + pid_t pid, unsigned max_len) +{ + struct kinfo_proc *pinfo; + char *retval, **args, **ptr; + unsigned size = 0; + int count; + + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_ARGS), 0); + + memset (buf, 0, sizeof (glibtop_proc_args)); + + glibtop_suid_enter (server); + + /* Get the process data */ + pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count); + if ((pinfo == NULL) || (count < 1)) + glibtop_error_io_r (server, "kvm_getprocs (proc_args)"); + + args = kvm_getargv (server->machine.kd, pinfo, max_len); + if (args == NULL) { + glibtop_warn_io_r (server, "kvm_getargv"); + glibtop_suid_leave (server); + return NULL; + } + + glibtop_suid_leave (server); + + for (ptr = args; *ptr; ptr++) + size += strlen (*ptr)+1; + + buf->size = size+2; + + retval = glibtop_malloc_r (server, buf->size); + memset (retval, 0, buf->size); + + for (ptr = args; *ptr; ptr++) { + if (*retval) strcat (retval, " "); + strcat (retval, *ptr); + } + + buf->flags = _glibtop_sysdeps_proc_args; + + return retval; +} diff --git a/sysdeps/kernel/ChangeLog b/sysdeps/kernel/ChangeLog index bbb1ec84..12c7afd7 100644 --- a/sysdeps/kernel/ChangeLog +++ b/sysdeps/kernel/ChangeLog @@ -1,3 +1,7 @@ +1998-10-26 Martin Baulig + + * procargs.c: New file. Currently empty. + 1998-10-25 Martin Baulig * ppp.c: New file. Currently empty. diff --git a/sysdeps/kernel/Makefile.am b/sysdeps/kernel/Makefile.am index 4be82da9..2c17a4c1 100644 --- a/sysdeps/kernel/Makefile.am +++ b/sysdeps/kernel/Makefile.am @@ -8,7 +8,8 @@ libgtop_sysdeps_la_SOURCES = open.c close.c kernel.s cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c siglist.c procmap.c ppp.c + procsegment.c siglist.c procargs.c procmap.c \ + ppp.c libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/kernel/procargs.c b/sysdeps/kernel/procargs.c new file mode 100644 index 00000000..dea49cb4 --- /dev/null +++ b/sysdeps/kernel/procargs.c @@ -0,0 +1,45 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Joshua Sled , July 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_proc_args = 0; + +/* Init function. */ + +void +glibtop_init_proc_args_s (glibtop *server) +{ + server->sysdeps.proc_args = _glibtop_sysdeps_proc_args; +} + +/* Provides detailed information about a process. */ + +const char * +glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf, + pid_t pid, unsigned max_len) +{ + memset (buf, 0, sizeof (glibtop_proc_args)); + return NULL; +} diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog index 789bc8d2..86efa045 100644 --- a/sysdeps/linux/ChangeLog +++ b/sysdeps/linux/ChangeLog @@ -1,3 +1,7 @@ +1998-10-26 Martin Baulig + + * procargs.c: New file. Currently empty. + 1998-10-25 Martin Baulig * ppp.c: New file. Currently empty. diff --git a/sysdeps/linux/Makefile.am b/sysdeps/linux/Makefile.am index 38b33490..fa236d69 100644 --- a/sysdeps/linux/Makefile.am +++ b/sysdeps/linux/Makefile.am @@ -8,8 +8,8 @@ libgtop_sysdeps_la_SOURCES = open.c close.c cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c procmap.c siglist.c sysinfo.c \ - ppp.c + procsegment.c procargs.c procmap.c siglist.c \ + sysinfo.c ppp.c libgtop_sysdeps_la_LIBADD = @GLIB_LIBS@ libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/linux/procargs.c b/sysdeps/linux/procargs.c new file mode 100644 index 00000000..dea49cb4 --- /dev/null +++ b/sysdeps/linux/procargs.c @@ -0,0 +1,45 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Joshua Sled , July 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_proc_args = 0; + +/* Init function. */ + +void +glibtop_init_proc_args_s (glibtop *server) +{ + server->sysdeps.proc_args = _glibtop_sysdeps_proc_args; +} + +/* Provides detailed information about a process. */ + +const char * +glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf, + pid_t pid, unsigned max_len) +{ + memset (buf, 0, sizeof (glibtop_proc_args)); + return NULL; +} diff --git a/sysdeps/names/Makefile.am b/sysdeps/names/Makefile.am index c034b326..93969ff4 100644 --- a/sysdeps/names/Makefile.am +++ b/sysdeps/names/Makefile.am @@ -9,7 +9,7 @@ libgtop_names_la_SOURCES = cpu.c mem.c swap.c uptime.c loadavg.c \ proclist.c sysdeps.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c \ prockernel.c procsegment.c fsusage.c \ - mountlist.c procmap.c ppp.c + mountlist.c procargs.c procmap.c ppp.c libgtop_names_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/names/procargs.c b/sysdeps/names/procargs.c new file mode 100644 index 00000000..82bc7c4d --- /dev/null +++ b/sysdeps/names/procargs.c @@ -0,0 +1,42 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +const char *glibtop_names_proc_args [GLIBTOP_MAX_PROC_ARGS] = +{ + "size" +}; + +const unsigned glibtop_types_proc_args [GLIBTOP_MAX_PROC_ARGS] = +{ + GLIBTOP_TYPE_ULONG +}; + +const char *glibtop_labels_proc_args [GLIBTOP_MAX_PROC_ARGS] = +{ + N_("Size") +}; + +const char *glibtop_descriptions_proc_args [GLIBTOP_MAX_PROC_ARGS] = +{ + N_("Length in bytes of the returned string.") +}; diff --git a/sysdeps/stub/ChangeLog b/sysdeps/stub/ChangeLog index 68ebbf4d..b2166344 100644 --- a/sysdeps/stub/ChangeLog +++ b/sysdeps/stub/ChangeLog @@ -1,3 +1,7 @@ +1998-10-26 Martin Baulig + + * procargs.c: New file. + 1998-10-25 Martin Baulig * ppp.c: New file. diff --git a/sysdeps/stub/Makefile.am b/sysdeps/stub/Makefile.am index e9636df1..549444f0 100644 --- a/sysdeps/stub/Makefile.am +++ b/sysdeps/stub/Makefile.am @@ -8,7 +8,7 @@ libgtop_sysdeps_la_SOURCES = open.c close.c siglist.c cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c procmap.c ppp.c + procsegment.c procargs.c procmap.c ppp.c libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/stub/procargs.c b/sysdeps/stub/procargs.c new file mode 100644 index 00000000..dea49cb4 --- /dev/null +++ b/sysdeps/stub/procargs.c @@ -0,0 +1,45 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Joshua Sled , July 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_proc_args = 0; + +/* Init function. */ + +void +glibtop_init_proc_args_s (glibtop *server) +{ + server->sysdeps.proc_args = _glibtop_sysdeps_proc_args; +} + +/* Provides detailed information about a process. */ + +const char * +glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf, + pid_t pid, unsigned max_len) +{ + memset (buf, 0, sizeof (glibtop_proc_args)); + return NULL; +} diff --git a/sysdeps/stub_suid/ChangeLog b/sysdeps/stub_suid/ChangeLog index 37833c17..e66eacd2 100644 --- a/sysdeps/stub_suid/ChangeLog +++ b/sysdeps/stub_suid/ChangeLog @@ -1,3 +1,8 @@ +1998-10-26 Martin Baulig + + * procargs.c: New file. + * procmap.c: New file. + 1998-10-25 Martin Baulig * ChangeLog: New file. diff --git a/sysdeps/stub_suid/Makefile.am b/sysdeps/stub_suid/Makefile.am index 78acf9d1..55ef0c2d 100644 --- a/sysdeps/stub_suid/Makefile.am +++ b/sysdeps/stub_suid/Makefile.am @@ -12,7 +12,7 @@ libgtop_sysdeps_suid_la_SOURCES = open.c close.c siglist.c cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c ppp.c + procsegment.c procargs.c procmap.c ppp.c libgtop_sysdeps_suid_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/stub_suid/procargs.c b/sysdeps/stub_suid/procargs.c new file mode 100644 index 00000000..7d6b7764 --- /dev/null +++ b/sysdeps/stub_suid/procargs.c @@ -0,0 +1,45 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Joshua Sled , July 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_proc_args = 0; + +/* Init function. */ + +void +glibtop_init_proc_args_p (glibtop *server) +{ + server->sysdeps.proc_args = _glibtop_sysdeps_proc_args; +} + +/* Provides detailed information about a process. */ + +const char * +glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf, + pid_t pid, unsigned max_len) +{ + memset (buf, 0, sizeof (glibtop_proc_args)); + return NULL; +} diff --git a/sysdeps/stub_suid/procmap.c b/sysdeps/stub_suid/procmap.c new file mode 100644 index 00000000..046a4aeb --- /dev/null +++ b/sysdeps/stub_suid/procmap.c @@ -0,0 +1,44 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Joshua Sled , July 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_proc_map = 0; + +/* Init function. */ + +void +glibtop_init_proc_map_p (glibtop *server) +{ + server->sysdeps.proc_map = _glibtop_sysdeps_proc_map; +} + +/* Provides detailed information about a process. */ + +glibtop_map_entry * +glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf, pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_map)); + return NULL; +}