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));
This commit is contained in:
Martin Baulig
1998-10-26 09:53:08 +00:00
parent 65e3bf19ab
commit bdc4e08454
35 changed files with 575 additions and 26 deletions

View File

@@ -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

View File

@@ -1,3 +1,7 @@
1998-10-26 Martin Baulig <martin@home-of-linux.org>
* procargs.c: New file to get command line arguments.
1998-10-25 Martin Baulig <martin@home-of-linux.org>
* ppp.c: New file to get PPP/ISDN statistics. Currently this only

View File

@@ -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)

View File

@@ -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)

View File

@@ -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 <jsled@xcf.berkeley.edu>, 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 <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/xmalloc.h>
#include <glibtop/procargs.h>
#include <glibtop_suid.h>
#include <kvm.h>
#include <sys/param.h>
#include <sys/proc.h>
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;
}

View File

@@ -1,3 +1,7 @@
1998-10-26 Martin Baulig <martin@home-of-linux.org>
* procargs.c: New file. Currently empty.
1998-10-25 Martin Baulig <martin@home-of-linux.org>
* ppp.c: New file. Currently empty.

View File

@@ -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)

45
sysdeps/kernel/procargs.c Normal file
View File

@@ -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 <jsled@xcf.berkeley.edu>, 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 <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/xmalloc.h>
#include <glibtop/procargs.h>
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;
}

View File

@@ -1,3 +1,7 @@
1998-10-26 Martin Baulig <martin@home-of-linux.org>
* procargs.c: New file. Currently empty.
1998-10-25 Martin Baulig <martin@home-of-linux.org>
* ppp.c: New file. Currently empty.

View File

@@ -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)

45
sysdeps/linux/procargs.c Normal file
View File

@@ -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 <jsled@xcf.berkeley.edu>, 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 <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/xmalloc.h>
#include <glibtop/procargs.h>
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;
}

View File

@@ -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)

42
sysdeps/names/procargs.c Normal file
View File

@@ -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 <martin@home-of-linux.org>, 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 <glibtop/procargs.h>
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.")
};

View File

@@ -1,3 +1,7 @@
1998-10-26 Martin Baulig <martin@home-of-linux.org>
* procargs.c: New file.
1998-10-25 Martin Baulig <martin@home-of-linux.org>
* ppp.c: New file.

View File

@@ -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)

45
sysdeps/stub/procargs.c Normal file
View File

@@ -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 <jsled@xcf.berkeley.edu>, 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 <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/xmalloc.h>
#include <glibtop/procargs.h>
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;
}

View File

@@ -1,3 +1,8 @@
1998-10-26 Martin Baulig <martin@home-of-linux.org>
* procargs.c: New file.
* procmap.c: New file.
1998-10-25 Martin Baulig <martin@home-of-linux.org>
* ChangeLog: New file.

View File

@@ -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)

View File

@@ -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 <jsled@xcf.berkeley.edu>, 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 <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/xmalloc.h>
#include <glibtop/procargs.h>
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;
}

View File

@@ -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 <jsled@xcf.berkeley.edu>, 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 <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/xmalloc.h>
#include <glibtop/procmap.h>
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;
}