diff options
author | Martin Baulig <baulig@suse.de> | 2001-04-20 21:06:35 +0000 |
---|---|---|
committer | Martin Baulig <martin@src.gnome.org> | 2001-04-20 21:06:35 +0000 |
commit | 7a7c6baf5593bba0fe1828687a3b0c6b837b160a (patch) | |
tree | 83f58dc2d2e1e3a6be8323d320175a958345344d /sysdeps | |
parent | 5bfb0850210fe27cba28794d85e0343ef37bb256 (diff) | |
download | libgtop-7a7c6baf5593bba0fe1828687a3b0c6b837b160a.tar.gz |
Moved all sysdeps code to the new libgtop-backends module.
2001-04-20 Martin Baulig <baulig@suse.de>
Moved all sysdeps code to the new libgtop-backends module.
* sysdeps/freesd/*: Removed.
* sysdeps/kernel/*: Removed.
* sysdeps/linux/*: Removed.
* sysdeps/osf1/*: Removed.
* sysdeps/solaris/*: Removed.
* sysdeps/stub/*: Removed.
* sysdeps/stub_suid/*: Removed.
* sysdeps/sun4/*: Removed.
Diffstat (limited to 'sysdeps')
253 files changed, 0 insertions, 21595 deletions
diff --git a/sysdeps/freebsd/.cvsignore b/sysdeps/freebsd/.cvsignore deleted file mode 100644 index 09980ae6..00000000 --- a/sysdeps/freebsd/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la diff --git a/sysdeps/freebsd/AUTHORS b/sysdeps/freebsd/AUTHORS deleted file mode 100644 index 9da8aceb..00000000 --- a/sysdeps/freebsd/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Martin Baulig (martin@home-of-linux.org) -Josh Sled (jsled@scam.XCF.Berkeley.EDU) diff --git a/sysdeps/freebsd/ChangeLog b/sysdeps/freebsd/ChangeLog deleted file mode 100644 index 85cb8f9e..00000000 --- a/sysdeps/freebsd/ChangeLog +++ /dev/null @@ -1,192 +0,0 @@ -2000-02-13 Martin Baulig <martin@home-of-linux.org> - - * netinfo.c: Reflect latest interface changes. - -2000-02-13 Martin Baulig <martin@home-of-linux.org> - - * *.c: kvm_nlist () returns -1 on error, but a positive return value - does not necessarily mean failure. Fixes #3302 which was reported by - Matthias Scheler some time ago. - -2000-02-06 Martin Baulig <martin@home-of-linux.org> - - * Makefile.am: Removed the non-suid `libgtop-sysdeps.la'. - * nosuid.c: Removed. - -1999-12-12 Martin Baulig <martin@home-of-linux.org> - - * netinfo.c: New file. - - * interfaces.c: Reflect latest interface changes. - * netload.c: Likewise. - -1999-10-24 Martin Baulig <martin@home-of-linux.org> - - * glibtop_machine.h: Make inclusion of <osreldate.h> conditional - to `HAVE_OSRELDATE_H', not to `__FreeBSD__'. - * procsignal.c, proctime.c, proctime.c: Likewise. - -1999-10-16 Martin Baulig <martin@home-of-linux.org> - - Applied all patches from the FreeBSD 3.3 ports collection. - - * swap.c: Only #include <rlist.h> for __FreeBSD_version < 400005. - - * prockernel.c: Make it compile on FreeBSD / alpha. - - * procsignal.c: Some fixes for FreeBSD-current. - -1999-10-16 Martin Baulig <martin@home-of-linux.org> - - * procstate.c (glibtop_get_proc_state_p): Don't use the - `GLIBTOP_PROCESS_*' constants for process states for - LibGTop 1.0.x. - -1999-07-29 Martin Baulig <martin@home-of-linux.org> - - * proctime.c (glibtop_get_proc_time_p): Fix bug reported by - Takis Psarogiannakopoulos: `start_time' are seconds since the - epoch as it is stated in the manual. - -Tue Jun 15 16:04:10 1999 Timur Bakeyev <mc@bat.ru> - - * procuid.c: A fix to a ommitted case, when nor NetBSD, nor - LibGTop >= 1.1.0. This should be investigated closely to cover - more cases.... - -1999-05-26 Martin Baulig <martin@home-of-linux.org> - - More NetBSD 1.4 fixes. - - * mem.c, procmap.c, procmem.c: Make this work with the new UVM code. - - [FIXME: This following most likely works on all BSD systems, but - this needs to be tested; I made it conditional to NetBSD 1.4 at - the moment. Please extend the conditionals to any other systems - where this works ...] - - * procstate.c: Added `ruid' and `rgid' for LibGTop >= 1.1.0. - * procuid.c: Added `ngroups' and `groups' for LibGTop >= 1.1.0. - -1999-05-25 Martin Baulig <martin@home-of-linux.org> - - * ppp.c: Make this work on NetBSD. - -Thu Apr 8 23:47:29 1999 Timur Bakeyev <timur@gnu.org> - - * cpu.c, mem.c, netload.c, procargs.c, procstate.c, proctime.c, - sem_limits.c, shm_limits.c, swap.c: Added initial port for BSD/OS - (aka BSDI) 2.x and 3.x. 4.x should also(?) work. - - Still, this port require more close look and extended check. - -1999-03-19 Martin Baulig <martin@home-of-linux.org> - - Added basic support for BSDI. It compiles without problems on - BSDI 2.1 and 3.1, but it is *untested* - I'm neither root on - the machine nor have I access to /dev/kmem, so I don't know - whether it will work. - - You need to give configure the `--enable-hacker-mode' parameter - to use the code. - - If someone can verify whether it actually works, please let me - know. - -1999-03-18 Martin Baulig <martin@home-of-linux.org> - - * ppp.c: Don't use `sppp.pp_phase' if we don't HAVE_I4B_ACCT. - This is an ugly hack until someone tells me which versions have - this field and which not. - -1999-02-25 Martin Baulig <martin@home-of-linux.org> - - * prockernel.c, proctime.c: Applied patch Stanislav Grozev for - OpenBSD: only include <osreldate.h> for FreeBSD. - -1999-02-24 Martin Baulig <martin@home-of-linux.org> - - * swap.c: Applied another patch from Jeremy Lea to - make it work with FreeBSD-current. - -1999-02-21 Martin Baulig <martin@home-of-linux.org> - - * procmap.c, procmem.c: Applied patch from Jeremy Lea. - - * prockernel.c, proctime.c: Applied patch from the FreeBSD 2.2.8 - ports collection. - - * procsignal.c: Applied patch from the NetBSD-current ports - collection. - -1998-12-06 Martin Baulig <martin@home-of-linux.org> - - * Make it work with OpenBSD 2.4. - -1998-12-05 Martin Baulig <martin@home-of-linux.org> - - * Make it work with NetBSD 1.3.2. - -1998-11-17 Martin Baulig <martin@home-of-linux.org> - - * Make it work with FreeBSD 3.0. - -1998-11-11 Martin Baulig <martin@home-of-linux.org> - - * *.c: It does not work to get information about the swapper task - on FreeBSD 2.2.6, so we simple return if pid == 0. - -1998-10-31 Martin Baulig <martin@home-of-linux.org> - - * *.c: Use glibtop_warn_io_r () instead of glibtop_error_io_r (). - - * proctime.c, prockernel.c, procargs.c: Don't call kvm_uread () if - the /proc filesystem is not mounted. - -1998-10-26 Martin Baulig <martin@home-of-linux.org> - - * netload.c: New file to get network load. - -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 - get ISDN statistics if you have the I4B package. - - To get the number of bytes transferred in/out you need to read the - file `misc/i4b_acct.txt' in the LibGTop source directory to see - how to enable this. - -1998-10-03 Martin Baulig <martin@home-of-linux.org> - - * procstate.c (glibtop_get_procstate_s): Use correct values for - the `state' field. - - * proclist.c (glibtop_get_proclist_p): Honor the GLIBTOP_EXCLUDE_IDLE - and GLIBTOP_EXCLUDE_SYSTEM flags of the `which' parameter. - -1998-08-24 Martin Baulig <martin@home-of-linux.org> - - * *.c (glibtop_init_p): Using correct `(1 << GLIBTOP_SYSDPES_*)'. - * cpu.c, mem.c: Removed `const' from sysctl () constants to keep - compiler happy. - - * procmem.c: Added missing call to `glibtop_init_p'. - - * prockernel.c: Casting `nwchan' to `unsigned long' since this - normally has the same size than a pointer. Well, is there a - FreeBSD for 64bit architectures ? - -1998-08-08 Martin Baulig <martin@home-of-linux.org> - - * swap.c: Added swap usage based upton the source code - of `pinfo'. - -1998-08-07 Martin Baulig <martin@home-of-linux.org> - - * *: Imported FreeBSD port of libgtop from Josh Sled. - - * ChangeLog: New file. diff --git a/sysdeps/freebsd/Makefile.am b/sysdeps/freebsd/Makefile.am deleted file mode 100644 index ce59df77..00000000 --- a/sysdeps/freebsd/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ - -INCLUDES = @INCLUDES@ - -lib_LTLIBRARIES = libgtop_sysdeps_suid.la - -libgtop_sysdeps_suid_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 procargs.c procmap.c netload.c \ - netinfo.c interfaces.c ppp.c - -libgtop_sysdeps_suid_la_LDFLAGS = $(LT_VERSION_INFO) - -include_HEADERS = glibtop_server.h glibtop_machine.h \ - glibtop_suid.h - diff --git a/sysdeps/freebsd/NOTES b/sysdeps/freebsd/NOTES deleted file mode 100644 index 82bbbc4b..00000000 --- a/sysdeps/freebsd/NOTES +++ /dev/null @@ -1,10 +0,0 @@ -sysctl (3) -/usr/include/sys/vmmeter.h : VM stats -kvm (3) - -CPU stats: /usr/include/sys/dkstat.h -cp_time_offset = kvm_nlist(...)["_cp_time"].n_value; - -"systemwide main memory usage structure" -sysctl(...) - diff --git a/sysdeps/freebsd/close.c b/sysdeps/freebsd/close.c deleted file mode 100644 index 1006e29e..00000000 --- a/sysdeps/freebsd/close.c +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/close.h> - -/* Closes pipe to gtop server. */ - -void -glibtop_close_p (glibtop *server) -{ } diff --git a/sysdeps/freebsd/cpu.c b/sysdeps/freebsd/cpu.c deleted file mode 100644 index 74aaf9cb..00000000 --- a/sysdeps/freebsd/cpu.c +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/cpu.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_cpu = -(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) + -(1L << GLIBTOP_CPU_NICE) + (1L << GLIBTOP_CPU_SYS) + -(1L << GLIBTOP_CPU_IDLE) + (1L << GLIBTOP_CPU_FREQUENCY); - -/* nlist structure for kernel access */ -static struct nlist nlst [] = { -#ifdef __bsdi__ - { "_cpustats" }, -#else - { "_cp_time" }, -#endif - { 0 } -}; - -/* MIB array for sysctl */ -static int mib_length=2; -static int mib [] = { CTL_KERN, KERN_CLOCKRATE }; - -/* Init function. */ - -int -glibtop_init_cpu_p (glibtop *server) -{ - if (kvm_nlist (server->_priv->machine.kd, nlst) < 0) { - glibtop_warn_io_r (server, "kvm_nlist (cpu)"); - return -1; - } - - /* Set this only if kvm_nlist () succeeded. */ - server->sysdeps.cpu = _glibtop_sysdeps_cpu; - - return 0; -} - -/* Provides information about cpu usage. */ - -int -glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf) -{ - long cpts [CPUSTATES]; - /* sysctl vars*/ - struct clockinfo ci; - size_t length; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_CPU), 0); - - memset (buf, 0, sizeof (glibtop_cpu)); - - /* If this fails, the nlist may not be valid. */ - if (server->sysdeps.cpu == 0) - return -1; - - if (kvm_read (server->_priv->machine.kd, nlst [0].n_value, - &cpts, sizeof (cpts)) != sizeof (cpts)) { - glibtop_warn_io_r (server, "kvm_read (cp_time)"); - return -1; - } - - /* Get the clockrate data */ - length = sizeof (struct clockinfo); - if (sysctl (mib, mib_length, &ci, &length, NULL, 0)) { - glibtop_warn_io_r (server, "sysctl"); - return -1; - } - - /* set user time */ - buf->user = cpts [CP_USER]; - /* set nice time */ - buf->nice = cpts [CP_NICE]; - /* set sys time */ - buf->sys = cpts [CP_SYS]; - /* set idle time */ - buf->idle = cpts [CP_IDLE]; - - /* set frequency */ - /* - FIXME -- is hz, tick, profhz or stathz wanted? - buf->frequency = sysctl("kern.clockrate", ...); - - struct clockinfo - */ - buf->frequency = ci.hz; - /* set total */ - buf->total = cpts [CP_USER] + cpts [CP_NICE] - + cpts [CP_SYS] + cpts [CP_IDLE]; - - /* Set the flags last. */ - buf->flags = _glibtop_sysdeps_cpu; - - return 0; -} diff --git a/sysdeps/freebsd/glibtop_machine.h b/sysdeps/freebsd/glibtop_machine.h deleted file mode 100644 index aba52ffc..00000000 --- a/sysdeps/freebsd/glibtop_machine.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_MACHINE_H__ -#define __GLIBTOP_MACHINE_H__ - -#include <sys/param.h> -#include <nlist.h> -#include <kvm.h> -#include <sys/dkstat.h> -#include <time.h> -#include <sys/user.h> -#include <sys/types.h> -#include <sys/sysctl.h> - -#include <fcntl.h> - -#ifdef HAVE_OSRELDATE_H -#include <osreldate.h> -#endif - -BEGIN_LIBGTOP_DECLS - -typedef struct _glibtop_machine glibtop_machine; - -struct _glibtop_machine -{ - uid_t uid, euid; - gid_t gid, egid; - - /* The kernel descriptor, used by kvm_* calls. We keep and re-use - * it rather than re-getting it for almost all function - * invocations. */ - kvm_t *kd; -}; - -END_LIBGTOP_DECLS - -#endif __GLIBTOP_MACHINE_H__ diff --git a/sysdeps/freebsd/glibtop_server.h b/sysdeps/freebsd/glibtop_server.h deleted file mode 100644 index d7e032d9..00000000 --- a/sysdeps/freebsd/glibtop_server.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_SERVER_H__ -#define __GLIBTOP_SERVER_H__ - -BEGIN_LIBGTOP_DECLS - -#define GLIBTOP_SUID_CPU (1 << GLIBTOP_SYSDEPS_CPU) -#define GLIBTOP_SUID_MEM (1 << GLIBTOP_SYSDEPS_MEM) -#define GLIBTOP_SUID_SWAP (1 << GLIBTOP_SYSDEPS_SWAP) -#define GLIBTOP_SUID_UPTIME (1 << GLIBTOP_SYSDEPS_UPTIME) -#define GLIBTOP_SUID_LOADAVG (1 << GLIBTOP_SYSDEPS_LOADAVG) -#define GLIBTOP_SUID_SHM_LIMITS (1 << GLIBTOP_SYSDEPS_SHM_LIMITS) -#define GLIBTOP_SUID_MSG_LIMITS (1 << GLIBTOP_SYSDEPS_MSG_LIMITS) -#define GLIBTOP_SUID_SEM_LIMITS (1 << GLIBTOP_SYSDEPS_SEM_LIMITS) -#define GLIBTOP_SUID_PROCLIST (1 << GLIBTOP_SYSDEPS_PROCLIST) -#define GLIBTOP_SUID_PROC_STATE (1 << GLIBTOP_SYSDEPS_PROC_STATE) -#define GLIBTOP_SUID_PROC_UID (1 << GLIBTOP_SYSDEPS_PROC_UID) -#define GLIBTOP_SUID_PROC_MEM (1 << GLIBTOP_SYSDEPS_PROC_MEM) -#define GLIBTOP_SUID_PROC_TIME (1 << GLIBTOP_SYSDEPS_PROC_TIME) -#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_NETLOAD (1 << GLIBTOP_SYSDEPS_NETLOAD) -#define GLIBTOP_SUID_NETINFO (1 << GLIBTOP_SYSDEPS_NETINFO) -#define GLIBTOP_SUID_INTERFACE_NAMES (1 << GLIBTOP_SYSDEPS_INTERFACE_NAMES) -#define GLIBTOP_SUID_PPP (1 << GLIBTOP_SYSDEPS_PPP) - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/freebsd/glibtop_suid.h b/sysdeps/freebsd/glibtop_suid.h deleted file mode 100644 index 31a4e3d4..00000000 --- a/sysdeps/freebsd/glibtop_suid.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_SUID_H__ -#define __GLIBTOP_SUID_H__ - -BEGIN_LIBGTOP_DECLS - -#if _IN_LIBGTOP -#include <sys/param.h> -#endif - -#define KI_PROC(ki) (&(ki))->kp_proc) -#define KI_EPROC(ki) (&(ki))->kp_eproc) - -#define FORCEUREAD 1 -#define UREADOK(ki) (FORCEUREAD || (KI_PROC(ki)->p_flag & P_INMEM)) - -static inline void glibtop_suid_enter (glibtop *server) { -setregid (server->_priv->machine.gid, - server->_priv->machine.egid); -}; - -static inline void glibtop_suid_leave (glibtop *server) { -if (setregid (server->_priv->machine.egid, - server->_priv->machine.gid)) - _exit (1); - }; - - void - glibtop_init_p (glibtop *server, const unsigned long features, - const unsigned flags); -void -glibtop_open_p (glibtop *server, const char *program_name, - const unsigned long features, - const unsigned flags); - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/freebsd/init.c b/sysdeps/freebsd/init.c deleted file mode 100644 index 48371f56..00000000 --- a/sysdeps/freebsd/init.c +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/open.h> - -static glibtop _glibtop_global_server; -glibtop *glibtop_global_server = NULL; - -glibtop * -glibtop_init_r (glibtop **server, - const unsigned long features, - const unsigned flags) -{ - if (*server != NULL) - return *server; - - if (glibtop_global_server == NULL) { - glibtop_global_server = &_glibtop_global_server; - glibtop_open (glibtop_global_server, "glibtop", - features, flags); - } - - return *server = glibtop_global_server; -} diff --git a/sysdeps/freebsd/interfaces.c b/sysdeps/freebsd/interfaces.c deleted file mode 100644 index 737c5c99..00000000 --- a/sysdeps/freebsd/interfaces.c +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/interfaces.h> - -static const unsigned long _glibtop_sysdeps_interface_names = -(1L << GLIBTOP_ARRAY_NUMBER) + (1L << GLIBTOP_ARRAY_SIZE) + -(1L << GLIBTOP_ARRAY_TOTAL); - -/* Init function. */ - -int -glibtop_init_interface_names_p (glibtop *server) -{ - server->sysdeps.interface_names = _glibtop_sysdeps_interface_names; - - return 0; -} - -/* Provides network statistics. */ - -glibtop_interface * -glibtop_get_interface_names_p (glibtop *server, glibtop_array *array, - u_int64_t interface, u_int64_t number, - u_int64_t instance, u_int64_t strategy) -{ - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_INTERFACE_NAMES), 0); - - memset (array, 0, sizeof (glibtop_array)); - - return NULL; -} diff --git a/sysdeps/freebsd/loadavg.c b/sysdeps/freebsd/loadavg.c deleted file mode 100644 index 67e0e29f..00000000 --- a/sysdeps/freebsd/loadavg.c +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/loadavg.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_loadavg = -(1L << GLIBTOP_LOADAVG_LOADAVG); - -/* Init function. */ - -int -glibtop_init_loadavg_p (glibtop *server) -{ - server->sysdeps.loadavg = _glibtop_sysdeps_loadavg; - - return 0; -} - -/* Provides load averange. */ - -int -glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf) -{ - double ldavg[3]; - int i; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_LOADAVG), 0); - - memset (buf, 0, sizeof (glibtop_loadavg)); - - getloadavg (ldavg, 3); - - /* fill in the struct */ - buf->flags = _glibtop_sysdeps_loadavg; - for (i = 0; i < 3; i++) { - buf->loadavg [i] = ldavg [i]; - } /* end for */ - - return 0; -} diff --git a/sysdeps/freebsd/mem.c b/sysdeps/freebsd/mem.c deleted file mode 100644 index b80edcdc..00000000 --- a/sysdeps/freebsd/mem.c +++ /dev/null @@ -1,228 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/mem.h> - -#include <glibtop_suid.h> - -#include <sys/sysctl.h> -#include <sys/vmmeter.h> -#include <vm/vm_param.h> - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) -#include <uvm/uvm_extern.h> -#endif - -static const unsigned long _glibtop_sysdeps_mem = -(1L << GLIBTOP_MEM_TOTAL) + (1L << GLIBTOP_MEM_USED) + -(1L << GLIBTOP_MEM_FREE) + -(1L << GLIBTOP_MEM_SHARED) + -(1L << GLIBTOP_MEM_BUFFER) + -#ifdef __FreeBSD__ -(1L << GLIBTOP_MEM_CACHED) + -#endif -(1L << GLIBTOP_MEM_USER) + (1L << GLIBTOP_MEM_LOCKED); - -#ifndef LOG1024 -#define LOG1024 10 -#endif - -/* these are for getting the memory statistics */ -static int pageshift; /* log base 2 of the pagesize */ - -/* define pagetok in terms of pageshift */ -#define pagetok(size) ((size) << pageshift) - -/* nlist structure for kernel access */ -static struct nlist nlst [] = { -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - { "_bufpages" }, - { 0 } -#else -#if defined(__bsdi__) - { "_bufcachemem" }, -#elif defined(__FreeBSD__) - { "_bufspace" }, -#else - { "_bufpages" }, -#endif - { "_cnt" }, - { 0 } -#endif -}; - -/* MIB array for sysctl */ -static int mib_length=2; -#ifdef __bsdi__ -static int mib [] = { CTL_VM, VM_TOTAL }; -#else -static int mib [] = { CTL_VM, VM_METER }; -#endif - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) -static int mib_uvmexp [] = { CTL_VM, VM_UVMEXP }; -#endif - -/* Init function. */ - -int -glibtop_init_mem_p (glibtop *server) -{ - register int pagesize; - - if (kvm_nlist (server->_priv->machine.kd, nlst) < 0) { - glibtop_warn_io_r (server, "kvm_nlist (mem)"); - return -1; - } - - /* get the page size with "getpagesize" and calculate pageshift - * from it */ - pagesize = getpagesize (); - pageshift = 0; - while (pagesize > 1) { - pageshift++; - pagesize >>= 1; - } - - /* we only need the amount of log(2)1024 for our conversion */ - pageshift -= LOG1024; - - server->sysdeps.mem = _glibtop_sysdeps_mem; - - return 0; -} - -int -glibtop_get_mem_p (glibtop *server, glibtop_mem *buf) -{ - struct vmtotal vmt; - size_t length_vmt; -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - struct uvmexp uvmexp; - size_t length_uvmexp; -#else - struct vmmeter vmm; -#endif - u_int v_used_count; - u_int v_total_count; - u_int v_free_count; - int bufspace; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MEM), 0); - - memset (buf, 0, sizeof (glibtop_mem)); - - if (server->sysdeps.mem == 0) - return -1; - - /* [FIXME: On FreeBSD 2.2.6, sysctl () returns an incorrect - * value for `vmt.vm'. We use some code from Unix top - * here.] */ - - /* Get the data from sysctl */ - length_vmt = sizeof (vmt); - if (sysctl (mib, 2, &vmt, &length_vmt, NULL, 0)) { - glibtop_warn_io_r (server, "sysctl (vmt)"); - return -1; - } - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - length_uvmexp = sizeof (uvmexp); - if (sysctl (mib_uvmexp, 2, &uvmexp, &length_uvmexp, NULL, 0)) { - glibtop_warn_io_r (server, "sysctl (uvmexp)"); - return -1; - } -#else - /* Get the data from kvm_* */ - if (kvm_read (server->_priv->machine.kd, nlst[1].n_value, - &vmm, sizeof (vmm)) != sizeof (vmm)) { - glibtop_warn_io_r (server, "kvm_read (cnt)"); - return -1; - } -#endif - - if (kvm_read (server->_priv->machine.kd, nlst[0].n_value, - &bufspace, sizeof (bufspace)) != sizeof (bufspace)) { - glibtop_warn_io_r (server, "kvm_read (bufspace)"); - return -1; - } - - /* convert memory stats to Kbytes */ - -#if defined(__FreeBSD__) - v_total_count = vmm.v_page_count; -#else -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - v_total_count = uvmexp.reserve_kernel + - uvmexp.reserve_pagedaemon + - uvmexp.free + uvmexp.wired + uvmexp.active + - uvmexp.inactive; -#else - v_total_count = vmm.v_kernel_pages + - vmm.v_free_count + vmm.v_wire_count + - vmm.v_active_count + vmm.v_inactive_count; -#endif -#endif - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - v_used_count = uvmexp.active + uvmexp.inactive; - v_free_count = uvmexp.free; -#else - v_used_count = vmm.v_active_count + vmm.v_inactive_count; - v_free_count = vmm.v_free_count; -#endif - - buf->total = (u_int64_t) pagetok (v_total_count) << LOG1024; - buf->used = (u_int64_t) pagetok (v_used_count) << LOG1024; - buf->free = (u_int64_t) pagetok (v_free_count) << LOG1024; - -#ifdef __FreeBSD__ - buf->cached = (u_int64_t) pagetok (vmm.v_cache_count) << LOG1024; -#endif - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - buf->locked = (u_int64_t) pagetok (uvmexp.wired) << LOG1024; -#else - buf->locked = (u_int64_t) pagetok (vmm.v_wire_count) << LOG1024; -#endif - - buf->shared = (u_int64_t) pagetok (vmt.t_rmshr) << LOG1024; - -#if __FreeBSD__ - buf->buffer = (u_int64_t) bufspace; -#else - buf->buffer = (u_int64_t) pagetok (bufspace) << LOG1024; -#endif - - /* user */ - buf->user = buf->total - buf->free - buf->shared - buf->buffer; - - /* Set the values to return */ - buf->flags = _glibtop_sysdeps_mem; - - return 0; -} diff --git a/sysdeps/freebsd/msg_limits.c b/sysdeps/freebsd/msg_limits.c deleted file mode 100644 index 2e7bd293..00000000 --- a/sysdeps/freebsd/msg_limits.c +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, August 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/msg_limits.h> - -#include <glibtop_suid.h> - -#if (defined __bsdi__) && (_BSDI_VERSION < 199700) -/* Older versions of BSDI don't seem to have this. */ - -int -glibtop_init_msg_limits_p (glibtop *server) -{ - return 0; -} - -int -glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf) -{ - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0); - - memset (buf, 0, sizeof (glibtop_msg_limits)); - - return 0; -} - -#else - -/* #define KERNEL to get declaration of `struct msginfo'. */ - -#if (defined __FreeBSD__) || (defined __bsdi__) -#define KERNEL 1 -#else -#define _KERNEL 1 -#endif - -#include <sys/ipc.h> -#include <sys/msg.h> - -static const unsigned long _glibtop_sysdeps_msg_limits = -(1L << GLIBTOP_MSG_LIMITS_MSGMAX) + (1L << GLIBTOP_MSG_LIMITS_MSGMNI) + -(1L << GLIBTOP_MSG_LIMITS_MSGMNB) + (1L << GLIBTOP_MSG_LIMITS_MSGTQL) + -(1L << GLIBTOP_MSG_LIMITS_MSGSSZ); - -/* The values in this structure never change at runtime, so we only - * read it once during initialization. We have to use the name `_msginfo' - * since `msginfo' is already declared external in <sys/msg.h>. */ -static struct msginfo _msginfo; - -/* nlist structure for kernel access */ -static struct nlist nlst [] = { - { "_msginfo" }, - { 0 } -}; - -/* Init function. */ - -int -glibtop_init_msg_limits_p (glibtop *server) -{ - if (kvm_nlist (server->_priv->machine.kd, nlst) < 0) { - glibtop_warn_io_r (server, "kvm_nlist (msg_limits)"); - return -1; - } - - if (kvm_read (server->_priv->machine.kd, nlst [0].n_value, - &_msginfo, sizeof (_msginfo)) != sizeof (_msginfo)) { - glibtop_warn_io_r (server, "kvm_read (msginfo)"); - return -1; - } - - server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf) -{ - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0); - - memset (buf, 0, sizeof (glibtop_msg_limits)); - - if (server->sysdeps.msg_limits == 0) - return -1; - - buf->msgmax = _msginfo.msgmax; - buf->msgmni = _msginfo.msgmni; - buf->msgmnb = _msginfo.msgmnb; - buf->msgtql = _msginfo.msgtql; - buf->msgssz = _msginfo.msgtql; - - buf->flags = _glibtop_sysdeps_msg_limits; - - return 0; -} - -#endif /* either a newer BSDI or no BSDI at all. */ - diff --git a/sysdeps/freebsd/netinfo.c b/sysdeps/freebsd/netinfo.c deleted file mode 100644 index c4db0aa1..00000000 --- a/sysdeps/freebsd/netinfo.c +++ /dev/null @@ -1,238 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/netinfo.h> - -#include <glibtop_suid.h> - -#include <net/if.h> -#include <net/if_dl.h> -#include <net/if_types.h> - -#ifdef HAVE_NET_IF_VAR_H -#include <net/if_var.h> -#endif - -#include <netinet/in.h> -#include <netinet/in_var.h> - -static const unsigned long _glibtop_sysdeps_netinfo = -(1L << GLIBTOP_NETINFO_IF_FLAGS) + -(1L << GLIBTOP_NETINFO_MTU); - -/* nlist structure for kernel access */ -static struct nlist nlst [] = { - { "_ifnet" }, - { 0 } -}; - -/* Init function. */ - -int -glibtop_init_netinfo_p (glibtop *server) -{ - server->sysdeps.netinfo = _glibtop_sysdeps_netinfo; - - if (kvm_nlist (server->_priv->machine.kd, nlst) < 0) - glibtop_error_io_r (server, "kvm_nlist"); - - return 0; -} - -static int -_netinfo_ipv4 (glibtop *server, glibtop_netinfo *buf, - const char *interface, glibtop_ifaddr *address) -{ - struct ifnet ifnet; - u_long ifnetaddr, ifnetfound, ifaddraddr; - char tname [16]; - - union { - struct ifaddr ifa; - struct in_ifaddr in; - } ifaddr; - - if (kvm_read (server->_priv->machine.kd, nlst [0].n_value, - &ifnetaddr, sizeof (ifnetaddr)) != sizeof (ifnetaddr)) { - glibtop_warn_io_r (server, "kvm_read (ifnet)"); - return -1; - } - - ifaddraddr = 0; - while (ifnetaddr || ifaddraddr) { - struct sockaddr_in *sin; - register char *cp; - - if (ifaddraddr == 0) { - ifnetfound = ifnetaddr; - - if (kvm_read (server->_priv->machine.kd, ifnetaddr, &ifnet, - sizeof (ifnet)) != sizeof (ifnet)) { - glibtop_warn_io_r (server, "kvm_read (ifnetaddr)"); - return -1; - } - -#if defined(__FreeBSD__) || defined(__bsdi__) - if (kvm_read (server->_priv->machine.kd, (u_long) ifnet.if_name, - tname, 16) != 16) { - glibtop_warn_io_r (server, "kvm_read (if_name)"); - return -1; - } -#else - strncpy (tname, ifnet.if_xname, 16); - tname [15] = 0; -#endif - -#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000) - ifaddraddr = (u_long) ifnet.if_addrhead.tqh_first; -#elif defined(__FreeBSD__) || defined(__bsdi__) - ifaddraddr = (u_long) ifnet.if_addrlist; -#else - ifaddraddr = (u_long) ifnet.if_addrlist.tqh_first; -#endif - } - - if (ifaddraddr) { - struct sockaddr *sa; - - if ((kvm_read (server->_priv->machine.kd, ifaddraddr, &ifaddr, - sizeof (ifaddr)) != sizeof (ifaddr))) { - glibtop_warn_io_r (server, "kvm_read (ifaddraddr)"); - return -1; - } - -#define CP(x) ((char *)(x)) - - cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) + CP(&ifaddr); - sa = (struct sockaddr *)cp; - - if (!strcmp (interface, tname) && (sa->sa_family == AF_INET)) { - sin = (struct sockaddr_in *)sa; - - if (ifnet.if_flags & IFF_UP) - buf->if_flags |= GLIBTOP_IF_FLAGS_UP; - if (ifnet.if_flags & IFF_BROADCAST) - buf->if_flags |= GLIBTOP_IF_FLAGS_BROADCAST; - if (ifnet.if_flags & IFF_DEBUG) - buf->if_flags |= GLIBTOP_IF_FLAGS_DEBUG; - if (ifnet.if_flags & IFF_LOOPBACK) - buf->if_flags |= GLIBTOP_IF_FLAGS_LOOPBACK; - if (ifnet.if_flags & IFF_POINTOPOINT) - buf->if_flags |= GLIBTOP_IF_FLAGS_POINTOPOINT; - if (ifnet.if_flags & IFF_RUNNING) - buf->if_flags |= GLIBTOP_IF_FLAGS_RUNNING; - if (ifnet.if_flags & IFF_NOARP) - buf->if_flags |= GLIBTOP_IF_FLAGS_NOARP; - if (ifnet.if_flags & IFF_PROMISC) - buf->if_flags |= GLIBTOP_IF_FLAGS_PROMISC; - if (ifnet.if_flags & IFF_ALLMULTI) - buf->if_flags |= GLIBTOP_IF_FLAGS_ALLMULTI; - if (ifnet.if_flags & IFF_OACTIVE) - buf->if_flags |= GLIBTOP_IF_FLAGS_OACTIVE; - if (ifnet.if_flags & IFF_SIMPLEX) - buf->if_flags |= GLIBTOP_IF_FLAGS_SIMPLEX; - if (ifnet.if_flags & IFF_LINK0) - buf->if_flags |= GLIBTOP_IF_FLAGS_LINK0; - if (ifnet.if_flags & IFF_LINK1) - buf->if_flags |= GLIBTOP_IF_FLAGS_LINK1; - if (ifnet.if_flags & IFF_LINK2) - buf->if_flags |= GLIBTOP_IF_FLAGS_LINK2; -#ifdef __FreeBSD__ - if (ifnet.if_flags & IFF_ALTPHYS) - buf->if_flags |= GLIBTOP_IF_FLAGS_ALTPHYS; -#endif - if (ifnet.if_flags & IFF_MULTICAST) - buf->if_flags |= GLIBTOP_IF_FLAGS_MULTICAST; - - buf->mtu = ifnet.if_mtu; - buf->flags = _glibtop_sysdeps_netinfo; - - address->subnet = htonl (ifaddr.in.ia_subnet); - address->flags |= (1L << GLIBTOP_IFADDR_SUBNET); - - address->addr_len = 4; - memcpy (&address->address, &sin->sin_addr.s_addr, 4); - - address->flags |= (1L << GLIBTOP_IFADDR_ADDRESS); - address->flags |= (1L << GLIBTOP_IFADDR_ADDR_LEN); - - return 0; - } - -#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000) - ifaddraddr = (u_long)ifaddr.ifa.ifa_link.tqe_next; -#elif defined(__FreeBSD__) || defined(__bsdi__) - ifaddraddr = (u_long)ifaddr.ifa.ifa_next; -#else - ifaddraddr = (u_long)ifaddr.ifa.ifa_list.tqe_next; -#endif - } - -#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000) - ifnetaddr = (u_long) ifnet.if_link.tqe_next; -#elif defined(__FreeBSD__) || defined(__bsdi__) - ifnetaddr = (u_long) ifnet.if_next; -#else - ifnetaddr = (u_long) ifnet.if_list.tqe_next; -#endif - } - - return 0; -} - -/* Provides Network statistics. */ - -glibtop_ifaddr * -glibtop_get_netinfo_p (glibtop *server, glibtop_array *array, - glibtop_netinfo *buf, const char *interface, - u_int64_t transport) -{ - glibtop_ifaddr address, *retval = NULL; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_NETINFO), 0); - - memset (buf, 0, sizeof (glibtop_netinfo)); - memset (&address, 0, sizeof (glibtop_ifaddr)); - - if (transport & GLIBTOP_TRANSPORT_IPV4) { - /* IPv4 */ - - if (!_netinfo_ipv4 (server, buf, interface, &address)) { - retval = glibtop_calloc_r (server, 1, sizeof (glibtop_ifaddr)); - *retval = address; - - array->number = 1; - array->size = sizeof (glibtop_ifaddr); - array->total = array->number * array->size; - - return retval; - } - } - - return NULL; -} diff --git a/sysdeps/freebsd/netload.c b/sysdeps/freebsd/netload.c deleted file mode 100644 index 5f9a0304..00000000 --- a/sysdeps/freebsd/netload.c +++ /dev/null @@ -1,177 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/netload.h> - -#include <glibtop_suid.h> - -#include <net/if.h> -#include <net/if_dl.h> -#include <net/if_types.h> - -#ifdef HAVE_NET_IF_VAR_H -#include <net/if_var.h> -#endif - -#include <netinet/in.h> -#include <netinet/in_var.h> - -static const unsigned long _glibtop_sysdeps_netload = -(1L << GLIBTOP_NETLOAD_PACKETS_IN) + -(1L << GLIBTOP_NETLOAD_PACKETS_OUT) + -(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) + -(1L << GLIBTOP_NETLOAD_BYTES_IN) + -(1L << GLIBTOP_NETLOAD_BYTES_OUT) + -(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) + -(1L << GLIBTOP_NETLOAD_ERRORS_IN) + -(1L << GLIBTOP_NETLOAD_ERRORS_OUT) + -(1L << GLIBTOP_NETLOAD_ERRORS_TOTAL) + -(1L << GLIBTOP_NETLOAD_COLLISIONS); - -/* nlist structure for kernel access */ -static struct nlist nlst [] = { - { "_ifnet" }, - { 0 } -}; - -/* Init function. */ - -int -glibtop_init_netload_p (glibtop *server) -{ - server->sysdeps.netload = _glibtop_sysdeps_netload; - - if (kvm_nlist (server->_priv->machine.kd, nlst) < 0) - glibtop_error_io_r (server, "kvm_nlist"); - - return 0; -} - -/* Provides Network statistics. */ - -int -glibtop_get_netload_p (glibtop *server, glibtop_netload *buf, - const char *interface, unsigned transport, - unsigned protocol) -{ - struct ifnet ifnet; - u_long ifnetaddr, ifnetfound, ifaddraddr; - struct sockaddr *sa; - char tname [16]; - - union { - struct ifaddr ifa; - struct in_ifaddr in; - } ifaddr; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_NETLOAD), 0); - - memset (buf, 0, sizeof (glibtop_netload)); - - if (kvm_read (server->_priv->machine.kd, nlst [0].n_value, - &ifnetaddr, sizeof (ifnetaddr)) != sizeof (ifnetaddr)) - glibtop_error_io_r (server, "kvm_read (ifnet)"); - - ifaddraddr = 0; - while (ifnetaddr || ifaddraddr) { - struct sockaddr_in *sin; - register char *cp; - - if (ifaddraddr == 0) { - ifnetfound = ifnetaddr; - - if (kvm_read (server->_priv->machine.kd, ifnetaddr, &ifnet, - sizeof (ifnet)) != sizeof (ifnet)) - glibtop_error_io_r (server, "kvm_read (ifnetaddr)"); - -#if defined(__FreeBSD__) || defined(__bsdi__) - if (kvm_read (server->_priv->machine.kd, (u_long) ifnet.if_name, - tname, 16) != 16) - glibtop_error_io_r (server, "kvm_read (if_name)"); -#else - strncpy (tname, ifnet.if_xname, 16); - tname [15] = 0; -#endif - -#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000) - ifaddraddr = (u_long) ifnet.if_addrhead.tqh_first; -#elif defined(__FreeBSD__) || defined(__bsdi__) - ifaddraddr = (u_long) ifnet.if_addrlist; -#else - ifaddraddr = (u_long) ifnet.if_addrlist.tqh_first; -#endif - } - - if (ifaddraddr) { - if ((kvm_read (server->_priv->machine.kd, ifaddraddr, &ifaddr, - sizeof (ifaddr)) != sizeof (ifaddr))) - glibtop_error_io_r (server, "kvm_read (ifaddraddr)"); - -#define CP(x) ((char *)(x)) - cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) + - CP(&ifaddr); sa = (struct sockaddr *)cp; - - if (!strcmp (interface, tname) && (sa->sa_family == AF_INET)) { - sin = (struct sockaddr_in *)sa; - - buf->packets_in = ifnet.if_ipackets; - buf->packets_out = ifnet.if_opackets; - buf->packets_total = buf->packets_in + buf->packets_out; - - buf->bytes_in = ifnet.if_ibytes; - buf->bytes_out = ifnet.if_obytes; - buf->bytes_total = buf->bytes_in + buf->bytes_out; - - buf->errors_in = ifnet.if_ierrors; - buf->errors_out = ifnet.if_oerrors; - buf->errors_total = buf->errors_in + buf->errors_out; - - buf->collisions = ifnet.if_collisions; - buf->flags = _glibtop_sysdeps_netload; - return -1; - } - -#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000) - ifaddraddr = (u_long)ifaddr.ifa.ifa_link.tqe_next; -#elif defined(__FreeBSD__) || defined(__bsdi__) - ifaddraddr = (u_long)ifaddr.ifa.ifa_next; -#else - ifaddraddr = (u_long)ifaddr.ifa.ifa_list.tqe_next; -#endif - } - -#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000) - ifnetaddr = (u_long) ifnet.if_link.tqe_next; -#elif defined(__FreeBSD__) || defined(__bsdi__) - ifnetaddr = (u_long) ifnet.if_next; -#else - ifnetaddr = (u_long) ifnet.if_list.tqe_next; -#endif - } - - return 0; -} diff --git a/sysdeps/freebsd/open.c b/sysdeps/freebsd/open.c deleted file mode 100644 index 4b54f649..00000000 --- a/sysdeps/freebsd/open.c +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/open.h> -#include <glibtop/xmalloc.h> - -/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - -void -glibtop_init_p (glibtop *server, const unsigned long features, - const unsigned flags) -{ - glibtop_init_func_t *init_fkt; - - if (server == NULL) - glibtop_error_r (NULL, "glibtop_init_p (server == NULL)"); - - /* Do the initialization, but only if not already initialized. */ - - if ((server->flags & _GLIBTOP_INIT_STATE_SYSDEPS) == 0) { - glibtop_open_p (server, "glibtop", features, flags); - - for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++) - (*init_fkt) (server); - - server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS; - } -} - -void -glibtop_open_p (glibtop *server, const char *program_name, - const unsigned long features, - const unsigned flags) -{ -#ifdef DEBUG - fprintf (stderr, "DEBUG (%d): glibtop_open_p ()\n", getpid ()); -#endif - - /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ - - server->_priv->machine.uid = getuid (); - server->_priv->machine.euid = geteuid (); - server->_priv->machine.gid = getgid (); - server->_priv->machine.egid = getegid (); - -#ifdef __FreeBSD__ - server->os_version_code = __FreeBSD_version; -#endif - - /* Setup machine-specific data */ - server->_priv->machine.kd = kvm_open - (NULL, NULL, NULL, O_RDONLY, "kvm_open"); - - if (server->_priv->machine.kd == NULL) - glibtop_error_io_r (server, "kvm_open"); - - /* Drop priviledges. */ - - if (setreuid (server->_priv->machine.euid, - server->_priv->machine.uid)) - _exit (1); - - if (setregid (server->_priv->machine.egid, - server->_priv->machine.gid)) - _exit (1); - - /* !!! END OF SUID ROOT PART !!! */ - - /* Our effective uid is now those of the user invoking the server, - * so we do no longer have any priviledges. */ - - /* NOTE: On FreeBSD, we do not need to be suid root, we just need to - * be sgid kmem. - * - * The server will only use setegid() to get back it's priviledges, - * so it will fail if it is suid root and not sgid kmem. */ -} diff --git a/sysdeps/freebsd/ppp.c b/sysdeps/freebsd/ppp.c deleted file mode 100644 index b255388e..00000000 --- a/sysdeps/freebsd/ppp.c +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/ppp.h> - -#include <glibtop_suid.h> - -#ifdef HAVE_I4B - -#include <net/if.h> -#include <net/if_types.h> - -#ifdef HAVE_NET_IF_VAR_H -#include <net/if_var.h> -#endif - -#include <net/netisr.h> -#include <net/route.h> - -#if defined(__FreeBSD__) || defined(__NetBSD__) -#include <net/if_sppp.h> -#else -#include <i4b/sppp/if_sppp.h> -#endif - -/* Read `misc/i4b_acct.txt' for details ... */ -#ifdef HAVE_I4B_ACCT -#include <machine/i4b_acct.h> -#endif - -static const unsigned long _glibtop_sysdeps_ppp = -(1L << GLIBTOP_PPP_STATE); - -#ifdef HAVE_I4B_ACCT -static const unsigned long _glibtop_sysdeps_ppp_acct = -(1L << GLIBTOP_PPP_BYTES_IN) + (1L << GLIBTOP_PPP_BYTES_OUT); -#endif - -#endif /* HAVE_I4B */ - -/* nlist structure for kernel access */ -static struct nlist nlst [] = { -#ifdef HAVE_I4B - { "_i4bisppp_softc" }, -#endif - { 0 } -}; - -/* Init function. */ - -int -glibtop_init_ppp_p (glibtop *server) -{ -#ifdef HAVE_I4B -#ifdef HAVE_I4B_ACCT - server->sysdeps.ppp = _glibtop_sysdeps_ppp | - _glibtop_sysdeps_ppp_acct; -#else - server->sysdeps.ppp = _glibtop_sysdeps_ppp; -#endif -#endif /* HAVE_I4B */ - - if (kvm_nlist (server->_priv->machine.kd, nlst) < 0) - glibtop_error_io_r (server, "kvm_nlist"); - - return 0; -} - -/* Provides information about ppp usage. */ - -int -glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device, - unsigned short isdn) -{ -#ifdef HAVE_I4B -#ifdef HAVE_I4B_ACCT - struct i4bisppp_softc data; -#else - struct sppp data; -#endif - int phase; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PPP), 0); - - memset (buf, 0, sizeof (glibtop_ppp)); - - if (kvm_read (server->_priv->machine.kd, nlst [0].n_value, - &data, sizeof (data)) != sizeof (data)) - glibtop_error_io_r (server, "kvm_read (i4bisppp_softc)"); - -#ifdef HAVE_I4B_ACCT - phase = data.sc_if_un.scu_sp.pp_phase; -#else - /* FIXME: Which FreeBSD version have this field and - * which not. */ -#if 0 - phase = data.pp_phase; -#endif -#endif - - switch (phase) { -#ifdef HAVE_I4B_ACCT - case PHASE_DEAD: - case PHASE_TERMINATE: - buf->state = GLIBTOP_PPP_STATE_HANGUP; - break; - case PHASE_ESTABLISH: - case PHASE_NETWORK: - buf->state = GLIBTOP_PPP_STATE_ONLINE; - break; -#endif - default: - buf->state = GLIBTOP_PPP_STATE_UNKNOWN; - break; - } - - buf->flags = _glibtop_sysdeps_ppp; - -#ifdef HAVE_I4B_ACCT - buf->bytes_in = data.sc_inb; - buf->bytes_out = data.sc_outb; - buf->flags |= _glibtop_sysdeps_ppp_acct; -#endif -#endif /* HAVE_I4B */ - - return 0; -} diff --git a/sysdeps/freebsd/procargs.c b/sysdeps/freebsd/procargs.c deleted file mode 100644 index 2055fa35..00000000 --- a/sysdeps/freebsd/procargs.c +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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 = -(1L << GLIBTOP_ARRAY_NUMBER) + (1L << GLIBTOP_ARRAY_SIZE); - -/* Init function. */ - -int -glibtop_init_proc_args_p (glibtop *server) -{ - server->sysdeps.proc_args = _glibtop_sysdeps_proc_args; - - return 0; -} - -/* Provides detailed information about a process. */ - -char ** -glibtop_get_proc_args_p (glibtop *server, glibtop_array *array, pid_t pid) -{ - struct kinfo_proc *pinfo; - char **args, **ptr, **ptrlist; - size_t count; - int i; - -#ifndef __bsdi__ - char filename [BUFSIZ]; - struct stat statb; -#endif - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_ARGS), 0); - - memset (array, 0, sizeof (glibtop_array)); - - /* swapper, init, pagedaemon, vmdaemon, update - this doen't work. */ - if (pid < 5) return NULL; - -#ifndef __bsdi__ - sprintf (filename, "/proc/%d/mem", pid); - if (stat (filename, &statb)) return NULL; -#endif - - glibtop_suid_enter (server); - - /* Get the process data */ - pinfo = kvm_getprocs (server->_priv->machine.kd, - KERN_PROC_PID, pid, &count); - if ((pinfo == NULL) || (count < 1)) { - glibtop_suid_leave (server); - glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); - return NULL; - } - - args = kvm_getargv (server->_priv->machine.kd, pinfo, BUFSIZ); - if (args == NULL) { - glibtop_suid_leave (server); - glibtop_warn_io_r (server, "kvm_getargv (%d)", pid); - return NULL; - } - - glibtop_suid_leave (server); - - count = 0; - for (ptr = args; *ptr; ptr++) - count++; - - ptrlist = glibtop_calloc_r (server, count+1, sizeof (char *)); - - for (i = 0, ptr = args; *ptr; ptr++, i++) { - ptrlist [i] = glibtop_strdup_r (server, *ptr); - } - - ptrlist [count] = NULL; - - array->number = count; - array->size = sizeof (char *); - array->flags = _glibtop_sysdeps_proc_args; - - return ptrlist; -} diff --git a/sysdeps/freebsd/procdata.c b/sysdeps/freebsd/procdata.c deleted file mode 100644 index 4cd1626a..00000000 --- a/sysdeps/freebsd/procdata.c +++ /dev/null @@ -1,182 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/procdata.h> - -#include <sys/stat.h> - -#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z) - -#define BIT_SHIFT(x) (1L << (x % 64)) - -static const unsigned long _glibtop_sysdeps_procdata_0 = -BIT_SHIFT(GLIBTOP_PROCDATA_CMD) + -BIT_SHIFT(GLIBTOP_PROCDATA_STATE) + -BIT_SHIFT(GLIBTOP_PROCDATA_UID) + -BIT_SHIFT(GLIBTOP_PROCDATA_PID) + -BIT_SHIFT(GLIBTOP_PROCDATA_PPID) + -BIT_SHIFT(GLIBTOP_PROCDATA_PGRP) + -BIT_SHIFT(GLIBTOP_PROCDATA_SESSION) + -BIT_SHIFT(GLIBTOP_PROCDATA_TTY) + -BIT_SHIFT(GLIBTOP_PROCDATA_TPGID) + -BIT_SHIFT(GLIBTOP_PROCDATA_PRIORITY) + -BIT_SHIFT(GLIBTOP_PROCDATA_NICE) + -BIT_SHIFT(GLIBTOP_PROCDATA_SIGNAL) + -BIT_SHIFT(GLIBTOP_PROCDATA_BLOCKED) + -BIT_SHIFT(GLIBTOP_PROCDATA_SIGIGNORE) + -BIT_SHIFT(GLIBTOP_PROCDATA_SIGCATCH) + -BIT_SHIFT(GLIBTOP_PROCDATA_START_TIME) + -BIT_SHIFT(GLIBTOP_PROCDATA_UTIME) + -BIT_SHIFT(GLIBTOP_PROCDATA_STIME) + -BIT_SHIFT(GLIBTOP_PROCDATA_CUTIME) + -BIT_SHIFT(GLIBTOP_PROCDATA_CSTIME) + -BIT_SHIFT(GLIBTOP_PROCDATA_SIZE) + -BIT_SHIFT(GLIBTOP_PROCDATA_RESIDENT) + -BIT_SHIFT(GLIBTOP_PROCDATA_SHARE) + -BIT_SHIFT(GLIBTOP_PROCDATA_TRS) + -BIT_SHIFT(GLIBTOP_PROCDATA_LRS) + -BIT_SHIFT(GLIBTOP_PROCDATA_DRS) + -BIT_SHIFT(GLIBTOP_PROCDATA_DT) + -BIT_SHIFT(GLIBTOP_PROCDATA_VSIZE) + -BIT_SHIFT(GLIBTOP_PROCDATA_RSS) + -BIT_SHIFT(GLIBTOP_PROCDATA_RSS_RLIM) + -BIT_SHIFT(GLIBTOP_PROCDATA_TIMEOUT) + -BIT_SHIFT(GLIBTOP_PROCDATA_IT_REAL_VALUE); - -static const unsigned long _glibtop_sysdeps_procdata_1 = -BIT_SHIFT(GLIBTOP_PROCDATA_K_FLAGS) + -BIT_SHIFT(GLIBTOP_PROCDATA_MIN_FLT) + -BIT_SHIFT(GLIBTOP_PROCDATA_MAJ_FLT) + -BIT_SHIFT(GLIBTOP_PROCDATA_CMIN_FLT) + -BIT_SHIFT(GLIBTOP_PROCDATA_CMAJ_FLT) + -BIT_SHIFT(GLIBTOP_PROCDATA_START_CODE) + -BIT_SHIFT(GLIBTOP_PROCDATA_END_CODE) + -BIT_SHIFT(GLIBTOP_PROCDATA_START_STACK) + -BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_ESP) + -BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_EIP) + -BIT_SHIFT(GLIBTOP_PROCDATA_WCHAN); - -/* Provides detailed information about a process. */ - -void -glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid) -{ - char input [BUFSIZ], *tmp; - struct stat statb; - int nread; - FILE *f; - - glibtop_init_r (&server, 0, 0); - - memset (buf, 0, sizeof (glibtop_procdata)); - - if (pid == 0) { - /* Client is only interested in the flags. */ - buf->flags [0] = _glibtop_sysdeps_procdata_0; - buf->flags [1] = _glibtop_sysdeps_procdata_1; - return; - } - - - sprintf (input, "/proc/%d/stat", pid); - - if (stat (input, &statb)) return; - - buf->uid = statb.st_uid; - - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; - } - - input [nread] = 0; - - /* This is from guile-utils/gtop/proc/readproc.c */ - - /* split into "PID (cmd" and "<rest>" */ - tmp = strrchr (input, ')'); - *tmp = '\0'; /* replace trailing ')' with NUL */ - /* parse these two strings separately, skipping the leading "(". */ - memset (buf->cmd, 0, sizeof (buf->cmd)); - sscanf (input, "%d (%39c", &buf->pid, buf->cmd); - sscanf(tmp + 2, /* skip space after ')' too */ - "%c %d %d %d %d %d %lu %lu %lu %lu %lu " - "%ld %ld %ld %ld %d %d %lu %lu %ld %lu " - "%lu %lu %lu %lu %lu %lu %lu %d %d %d %d %lu", - &buf->state, &buf->ppid, &buf->pgrp, &buf->session, - &buf->tty, &buf->tpgid, &buf->k_flags, &buf->min_flt, - &buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt, - &buf->utime, &buf->stime, &buf->cutime, &buf->cstime, - &buf->priority, &buf->nice, &buf->timeout, - &buf->it_real_value, &buf->start_time, &buf->vsize, - &buf->rss, &buf->rss_rlim, &buf->start_code, - &buf->end_code, &buf->start_stack, &buf->kstk_esp, - &buf->kstk_eip, &buf->signal, &buf->blocked, - &buf->sigignore, &buf->sigcatch, &buf->wchan); - - if (buf->tty == 0) - /* the old notty val, update elsewhere bef. moving to 0 */ - buf->tty = -1; - - if (server->os_version_code < LINUX_VERSION(1,3,39)) { - /* map old meanings to new */ - buf->priority = 2*15 - buf->priority; - buf->nice = 15 - buf->nice; - } - if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1) - /* when tty wasn't full devno */ - buf->tty = 4*0x100 + buf->tty; - - fclose (f); - - sprintf (input, "/proc/%d/statm", pid); - - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; - } - - input [nread] = 0; - - sscanf (input, "%ld %ld %ld %ld %ld %ld %ld", - &buf->size, &buf->resident, &buf->share, - &buf->trs, &buf->lrs, &buf->drs, &buf->dt); - - fclose (f); - - buf->flags [0] = _glibtop_sysdeps_procdata_0; - buf->flags [1] = _glibtop_sysdeps_procdata_1; -} diff --git a/sysdeps/freebsd/prockernel.c b/sysdeps/freebsd/prockernel.c deleted file mode 100644 index 832c81c4..00000000 --- a/sysdeps/freebsd/prockernel.c +++ /dev/null @@ -1,191 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/prockernel.h> - -#include <glibtop_suid.h> - -#include <kvm.h> -#include <sys/param.h> -#include <sys/sysctl.h> -#include <sys/proc.h> -#if (!defined __OpenBSD__) && (!defined __bsdi__) -#include <sys/user.h> -#endif -#if !defined(__bsdi__) && !(defined(__FreeBSD__) && defined(__alpha__)) -#include <machine/pcb.h> -#endif -#if defined(__FreeBSD__) && !defined(__alpha__) -#include <machine/tss.h> -#endif - -#include <unistd.h> -#include <fcntl.h> - -#ifdef HAVE_OSRELDATE_H -#include <osreldate.h> -#endif - -static const unsigned long _glibtop_sysdeps_proc_kernel_pstats = -(1L << GLIBTOP_PROC_KERNEL_MIN_FLT) + -(1L << GLIBTOP_PROC_KERNEL_MAJ_FLT) + -(1L << GLIBTOP_PROC_KERNEL_CMIN_FLT) + -(1L << GLIBTOP_PROC_KERNEL_CMAJ_FLT); - -static const unsigned long _glibtop_sysdeps_proc_kernel_pcb = -(1L << GLIBTOP_PROC_KERNEL_KSTK_EIP) + -(1L << GLIBTOP_PROC_KERNEL_KSTK_ESP); - -static const unsigned long _glibtop_sysdeps_proc_kernel_wchan = -(1L << GLIBTOP_PROC_KERNEL_NWCHAN) + -(1L << GLIBTOP_PROC_KERNEL_WCHAN); - -/* Init function. */ - -int -glibtop_init_proc_kernel_p (glibtop *server) -{ - server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel_pstats | - _glibtop_sysdeps_proc_kernel_pcb | - _glibtop_sysdeps_proc_kernel_wchan; - - return 0; -} - -int -glibtop_get_proc_kernel_p (glibtop *server, - glibtop_proc_kernel *buf, - pid_t pid) -{ - struct kinfo_proc *pinfo; - struct user *u_addr = (struct user *)USRSTACK; - struct pstats pstats; - struct pcb pcb; - int count; - - char filename [BUFSIZ]; - struct stat statb; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0); - - memset (buf, 0, sizeof (glibtop_proc_kernel)); - - if (server->sysdeps.proc_time == 0) - return -1; - - /* It does not work for the swapper task. */ - if (pid == 0) return -1; - - /* Get the process information */ - pinfo = kvm_getprocs (server->_priv->machine.kd, - KERN_PROC_PID, pid, &count); - if ((pinfo == NULL) || (count != 1)) - glibtop_error_io_r (server, "kvm_getprocs (%d)", pid); - - buf->nwchan = (unsigned long) pinfo [0].kp_proc.p_wchan &~ KERNBASE; - buf->flags |= (1L << GLIBTOP_PROC_KERNEL_NWCHAN); - - if (pinfo [0].kp_proc.p_wchan && pinfo [0].kp_proc.p_wmesg) { - strncpy (buf->wchan, pinfo [0].kp_eproc.e_wmesg, - sizeof (buf->wchan) - 1); - buf->wchan [sizeof (buf->wchan) - 1] = 0; - buf->flags |= (1L << GLIBTOP_PROC_KERNEL_WCHAN); - } else { - buf->wchan [0] = 0; - } - - /* Taken from `saveuser ()' in `/usr/src/bin/ps/ps.c'. */ - - /* [FIXME]: /usr/include/sys/user.h tells me that the user area - * may or may not be at the same kernel address in all - * processes, but I don't see any way to get that address. - * Since `ps' simply uses its own address, I think it's - * safe to do this here, too. */ - - /* NOTE: You need to mount the /proc filesystem to make - * `kvm_uread' work. */ - - sprintf (filename, "/proc/%d/mem", (int) pid); - if (stat (filename, &statb)) return -1; - - glibtop_suid_enter (server); - - if ((pinfo [0].kp_proc.p_flag & P_INMEM) && - kvm_uread (server->_priv->machine.kd, &(pinfo [0]).kp_proc, - (unsigned long) &u_addr->u_stats, - (char *) &pstats, sizeof (pstats)) == sizeof (pstats)) - { - /* - * The u-area might be swapped out, and we can't get - * at it because we have a crashdump and no swap. - * If it's here fill in these fields, otherwise, just - * leave them 0. - */ - - buf->min_flt = (u_int64_t) pstats.p_ru.ru_minflt; - buf->maj_flt = (u_int64_t) pstats.p_ru.ru_majflt; - buf->cmin_flt = (u_int64_t) pstats.p_cru.ru_minflt; - buf->cmaj_flt = (u_int64_t) pstats.p_cru.ru_majflt; - - buf->flags |= _glibtop_sysdeps_proc_kernel_pstats; - } - - if ((pinfo [0].kp_proc.p_flag & P_INMEM) && - kvm_uread (server->_priv->machine.kd, &(pinfo [0]).kp_proc, - (unsigned long) &u_addr->u_pcb, - (char *) &pcb, sizeof (pcb)) == sizeof (pcb)) - { -#ifdef __FreeBSD__ -#ifndef __alpha__ -#if (__FreeBSD_version >= 300003) - buf->kstk_esp = (u_int64_t) pcb.pcb_esp; - buf->kstk_eip = (u_int64_t) pcb.pcb_eip; -#else - buf->kstk_esp = (u_int64_t) pcb.pcb_ksp; - buf->kstk_eip = (u_int64_t) pcb.pcb_pc; -#endif -#else - /*xxx FreeBSD/Alpha? */ -#endif -#else - buf->kstk_esp = (u_int64_t) pcb.pcb_tss.tss_esp0; -#ifdef __bsdi__ - buf->kstk_eip = (u_int64_t) pcb.pcb_tss.tss_eip; -#else - buf->kstk_eip = (u_int64_t) pcb.pcb_tss.__tss_eip; -#endif - - buf->flags |= _glibtop_sysdeps_proc_kernel_pcb; -#endif - } - - /* Taken from `wchan ()' in `/usr/src/bin/ps/print.c'. */ - - glibtop_suid_leave (server); - - return 0; -} diff --git a/sysdeps/freebsd/proclist.c b/sysdeps/freebsd/proclist.c deleted file mode 100644 index bb4e0de8..00000000 --- a/sysdeps/freebsd/proclist.c +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/proclist.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proclist = -(1L << GLIBTOP_PROCLIST_TOTAL) + (1L << GLIBTOP_PROCLIST_NUMBER) + -(1L << GLIBTOP_PROCLIST_SIZE); - -/* Fetch list of currently running processes. - * The interface of this function is a little bit different from the others: - * buf->flags is only set if the call succeeded, in this case pids_chain, - * a list of the pids of all currently running processes is returned, - * buf->number is the number of elements of this list and buf->size is - * the size of one single element (sizeof (unsigned)). The total size is - * stored in buf->total. - * - * The calling function has to free the memory to which a pointer is returned. - * - * IMPORTANT NOTE: - * On error, this function MUST return NULL and set buf->flags to zero ! - * On success, it returnes a pointer to a list of buf->number elements - * each buf->size big. The total size is stored in buf->total. - * The calling function has to free the memory to which a pointer is returned. - * - * On error, NULL is returned and buf->flags is zero. */ - -/* Init function. */ - -int -glibtop_init_proclist_p (glibtop *server) -{ - server->sysdeps.proclist = _glibtop_sysdeps_proclist; - - return 0; -} - -unsigned * -glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf, - int64_t real_which, int64_t arg) -{ - struct kinfo_proc *pinfo; - unsigned *pids = NULL; - int which, count; - int i,j; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0); - - memset (buf, 0, sizeof (glibtop_proclist)); - - which = (int)(real_which & GLIBTOP_KERN_PROC_MASK); - - /* Get the process data */ - pinfo = kvm_getprocs (server->_priv->machine.kd, which, arg, &count); - if ((pinfo == NULL) || (count < 1)) { - glibtop_warn_io_r (server, "kvm_getprocs (proclist)"); - return NULL; - } - count--; - - /* Allocate count objects in the pids_chain array - * Same as malloc is pids is NULL, which it is. */ - pids = glibtop_realloc_r (server, pids, count * sizeof (unsigned)); - /* Copy the pids over to this chain */ - for (i=j=0; i < count; i++) { - if ((real_which & GLIBTOP_EXCLUDE_IDLE) && - (pinfo[i].kp_proc.p_stat != SRUN)) - continue; - else if ((real_which & GLIBTOP_EXCLUDE_SYSTEM) && - (pinfo[i].kp_eproc.e_pcred.p_ruid == 0)) - continue; - pids [j++] = (unsigned) pinfo[i].kp_proc.p_pid; - } /* end for */ - /* Set the fields in buf */ - buf->number = j; - buf->size = sizeof (unsigned); - buf->total = j * sizeof (unsigned); - buf->flags = _glibtop_sysdeps_proclist; - return pids; -} diff --git a/sysdeps/freebsd/procmap.c b/sysdeps/freebsd/procmap.c deleted file mode 100644 index 686caebb..00000000 --- a/sysdeps/freebsd/procmap.c +++ /dev/null @@ -1,271 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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> - -#include <glibtop_suid.h> - -#include <kvm.h> -#include <sys/param.h> -#include <sys/proc.h> -#include <sys/resource.h> -#include <vm/vm_object.h> -#include <vm/vm_prot.h> -#include <vm/vm_map.h> - -#include <sys/vnode.h> -#include <sys/mount.h> -#include <ufs/ufs/quota.h> -#include <ufs/ufs/inode.h> - -#include <sys/ucred.h> -#if (!defined __OpenBSD__) && (!defined __bsdi__) -#include <sys/user.h> -#endif -#include <sys/sysctl.h> -#include <vm/vm.h> - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) -/* Fixme ... */ -#undef _KERNEL -#define _UVM_UVM_AMAP_I_H_ 1 -#define _UVM_UVM_MAP_I_H_ 1 -#include <uvm/uvm.h> -#endif - -static const unsigned long _glibtop_sysdeps_proc_map = -(1L << GLIBTOP_PROC_MAP_TOTAL) + (1L << GLIBTOP_PROC_MAP_NUMBER) + -(1L << GLIBTOP_PROC_MAP_SIZE); - -static const unsigned long _glibtop_sysdeps_map_entry = -(1L << GLIBTOP_MAP_ENTRY_START) + (1L << GLIBTOP_MAP_ENTRY_END) + -(1L << GLIBTOP_MAP_ENTRY_OFFSET) + (1L << GLIBTOP_MAP_ENTRY_PERM) + -(1L << GLIBTOP_MAP_ENTRY_INODE) + (1L << GLIBTOP_MAP_ENTRY_DEVICE); - -/* Init function. */ - -int -glibtop_init_proc_map_p (glibtop *server) -{ - server->sysdeps.proc_map = _glibtop_sysdeps_proc_map; - - return 0; -} - -/* Provides detailed information about a process. */ - -glibtop_map_entry * -glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf, - pid_t pid) -{ - struct kinfo_proc *pinfo; - struct vm_map_entry entry, *first; - struct vmspace vmspace; -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - struct vnode vnode; - struct inode inode; -#else - struct vm_object object; -#endif - glibtop_map_entry *maps; -#if defined __FreeBSD__ - struct vnode vnode; - struct inode inode; - struct mount mount; -#endif - int count, i = 0; - int update = 0; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MAP), 0); - - memset (buf, 0, sizeof (glibtop_proc_map)); - - /* It does not work for the swapper task. */ - if (pid == 0) return NULL; - - glibtop_suid_enter (server); - - /* Get the process data */ - pinfo = kvm_getprocs (server->_priv->machine.kd, - KERN_PROC_PID, pid, &count); - if ((pinfo == NULL) || (count < 1)) - glibtop_error_io_r (server, "kvm_getprocs (%d)", pid); - - /* Now we get the memory maps. */ - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) pinfo [0].kp_proc.p_vmspace, - (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) - glibtop_error_io_r (server, "kvm_read (vmspace)"); - - first = vmspace.vm_map.header.next; - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) vmspace.vm_map.header.next, - (char *) &entry, sizeof (entry)) != sizeof (entry)) - glibtop_error_io_r (server, "kvm_read (entry)"); - - /* Allocate space. */ - - buf->number = vmspace.vm_map.nentries; - buf->size = sizeof (glibtop_map_entry); - - buf->total = buf->number * buf->size; - - maps = glibtop_malloc_r (server, buf->total); - - memset (maps, 0, buf->total); - - buf->flags = _glibtop_sysdeps_proc_map; - - /* Walk through the `vm_map_entry' list ... */ - - /* I tested this a few times with `mmap'; as soon as you write - * to the mmap'ed area, the object type changes from OBJT_VNODE - * to OBJT_DEFAULT so if seems this really works. */ - - do { - if (update) { - if (kvm_read (server->_priv->machine.kd, - (unsigned long) entry.next, - &entry, sizeof (entry)) != sizeof (entry)) - glibtop_error_io_r (server, "kvm_read (entry)"); - } else { - update = 1; - } - -#ifdef __FreeBSD__ -#if __FreeBSD__ >= 4 - if (entry.eflags & (MAP_ENTRY_IS_SUB_MAP)) - continue; -#else - if (entry.eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP)) - continue; -#endif -#else -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - if (UVM_ET_ISSUBMAP (&entry)) - continue; -#else - if (entry.is_a_map || entry.is_sub_map) - continue; -#endif -#endif - - maps [i].flags = _glibtop_sysdeps_map_entry; - - maps [i].start = entry.start; - maps [i].end = entry.end; - maps [i].offset = entry.offset; - - maps [i].perm = 0; - - if (entry.protection & VM_PROT_READ) - maps [i].perm |= GLIBTOP_MAP_PERM_READ; - if (entry.protection & VM_PROT_WRITE) - maps [i].perm |= GLIBTOP_MAP_PERM_WRITE; - if (entry.protection & VM_PROT_EXECUTE) - maps [i].perm |= GLIBTOP_MAP_PERM_EXECUTE; - - i++; - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - if (!entry.object.uvm_obj) - continue; - - /* We're only interested in vnodes */ - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) entry.object.uvm_obj, - &vnode, sizeof (vnode)) != sizeof (vnode)) { - glibtop_warn_io_r (server, "kvm_read (vnode)"); - return NULL; - } -#else - if (!entry.object.vm_object) - continue; - - /* We're only interested in `vm_object's */ - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) entry.object.vm_object, - &object, sizeof (object)) != sizeof (object)) - glibtop_error_io_r (server, "kvm_read (object)"); -#endif - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - if (!vnode.v_uvm.u_flags & UVM_VNODE_VALID) - continue; - - if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) || - !vnode.v_data) continue; - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) vnode.v_data, - &inode, sizeof (inode)) != sizeof (inode)) - glibtop_error_io_r (server, "kvm_read (inode)"); - - maps [i-1].inode = inode.i_number; - maps [i-1].device = inode.i_dev; -#endif - - -#ifdef __FreeBSD__ - /* If the object is of type vnode, add its size */ - - if (object.type != OBJT_VNODE) - continue; - - if (!object.handle) - continue; - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) object.handle, - &vnode, sizeof (vnode)) != sizeof (vnode)) - glibtop_error_io_r (server, "kvm_read (vnode)"); - - if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) || - !vnode.v_data) continue; - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) vnode.v_data, - &inode, sizeof (inode)) != sizeof (inode)) - glibtop_error_io_r (server, "kvm_read (inode)"); - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) vnode.v_mount, - &mount, sizeof (mount)) != sizeof (mount)) - glibtop_error_io_r (server, "kvm_read (mount)"); - - maps [i-1].inode = inode.i_number; - maps [i-1].device = inode.i_dev; -#endif - } while (entry.next != first); - - return maps; -} diff --git a/sysdeps/freebsd/procmem.c b/sysdeps/freebsd/procmem.c deleted file mode 100644 index 8fb6b999..00000000 --- a/sysdeps/freebsd/procmem.c +++ /dev/null @@ -1,266 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procmem.h> - -#include <glibtop_suid.h> - -#include <kvm.h> -#include <sys/param.h> -#include <sys/proc.h> -#include <sys/resource.h> -#include <vm/vm_object.h> -#include <vm/vm_map.h> - -#include <sys/vnode.h> -#include <ufs/ufs/quota.h> -#include <ufs/ufs/inode.h> - -#include <sys/ucred.h> -#if (!defined __OpenBSD__) && (!defined __bsdi__) -#include <sys/user.h> -#endif -#include <sys/sysctl.h> -#include <vm/vm.h> - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) -/* Fixme ... */ -#undef _KERNEL -#define _UVM_UVM_AMAP_I_H_ 1 -#define _UVM_UVM_MAP_I_H_ 1 -#include <uvm/uvm.h> -#endif - -static const unsigned long _glibtop_sysdeps_proc_mem = -(1L << GLIBTOP_PROC_MEM_SIZE) + -(1L << GLIBTOP_PROC_MEM_VSIZE) + -(1L << GLIBTOP_PROC_MEM_RESIDENT) + -(1L << GLIBTOP_PROC_MEM_RSS) + -(1L << GLIBTOP_PROC_MEM_RSS_RLIM); - -static const unsigned long _glibtop_sysdeps_proc_mem_share = -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) -(1L << GLIBTOP_PROC_MEM_SHARE); -#elif defined(__FreeBSD__) -(1L << GLIBTOP_PROC_MEM_SHARE); -#else -0; -#endif - -#ifndef LOG1024 -#define LOG1024 10 -#endif - -/* these are for getting the memory statistics */ -static int pageshift; /* log base 2 of the pagesize */ - -/* define pagetok in terms of pageshift */ -#define pagetok(size) ((size) << pageshift) - -/* Init function. */ - -int -glibtop_init_proc_mem_p (glibtop *server) -{ - register int pagesize; - - /* get the page size with "getpagesize" and calculate pageshift - * from it */ - pagesize = getpagesize (); - pageshift = 0; - while (pagesize > 1) { - pageshift++; - pagesize >>= 1; - } - - /* we only need the amount of log(2)1024 for our conversion */ - pageshift -= LOG1024; - - server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem | - _glibtop_sysdeps_proc_mem_share; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf, - pid_t pid) -{ - struct kinfo_proc *pinfo; - struct vm_map_entry entry, *first; - struct vmspace *vms, vmspace; -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - struct vnode vnode; - struct inode inode; -#else - struct vm_object object; -#endif - struct plimit plimit; - int count; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MEM), 0); - - memset (buf, 0, sizeof (glibtop_proc_mem)); - - if (server->sysdeps.proc_mem == 0) - return -1; - - /* It does not work for the swapper task. */ - if (pid == 0) return -1; - - /* Get the process data */ - pinfo = kvm_getprocs (server->_priv->machine.kd, - KERN_PROC_PID, pid, &count); - if ((pinfo == NULL) || (count < 1)) { - glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); - return -1; - } - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) pinfo [0].kp_proc.p_limit, - (char *) &plimit, sizeof (plimit)) != sizeof (plimit)) { - glibtop_warn_io_r (server, "kvm_read (plimit)"); - return -1; - } - - buf->rss_rlim = (u_int64_t) - (plimit.pl_rlimit [RLIMIT_RSS].rlim_cur); - - vms = &pinfo [0].kp_eproc.e_vm; - - buf->vsize = buf->size = (u_int64_t) pagetok - (vms->vm_tsize + vms->vm_dsize + vms->vm_ssize) << LOG1024; - - buf->resident = buf->rss = (u_int64_t) pagetok - (vms->vm_rssize) << LOG1024; - - /* Now we get the shared memory. */ - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) pinfo [0].kp_proc.p_vmspace, - (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) { - glibtop_warn_io_r (server, "kvm_read (vmspace)"); - return -1; - } - - first = vmspace.vm_map.header.next; - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) vmspace.vm_map.header.next, - (char *) &entry, sizeof (entry)) != sizeof (entry)) { - glibtop_warn_io_r (server, "kvm_read (entry)"); - return -1; - } - - /* Walk through the `vm_map_entry' list ... */ - - /* I tested this a few times with `mmap'; as soon as you write - * to the mmap'ed area, the object type changes from OBJT_VNODE - * to OBJT_DEFAULT so if seems this really works. */ - - while (entry.next != first) { - if (kvm_read (server->_priv->machine.kd, - (unsigned long) entry.next, - &entry, sizeof (entry)) != sizeof (entry)) { - glibtop_warn_io_r (server, "kvm_read (entry)"); - return -1; - } - -#ifdef __FreeBSD__ -#if __FreeBSD__ >= 4 - if (entry.eflags & (MAP_ENTRY_IS_SUB_MAP)) - continue; -#else - if (entry.eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP)) - continue; -#endif -#else -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - if (UVM_ET_ISSUBMAP (&entry)) - continue; -#else - if (entry.is_a_map || entry.is_sub_map) - continue; -#endif -#endif - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - if (!entry.object.uvm_obj) - continue; - - /* We're only interested in vnodes */ - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) entry.object.uvm_obj, - &vnode, sizeof (vnode)) != sizeof (vnode)) { - glibtop_warn_io_r (server, "kvm_read (vnode)"); - return -1; - } -#else - if (!entry.object.vm_object) - continue; - - /* We're only interested in `vm_object's */ - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) entry.object.vm_object, - &object, sizeof (object)) != sizeof (object)) { - glibtop_warn_io_r (server, "kvm_read (object)"); - return -1; - } -#endif - /* If the object is of type vnode, add its size */ - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - if (!vnode.v_uvm.u_flags & UVM_VNODE_VALID) - continue; - - if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) || - !vnode.v_data) continue; - - /* Reference count must be at least two. */ - if (vnode.v_uvm.u_obj.uo_refs <= 1) - continue; - - buf->share += pagetok (vnode.v_uvm.u_obj.uo_npages) << LOG1024; -#endif - -#ifdef __FreeBSD__ - if (object.type != OBJT_VNODE) - continue; - - buf->share += object.un_pager.vnp.vnp_size; -#endif - } - - buf->flags = _glibtop_sysdeps_proc_mem | - _glibtop_sysdeps_proc_mem_share; - - return 0; -} diff --git a/sysdeps/freebsd/procsegment.c b/sysdeps/freebsd/procsegment.c deleted file mode 100644 index 03045fc4..00000000 --- a/sysdeps/freebsd/procsegment.c +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procsegment.h> - -#include <glibtop_suid.h> - -#include <kvm.h> -#include <sys/param.h> -#include <sys/sysctl.h> - -static const unsigned long _glibtop_sysdeps_proc_segment = 0; - -/* Init function. */ - -int -glibtop_init_proc_segment_p (glibtop *server) -{ - server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_segment_p (glibtop *server, - glibtop_proc_segment *buf, - pid_t pid) -{ - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0); - - memset (buf, 0, sizeof (glibtop_proc_segment)); - -#if 0 - /* Get the process info from the kernel */ - kvm_getprocs (server->_priv->machine.kd, KERN_PROC_PID, pid, count); - if (*count != 1) { - return -1; /* the zeroed-out buffer indicating no data */ - } - - /* trs: text resident set size - pinfo[0]->kp_eproc.e_xrssize; - */ - /* buf->trs = pinfo[0]->kp_eproc.e_xrssize; */ - /* lrs: shared-lib resident set size - ? */ - /* drs: data resident set size - pinfo[0]->kp_eproc.e_vm.vm_map.vm_dsize; - */ - /* dt: dirty pages - */ - /* start_code: address of beginning of code segment - - */ - /* end_code: address of end of code segment - */ - /* start_stack: address of the bottom of stack segment - */ -#endif - - return 0; -} - diff --git a/sysdeps/freebsd/procsignal.c b/sysdeps/freebsd/procsignal.c deleted file mode 100644 index 5bcd3f92..00000000 --- a/sysdeps/freebsd/procsignal.c +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procsignal.h> - -#include <glibtop_suid.h> - -#ifdef HAVE_OSRELDATE_H -#include <osreldate.h> -#endif - -static const unsigned long _glibtop_sysdeps_proc_signal = -(1L << GLIBTOP_PROC_SIGNAL_SIGNAL) + -(1L << GLIBTOP_PROC_SIGNAL_BLOCKED) + -(1L << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + -(1L << GLIBTOP_PROC_SIGNAL_SIGCATCH); - -/* Init function. */ - -int -glibtop_init_proc_signal_p (glibtop *server) -{ - server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal; - - return 0; -} - -int -glibtop_get_proc_signal_p (glibtop *server, - glibtop_proc_signal *buf, - pid_t pid) -{ - struct kinfo_proc *pinfo; - int count = 0; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0); - - memset (buf, 0, sizeof (glibtop_proc_signal)); - - /* It does not work for the swapper task. */ - if (pid == 0) return -1; - - /* Get the process information */ - pinfo = kvm_getprocs (server->_priv->machine.kd, - KERN_PROC_PID, pid, &count); - if ((pinfo == NULL) || (count != 1)) { - glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); - return -1; - } - - /* signal: mask of pending signals. - * pinfo [0].kp_proc.p_siglist - */ -#if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011) - buf->signal [0] = pinfo [0].kp_proc.p_siglist.__bits[0]; -#else - buf->signal [0] = pinfo [0].kp_proc.p_siglist; -#endif - - /* blocked: mask of blocked signals. - * pinfo [0].kp_proc.p_sigmask - */ -#if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011) - buf->blocked [0] = pinfo [0].kp_proc.p_sigmask.__bits[0]; -#else - buf->blocked [0] = pinfo [0].kp_proc.p_sigmask; -#endif - - /* sigignore: mask of ignored signals. - * pinfo [0].kp_proc.p_sigignore - */ -#if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011) - buf->sigignore [0] = pinfo [0].kp_proc.p_sigignore.__bits[0]; -#else - buf->sigignore [0] = pinfo [0].kp_proc.p_sigignore; -#endif - - /* sigcatch: mask of caught signals. - * pinfo [0].kp_proc.p_sigcatch - */ -#if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011) - buf->sigcatch [0] = pinfo [0].kp_proc.p_sigcatch.__bits[0]; -#else - buf->sigcatch [0] = pinfo [0].kp_proc.p_sigcatch; -#endif - - buf->flags = _glibtop_sysdeps_proc_signal; - - return 0; -} diff --git a/sysdeps/freebsd/procstate.c b/sysdeps/freebsd/procstate.c deleted file mode 100644 index 1839f2e7..00000000 --- a/sysdeps/freebsd/procstate.c +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998 Joshua Sled - This file is part of LibGTop 1.0. - - Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procstate.h> - -#include <glibtop_suid.h> - -#if !defined(__OpenBSD__) -//&& (!defined __bsdi__) -#include <sys/user.h> -#endif - -static const unsigned long _glibtop_sysdeps_proc_state = -(1L << GLIBTOP_PROC_STATE_CMD) + (1L << GLIBTOP_PROC_STATE_UID) + -(1L << GLIBTOP_PROC_STATE_GID); - -static const unsigned long _glibtop_sysdeps_proc_state_new = -#if LIBGTOP_VERSION_CODE >= 1001000 -(1L << GLIBTOP_PROC_STATE_RUID) + (1L << GLIBTOP_PROC_STATE_RGID); -#else -0; -#endif - -/* Init function. */ - -int -glibtop_init_proc_state_p (glibtop *server) -{ - server->sysdeps.proc_state = _glibtop_sysdeps_proc_state | - _glibtop_sysdeps_proc_state_new; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_state_p (glibtop *server, - glibtop_proc_state *buf, - pid_t pid) -{ - struct kinfo_proc *pinfo; - int count = 0; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_STATE), 0); - - memset (buf, 0, sizeof (glibtop_proc_state)); - - /* It does not work for the swapper task. */ - if (pid == 0) return -1; - - /* Get the process information */ - pinfo = kvm_getprocs (server->_priv->machine.kd, - KERN_PROC_PID, pid, &count); - if ((pinfo == NULL) || (count != 1)) { - glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); - return -1; - } - - strncpy (buf->cmd, pinfo [0].kp_proc.p_comm, sizeof (buf->cmd)-1); - buf->cmd [sizeof (buf->cmd)-1] = 0; - - buf->uid = pinfo [0].kp_eproc.e_pcred.p_svuid; - buf->gid = pinfo [0].kp_eproc.e_pcred.p_svgid; - -#if LIBGTOP_VERSION_CODE >= 1001000 - buf->ruid = pinfo [0].kp_eproc.e_pcred.p_ruid; - buf->rgid = pinfo [0].kp_eproc.e_pcred.p_rgid; -#endif - - /* Set the flags for the data we're about to return*/ - buf->flags = _glibtop_sysdeps_proc_state | - _glibtop_sysdeps_proc_state_new; - -#if LIBGTOP_VERSION_CODE >= 1001000 - switch (pinfo [0].kp_proc.p_stat) { - case SIDL: - buf->state = 0; - break; - case SRUN: - buf->state = GLIBTOP_PROCESS_RUNNING; - break; - case SSLEEP: - buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE; - break; - case SSTOP: - buf->state = GLIBTOP_PROCESS_STOPPED; - break; - case SZOMB: - buf->state = GLIBTOP_PROCESS_ZOMBIE; - break; - default: - return -1; - } -#else - switch (pinfo [0].kp_proc.p_stat) { - case SIDL: - buf->state = 'S'; - break; - case SRUN: - buf->state = 'R'; - break; - case SSLEEP: - buf->state = 'S'; - break; - case SSTOP: - buf->state = 'T'; - break; - case SZOMB: - buf->state = 'Z'; - break; - default: - return -1; - } -#endif - - buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE); - - return 0; -} diff --git a/sysdeps/freebsd/proctime.c b/sysdeps/freebsd/proctime.c deleted file mode 100644 index e7b35b3e..00000000 --- a/sysdeps/freebsd/proctime.c +++ /dev/null @@ -1,236 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/proctime.h> - -#include <glibtop_suid.h> - -#ifdef HAVE_OSRELDATE_H -#include <osreldate.h> -#endif - -static const unsigned long _glibtop_sysdeps_proc_time = -(1L << GLIBTOP_PROC_TIME_RTIME) + (1L << GLIBTOP_PROC_TIME_FREQUENCY); - -static const unsigned long _glibtop_sysdeps_proc_time_user = -(1L << GLIBTOP_PROC_TIME_UTIME) + (1L << GLIBTOP_PROC_TIME_STIME) + -(1L << GLIBTOP_PROC_TIME_CUTIME) + (1L << GLIBTOP_PROC_TIME_CSTIME) + -(1L << GLIBTOP_PROC_TIME_START_TIME); - -#define tv2sec(tv) (((u_int64_t) tv.tv_sec * 1000000) + (u_int64_t) tv.tv_usec) - -/* Init function. */ - -int -glibtop_init_proc_time_p (glibtop *server) -{ - server->sysdeps.proc_time = _glibtop_sysdeps_proc_time | - _glibtop_sysdeps_proc_time_user; - - return 0; -} - -/* Taken from /usr/src/sys/kern/kern_resource.c */ - -/* - * Transform the running time and tick information in proc p into user, - * system, and interrupt time usage. - */ - -static void -calcru(p, up, sp, ip) - struct proc *p; - struct timeval *up; - struct timeval *sp; - struct timeval *ip; -{ - quad_t totusec; - u_quad_t u, st, ut, it, tot; -#if (__FreeBSD_version < 300003) - long sec, usec; -#endif - struct timeval tv; - - st = p->p_sticks; - ut = p->p_uticks; - it = p->p_iticks; - - tot = st + ut + it; - if (tot == 0) { - st = 1; - tot = 1; - } - -#if (defined __FreeBSD__) && (__FreeBSD_version >= 300003) - - /* This was changed from a `struct timeval' into a `u_int64_t' - * on FreeBSD 3.0 and renamed p_rtime -> p_runtime. - */ - - totusec = (u_quad_t) p->p_runtime; -#else - sec = p->p_rtime.tv_sec; - usec = p->p_rtime.tv_usec; - - totusec = (quad_t)sec * 1000000 + usec; -#endif - - if (totusec < 0) { - /* XXX no %qd in kernel. Truncate. */ - fprintf (stderr, "calcru: negative time: %ld usec\n", - (long)totusec); - totusec = 0; - } - - - u = totusec; - st = (u * st) / tot; - sp->tv_sec = st / 1000000; - sp->tv_usec = st % 1000000; - ut = (u * ut) / tot; - up->tv_sec = ut / 1000000; - up->tv_usec = ut % 1000000; - if (ip != NULL) { - it = (u * it) / tot; - ip->tv_sec = it / 1000000; - ip->tv_usec = it % 1000000; - } -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf, - pid_t pid) -{ - struct kinfo_proc *pinfo; -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - register struct rusage *rup; -#else - struct user *u_addr = (struct user *)USRSTACK; -#endif - struct pstats pstats; - int count; - - char filename [BUFSIZ]; - struct stat statb; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0); - - memset (buf, 0, sizeof (glibtop_proc_time)); - - /* It does not work for the swapper task. */ - if (pid == 0) return -1; - -#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)) - if (server->sysdeps.proc_time == 0) - return -1; - -#ifndef __bsdi__ - sprintf (filename, "/proc/%d/mem", (int) pid); - if (stat (filename, &statb)) return -1; -#endif -#endif - - /* Get the process information */ - pinfo = kvm_getprocs (server->_priv->machine.kd, - KERN_PROC_PID, pid, &count); - if ((pinfo == NULL) || (count != 1)) - glibtop_error_io_r (server, "kvm_getprocs (%d)", pid); - -#if (defined __FreeBSD__) && (__FreeBSD_version >= 300003) - buf->rtime = pinfo [0].kp_proc.p_runtime; -#else - buf->rtime = tv2sec (pinfo [0].kp_proc.p_rtime); -#endif - - buf->frequency = 1000000; - buf->flags = _glibtop_sysdeps_proc_time; - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - glibtop_suid_enter (server); - - if (kvm_read (server->_priv->machine.kd, - (unsigned long) pinfo [0].kp_proc.p_stats, - &pstats, sizeof (pstats)) != sizeof (pstats)) { - glibtop_warn_io_r (server, "kvm_read (pstats)"); - return -1; - } - - glibtop_suid_leave (server); - - rup = &pstats.p_ru; - calcru(&(pinfo [0]).kp_proc, - &rup->ru_utime, &rup->ru_stime, NULL); - - buf->utime = tv2sec (pstats.p_ru.ru_utime); - buf->stime = tv2sec (pstats.p_ru.ru_stime); - - buf->cutime = tv2sec (pstats.p_cru.ru_utime); - buf->cstime = tv2sec (pstats.p_cru.ru_stime); - - buf->start_time = (u_int64_t) pstats.p_start.tv_sec; - - buf->flags |= _glibtop_sysdeps_proc_time_user; -#else - glibtop_suid_enter (server); - - if ((pinfo [0].kp_proc.p_flag & P_INMEM) && - kvm_uread (server->_priv->machine.kd, &(pinfo [0]).kp_proc, - (unsigned long) &u_addr->u_stats, - (char *) &pstats, sizeof (pstats)) == sizeof (pstats)) - { - /* This is taken form the kernel source code of - * FreeBSD 2.2.6. */ - - /* Well, we just do the same getrusage () does ... */ - - register struct rusage *rup; - - glibtop_suid_leave (server); - - rup = &pstats.p_ru; - calcru(&(pinfo [0]).kp_proc, - &rup->ru_utime, &rup->ru_stime, NULL); - - buf->utime = tv2sec (pstats.p_ru.ru_utime); - buf->stime = tv2sec (pstats.p_ru.ru_stime); - - buf->cutime = tv2sec (pstats.p_cru.ru_utime); - buf->cstime = tv2sec (pstats.p_cru.ru_stime); - - buf->start_time = tv2sec (pstats.p_start); - - buf->flags = _glibtop_sysdeps_proc_time_user; - } - - glibtop_suid_leave (server); -#endif - - return 0; -} - diff --git a/sysdeps/freebsd/procuid.c b/sysdeps/freebsd/procuid.c deleted file mode 100644 index 956a3a73..00000000 --- a/sysdeps/freebsd/procuid.c +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procuid.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_uid = -(1L << GLIBTOP_PROC_UID_UID) + (1L << GLIBTOP_PROC_UID_EUID) + -(1L << GLIBTOP_PROC_UID_EGID) + (1L << GLIBTOP_PROC_UID_PID) + -(1L << GLIBTOP_PROC_UID_PPID) + (1L << GLIBTOP_PROC_UID_PGRP) + -(1L << GLIBTOP_PROC_UID_TPGID) + (1L << GLIBTOP_PROC_UID_PRIORITY) + -(1L << GLIBTOP_PROC_UID_NICE); - -static const unsigned long _glibtop_sysdeps_proc_uid_groups = -#if LIBGTOP_VERSION_CODE >= 1001000 -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) -(1L << GLIBTOP_PROC_UID_NGROUPS) + (1L << GLIBTOP_PROC_UID_GROUPS); -#else -0L; -#endif -#else /* LIBGTOP_VERSION_CODE < 1001000 */ -0L; -#endif - -/* Init function. */ - -int -glibtop_init_proc_uid_p (glibtop *server) -{ - server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid | - _glibtop_sysdeps_proc_uid_groups; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf, - pid_t pid) -{ - struct kinfo_proc *pinfo; - int count = 0; - -#if LIBGTOP_VERSION_CODE >= 1001000 -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - struct ucred ucred; - void *ucred_ptr; -#endif -#endif - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_UID), 0); - - memset (buf, 0, sizeof (glibtop_proc_uid)); - - /* It does not work for the swapper task. */ - if (pid == 0) return -1; - - /* Get the process information */ - pinfo = kvm_getprocs (server->_priv->machine.kd, - KERN_PROC_PID, pid, &count); - if ((pinfo == NULL) || (count != 1)) { - glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); - return -1; - } - - buf->uid = pinfo [0].kp_eproc.e_pcred.p_ruid; - buf->euid = pinfo [0].kp_eproc.e_pcred.p_svuid; - buf->gid = pinfo [0].kp_eproc.e_pcred.p_rgid; - buf->egid = pinfo [0].kp_eproc.e_pcred.p_svgid; - - buf->ppid = pinfo [0].kp_eproc.e_ppid; - buf->pgrp = pinfo [0].kp_eproc.e_pgid; - buf->tpgid = pinfo [0].kp_eproc.e_tpgid; - - buf->nice = pinfo [0].kp_proc.p_nice; - buf->priority = pinfo [0].kp_proc.p_priority; - - /* Set the flags for the data we're about to return*/ - buf->flags = _glibtop_sysdeps_proc_uid; - - /* Use LibGTop conditionals here so we can more easily merge this - * code into the LIBGTOP_STABLE_1_0 branch. */ -#if LIBGTOP_VERSION_CODE >= 1001000 - /* This probably also works with other versions, but not yet - * tested. Please remove the conditional if this is true. */ -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - ucred_ptr = (void *) pinfo [0].kp_eproc.e_pcred.pc_ucred; - - if (ucred_ptr) { - if (kvm_read (server->_priv->machine.kd, - (unsigned long) ucred_ptr, - &ucred, sizeof (ucred)) != sizeof (ucred)) { - glibtop_warn_io_r (server, "kvm_read (ucred)"); - } else { - int count = (ucred.cr_ngroups < GLIBTOP_MAX_GROUPS) ? - ucred.cr_ngroups : GLIBTOP_MAX_GROUPS; - int i; - - for (i = 0; i < count; i++) - buf->groups [i] = ucred.cr_groups [i]; - buf->ngroups = count; - - buf->flags |= _glibtop_sysdeps_proc_uid_groups; - } - } -#endif -#endif - - return 0; -} diff --git a/sysdeps/freebsd/sem_limits.c b/sysdeps/freebsd/sem_limits.c deleted file mode 100644 index c0c91471..00000000 --- a/sysdeps/freebsd/sem_limits.c +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, August 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/sem_limits.h> - -#include <glibtop_suid.h> - -#if defined(__bsdi__) && (_BSDI_VERSION < 199700) -/* Older versions of BSDI don't seem to have this. */ - -int -glibtop_init_sem_limits_p (glibtop *server) -{ - - return 0; -} - -int -glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf) -{ - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0); - - memset (buf, 0, sizeof (glibtop_sem_limits)); - - return 0; -} - -#else - -/* #define KERNEL to get declaration of `struct seminfo'. */ - -#if defined(__FreeBSD__) || defined(__bsdi__) -#define KERNEL 1 -#else -#define _KERNEL 1 -#endif - -#include <sys/ipc.h> -#include <sys/sem.h> - -static unsigned long _glibtop_sysdeps_sem_limits = -(1L << GLIBTOP_SEM_LIMITS_SEMMAP) + (1L << GLIBTOP_SEM_LIMITS_SEMMNI) + -(1L << GLIBTOP_SEM_LIMITS_SEMMNS) + (1L << GLIBTOP_SEM_LIMITS_SEMMNU) + -(1L << GLIBTOP_SEM_LIMITS_SEMMSL) + (1L << GLIBTOP_SEM_LIMITS_SEMOPM) + -(1L << GLIBTOP_SEM_LIMITS_SEMUME) + (1L << GLIBTOP_SEM_LIMITS_SEMUSZ) + -(1L << GLIBTOP_SEM_LIMITS_SEMVMX) + (1L << GLIBTOP_SEM_LIMITS_SEMAEM); - -/* The values in this structure never change at runtime, so we only - * read it once during initialization. We have to use the name `_seminfo' - * since `seminfo' is already declared external in <sys/sem.h>. */ -static struct seminfo _seminfo; - -/* nlist structure for kernel access */ -static struct nlist nlst [] = { - { "_seminfo" }, - { 0 } -}; - -/* Init function. */ - -int -glibtop_init_sem_limits_p (glibtop *server) -{ - if (kvm_nlist (server->_priv->machine.kd, nlst) < 0) { - glibtop_warn_io_r (server, "kvm_nlist (sem_limits)"); - return -1; - } - - if (kvm_read (server->_priv->machine.kd, nlst [0].n_value, - &_seminfo, sizeof (_seminfo)) != sizeof (_seminfo)) { - glibtop_warn_io_r (server, "kvm_read (seminfo)"); - return -1; - } - - server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits; - - return 0; -} - -/* Provides information about sysv sem limits. */ - -int -glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf) -{ - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0); - - memset (buf, 0, sizeof (glibtop_sem_limits)); - - if (server->sysdeps.sem_limits == 0) - return -1; - - buf->semmap = _seminfo.semmap; - buf->semmni = _seminfo.semmni; - buf->semmns = _seminfo.semmns; - buf->semmnu = _seminfo.semmnu; - buf->semmsl = _seminfo.semmsl; - buf->semopm = _seminfo.semopm; - buf->semvmx = _seminfo.semvmx; - buf->semaem = _seminfo.semaem; - - buf->flags = _glibtop_sysdeps_sem_limits; - - return 0; -} - -#endif /* either a newer BSDI or no BSDI at all. */ - diff --git a/sysdeps/freebsd/shm_limits.c b/sysdeps/freebsd/shm_limits.c deleted file mode 100644 index fd4d5583..00000000 --- a/sysdeps/freebsd/shm_limits.c +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, August 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/shm_limits.h> - -#include <glibtop_suid.h> - -#if defined(__bsdi__) && (_BSDI_VERSION < 199700) -/* Older versions of BSDI don't seem to have this. */ - -int -glibtop_init_shm_limits_p (glibtop *server) -{ - - return 0; -} - -int -glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf) -{ - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0); - - memset (buf, 0, sizeof (glibtop_shm_limits)); - - return 0; -} - -#else - -/* #define KERNEL to get declaration of `struct shminfo'. */ - -#if defined(__FreeBSD__) || defined(__bsdi__) -#define KERNEL 1 -#else -#define _KERNEL 1 -#endif - -#include <sys/ipc.h> -#include <sys/shm.h> - -static unsigned long _glibtop_sysdeps_shm_limits = -(1L << GLIBTOP_SHM_LIMITS_SHMMAX) + (1L << GLIBTOP_SHM_LIMITS_SHMMIN) + -(1L << GLIBTOP_SHM_LIMITS_SHMMNI) + (1L << GLIBTOP_SHM_LIMITS_SHMSEG) + -(1L << GLIBTOP_SHM_LIMITS_SHMALL); - -/* The values in this structure never change at runtime, so we only - * read it once during initialization. We have to use the name `_shminfo' - * since `shminfo' is already declared external in <sys/shm.h>. */ -static struct shminfo _shminfo; - -/* nlist structure for kernel access */ -static struct nlist nlst [] = { - { "_shminfo" }, - { 0 } -}; - -/* Init function. */ - -int -glibtop_init_shm_limits_p (glibtop *server) -{ - if (kvm_nlist (server->_priv->machine.kd, nlst) < 0) { - glibtop_warn_io_r (server, "kvm_nlist (shm_limits)"); - return -1; - } - - if (kvm_read (server->_priv->machine.kd, nlst [0].n_value, - &_shminfo, sizeof (_shminfo)) != sizeof (_shminfo)) { - glibtop_warn_io_r (server, "kvm_read (shminfo)"); - return -1; - } - - server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf) -{ - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0); - - memset (buf, 0, sizeof (glibtop_shm_limits)); - - if (server->sysdeps.shm_limits == 0) - return -1; - - buf->shmmax = _shminfo.shmmax; - buf->shmmin = _shminfo.shmmin; - buf->shmmni = _shminfo.shmmni; - buf->shmseg = _shminfo.shmseg; - buf->shmall = _shminfo.shmall; - - buf->flags = _glibtop_sysdeps_shm_limits; - - return 0; -} - -#endif /* either a newer BSDI or no BSDI at all. */ - diff --git a/sysdeps/freebsd/swap.c b/sysdeps/freebsd/swap.c deleted file mode 100644 index 0ab96eae..00000000 --- a/sysdeps/freebsd/swap.c +++ /dev/null @@ -1,432 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/swap.h> - -#include <glibtop/xmalloc.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_swap = -(1L << GLIBTOP_SWAP_TOTAL) + (1L << GLIBTOP_SWAP_USED) + -(1L << GLIBTOP_SWAP_FREE) + (1L << GLIBTOP_SWAP_PAGEIN) + -(1L << GLIBTOP_SWAP_PAGEOUT); - -#if defined(__FreeBSD__) || defined(__bsdi__) - -#include <sys/conf.h> -#ifdef __bsdi__ -#include <vm/swap_pager.h> -#else -#if __FreeBSD_version < 400005 -#include <sys/rlist.h> -#endif -#endif -#include <sys/vmmeter.h> - -/* nlist structure for kernel access */ - -#if defined(__bsdi__) -static struct nlist nlst [] = { - { "_swapstats" }, /* general swap info */ - { 0 } -}; -#elif __FreeBSD__ < 4 -static struct nlist nlst [] = { -#define VM_SWAPLIST 0 - { "_swaplist" },/* list of free swap areas */ -#define VM_SWDEVT 1 - { "_swdevt" }, /* list of swap devices and sizes */ -#define VM_NSWAP 2 - { "_nswap" }, /* size of largest swap device */ -#define VM_NSWDEV 3 - { "_nswdev" }, /* number of swap devices */ -#define VM_DMMAX 4 - { "_dmmax" }, /* maximum size of a swap block */ - { 0 } -}; -#endif - -#elif defined(__NetBSD__) - -#if (__NetBSD_Version__ >= 104000000) -#include <uvm/uvm_extern.h> -#include <sys/swap.h> -#else -#include <vm/vm_swap.h> -#endif - -#endif - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) -static int mib_uvmexp [] = { CTL_VM, VM_UVMEXP }; -#else -/* nlist structure for kernel access */ -static struct nlist nlst2 [] = { - { "_cnt" }, - { 0 } -}; -#endif - -/* Init function. */ - -int -glibtop_init_swap_p (glibtop *server) -{ -#if defined(__FreeBSD__) || defined(__bsdi__) -#if __FreeBSD__ < 4 || defined(__bsdi__) - if (kvm_nlist (server->_priv->machine.kd, nlst) < 0) { - glibtop_warn_io_r (server, "kvm_nlist (swap)"); - return -1; - } -#else - struct kvm_swap dummy; - - if (kvm_getswapinfo (server->_priv->machine.kd, &dummy, 1, 0) != 0) { - glibtop_warn_io_r (server, "kvm_swap (swap)"); - return -1; - } -#endif -#endif - -#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)) - if (kvm_nlist (server->_priv->machine.kd, nlst2) < 0) { - glibtop_warn_io_r (server, "kvm_nlist (cnt)"); - return -1; - } -#endif - - server->sysdeps.swap = _glibtop_sysdeps_swap; - - return 0; -} - -/* Provides information about swap usage. */ - -/* - * This function is based on a program called swapinfo written - * by Kevin Lahey <kml@rokkaku.atl.ga.us>. - */ - -int -glibtop_get_swap_p (glibtop *server, glibtop_swap *buf) -{ -#if defined(__FreeBSD__) - -# if __FreeBSD__ < 4 - char *header; - int hlen, nswdev, dmmax; - int div, nfree, npfree; - struct swdevt *sw; - long blocksize, *perdev; - struct rlist head; - struct rlisthdr swaplist; - struct rlist *swapptr; - size_t sw_size; - u_long ptr; -# else - int nswdev; - struct kvm_swap kvmsw[16]; -# endif - -#elif defined(__bsdi__) - struct swapstats swap; -#elif defined(__NetBSD__) - struct swapent *swaplist; -#endif - - int nswap, i; - int avail = 0, inuse = 0; - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - struct uvmexp uvmexp; - size_t length_uvmexp; -#else - /* To get `pagein' and `pageout'. */ - struct vmmeter vmm; -#endif - static int swappgsin = -1; - static int swappgsout = -1; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SWAP), 0); - - memset (buf, 0, sizeof (glibtop_swap)); - - if (server->sysdeps.swap == 0) - return -1; - -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - length_uvmexp = sizeof (uvmexp); - if (sysctl (mib_uvmexp, 2, &uvmexp, &length_uvmexp, NULL, 0)) { - glibtop_warn_io_r (server, "sysctl (uvmexp)"); - return -1; - } -#else - /* This is used to get the `pagein' and `pageout' members. */ - - if (kvm_read (server->_priv->machine.kd, nlst2[0].n_value, - &vmm, sizeof (vmm)) != sizeof (vmm)) { - glibtop_warn_io_r (server, "kvm_read (cnt)"); - return -1; - } -#endif - - if (swappgsin < 0) { - buf->pagein = 0; - buf->pageout = 0; - } else { -#ifdef __FreeBSD__ - buf->pagein = vmm.v_swappgsin - swappgsin; - buf->pageout = vmm.v_swappgsout - swappgsout; -#else -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - buf->pagein = uvmexp.swapins - swappgsin; - buf->pageout = uvmexp.swapouts - swappgsout; -#else - buf->pagein = vmm.v_swpin - swappgsin; - buf->pageout = vmm.v_swpout - swappgsout; -#endif -#endif - } - -#ifdef __FreeBSD__ - swappgsin = vmm.v_swappgsin; - swappgsout = vmm.v_swappgsout; -#else -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) - swappgsin = uvmexp.swapins; - swappgsout = uvmexp.swapouts; -#else - swappgsin = vmm.v_swpin; - swappgsout = vmm.v_swpout; -#endif -#endif - -#if defined(__FreeBSD__) - -#if __FreeBSD__ < 4 - - /* Size of largest swap device. */ - - if (kvm_read (server->_priv->machine.kd, nlst[VM_NSWAP].n_value, - &nswap, sizeof (nswap)) != sizeof (nswap)) { - glibtop_warn_io_r (server, "kvm_read (nswap)"); - return -1; - } - - /* Number of swap devices. */ - - if (kvm_read (server->_priv->machine.kd, nlst[VM_NSWDEV].n_value, - &nswdev, sizeof (nswdev)) != sizeof (nswdev)) { - glibtop_warn_io_r (server, "kvm_read (nswdev)"); - return -1; - } - - /* Maximum size of a swap block. */ - - if (kvm_read (server->_priv->machine.kd, nlst[VM_DMMAX].n_value, - &dmmax, sizeof (dmmax)) != sizeof (dmmax)) { - glibtop_warn_io_r (server, "kvm_read (dmmax)"); - return -1; - } - - /* List of free swap areas. */ - - if (kvm_read (server->_priv->machine.kd, nlst[VM_SWAPLIST].n_value, - &swaplist, sizeof (swaplist)) != sizeof (swaplist)) { - glibtop_warn_io_r (server, "kvm_read (swaplist)"); - return -1; - } - - /* Kernel offset of list of swap devices and sizes. */ - - if (kvm_read (server->_priv->machine.kd, nlst[VM_SWDEVT].n_value, - &ptr, sizeof (ptr)) != sizeof (ptr)) { - glibtop_warn_io_r (server, "kvm_read (swdevt)"); - return -1; - } - - /* List of swap devices and sizes. */ - - sw_size = nswdev * sizeof (*sw); - sw = glibtop_malloc_r (server, sw_size); - - if (kvm_read (server->_priv->machine.kd, ptr, sw, sw_size) != (ssize_t)sw_size) { - glibtop_warn_io_r (server, "kvm_read (*swdevt)"); - return -1; - } - - perdev = glibtop_malloc (nswdev * sizeof (*perdev)); - - /* Count up swap space. */ - - nfree = 0; - memset (perdev, 0, nswdev * sizeof(*perdev)); - - swapptr = swaplist.rlh_list; - - while (swapptr) { - int top, bottom, next_block; - - if (kvm_read (server->_priv->machine.kd, (int) swapptr, &head, - sizeof (struct rlist)) != sizeof (struct rlist)) { - glibtop_warn_io_r (server, "kvm_read (swapptr)"); - return -1; - } - - top = head.rl_end; - bottom = head.rl_start; - - nfree += top - bottom + 1; - - /* - * Swap space is split up among the configured disks. - * - * For interleaved swap devices, the first dmmax blocks - * of swap space some from the first disk, the next dmmax - * blocks from the next, and so on up to nswap blocks. - * - * The list of free space joins adjacent free blocks, - * ignoring device boundries. If we want to keep track - * of this information per device, we'll just have to - * extract it ourselves. - */ - while (top / dmmax != bottom / dmmax) { - next_block = ((bottom + dmmax) / dmmax); - perdev[(bottom / dmmax) % nswdev] += - next_block * dmmax - bottom; - bottom = next_block * dmmax; - } - perdev[(bottom / dmmax) % nswdev] += - top - bottom + 1; - - swapptr = head.rl_next; - } - - header = getbsize (&hlen, &blocksize); - - div = blocksize / 512; - avail = npfree = 0; - for (i = 0; i < nswdev; i++) { - int xsize, xfree; - - /* - * Don't report statistics for partitions which have not - * yet been activated via swapon(8). - */ - if (!(sw[i].sw_flags & SW_FREED)) - continue; - - /* The first dmmax is never allocated to avoid trashing of - * disklabels - */ - xsize = sw[i].sw_nblks - dmmax; - xfree = perdev[i]; - inuse = xsize - xfree; - npfree++; - avail += xsize; - } - - /* - * If only one partition has been set up via swapon(8), we don't - * need to bother with totals. - */ - inuse = avail - nfree; - - glibtop_free_r (server, sw); - glibtop_free_r (server, perdev); - - buf->flags = _glibtop_sysdeps_swap; - - buf->used = inuse; - buf->free = avail; - - buf->total = inuse + avail; - -#else - - nswdev = kvm_getswapinfo(server->_priv->machine.kd, kvmsw, 16, 0); - - buf->flags = _glibtop_sysdeps_swap; - - buf->used = kvmsw[nswdev].ksw_used; - buf->total = kvmsw[nswdev].ksw_total; - - buf->free = buf->total - buf->used; - -#endif - -#elif defined(__bsdi__) - - /* General info about swap devices. */ - - if (kvm_read (server->_priv->machine.kd, nlst[0].n_value, - &swap, sizeof (swap)) != sizeof (swap)) { - glibtop_warn_io_r (server, "kvm_read (swap)"); - return -1; - } - - buf->flags = _glibtop_sysdeps_swap; - - buf->used = swap.swap_total - swap.swap_free; - buf->free = swap.swap_free; - - buf->total = swap.swap_total; - -#elif defined(__NetBSD__) - - nswap = swapctl (SWAP_NSWAP, NULL, 0); - if (nswap < 0) { - glibtop_warn_io_r (server, "swapctl (SWAP_NSWAP)"); - return -1; - } - - swaplist = glibtop_calloc_r (server, nswap, sizeof (struct swapent)); - - if (swapctl (SWAP_STATS, swaplist, nswap) != nswap) { - glibtop_warn_io_r (server, "swapctl (SWAP_STATS)"); - glibtop_free_r (server, swaplist); - return -1; - } - - for (i = 0; i < nswap; i++) { - avail += swaplist[i].se_nblks; - inuse += swaplist[i].se_inuse; - } - - glibtop_free_r (server, swaplist); - - buf->flags = _glibtop_sysdeps_swap; - - buf->used = inuse; - buf->free = avail; - - buf->total = inuse + avail; -#endif - - return 0; -} diff --git a/sysdeps/freebsd/uptime.c b/sysdeps/freebsd/uptime.c deleted file mode 100644 index 1b8b1dd2..00000000 --- a/sysdeps/freebsd/uptime.c +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/uptime.h> - -#include <glibtop/cpu.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_uptime = -(1L << GLIBTOP_UPTIME_UPTIME) + (1L << GLIBTOP_UPTIME_IDLETIME); - -static const unsigned long _required_cpu_flags = -(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_IDLE) + -(1L << GLIBTOP_CPU_FREQUENCY); - -/* Init function. */ - -int -glibtop_init_uptime_p (glibtop *server) -{ - server->sysdeps.uptime = _glibtop_sysdeps_uptime; - - return 0; -} - -/* Provides uptime and idle time. */ - -int -glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf) -{ - glibtop_cpu cpu; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0); - - memset (buf, 0, sizeof (glibtop_uptime)); - - /* We simply calculate it from the CPU usage. */ - - glibtop_get_cpu_p (server, &cpu); - - /* Make sure all required fields are present. */ - - if ((cpu.flags & _required_cpu_flags) != _required_cpu_flags) - return -1; - - /* Calculate values. */ - - buf->uptime = (double) cpu.total / (double) cpu.frequency; - buf->idletime = (double) cpu.idle / (double) cpu.frequency; - - buf->flags = _glibtop_sysdeps_uptime; - - return 0; -} diff --git a/sysdeps/kernel/.cvsignore b/sysdeps/kernel/.cvsignore deleted file mode 100644 index 1eb1cdc4..00000000 --- a/sysdeps/kernel/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -marshal.c -backend-kernel.h diff --git a/sysdeps/kernel/AUTHORS b/sysdeps/kernel/AUTHORS deleted file mode 100644 index 702002a3..00000000 --- a/sysdeps/kernel/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Martin Baulig (martin@home-of-linux.org) diff --git a/sysdeps/kernel/ChangeLog b/sysdeps/kernel/ChangeLog deleted file mode 100644 index d4cd40de..00000000 --- a/sysdeps/kernel/ChangeLog +++ /dev/null @@ -1,54 +0,0 @@ -2000-01-24 Martin Baulig <martin@home-of-linux.org> - - * interfaces.c, netinfo.c: Removed. - -2000-01-23 Martin Baulig <martin@home-of-linux.org> - - This is now a LibGTop backend which can be loaded additionally - to the normal Linux sysdeps code. - - * open.c, close.c: Removed. - * shm_limits.c, msg_limits.c, sem_limits.c, ppp.c: Removed. - * siglist.c, sysinfo.c: Removed. - - * backend-kernel.c: New file. - * glibtop-backend-private.h: New file. - * libgtop-kernel.backend: New file. - - * backend-kernel.pl: New file. Automatically creates - `backend-kernel.h'. - - * marshal.pl: New file. Automatically creates `marshal.c'. - - * glibtop_server.h: Replaced all `GLIBTOP_SUID_<feature>' constants - with `GLIBTOP_IMPL_<feature>' ones; they're used in marshal.c to - find out which features this backend implements. - - * *.c: Renamed all `glibtop_get_<feature>_s' functions to - `glibtop_get_<feature>_k' and all `glibtop_init_<feature>_s' ones - to `glibtop_init_<feature>_k'. - -1999-12-22 Martin Baulig <martin@home-of-linux.org> - - * procdata.c: Distinguish between GLIBTOP_ERROR_NO_KERNEL_SUPPORT - and GLIBTOP_ERROR_NO_SUCH_PROCESS. - - * procdata.c (glibtop_get_proc_data_proc_state_s): Return - -GLIBTOP_ERROR_NO_SUCH_PROCESS if the process doesn't exist. - (glibtop_get_proc_data_proc_mem_s): Likewise. - (glibtop_get_proc_data_proc_signal_s): Likewise. - (glibtop_get_proc_data_proc_kernel_s): Likewise. - (glibtop_get_proc_data_proc_args_s): Likewise. - (glibtop_get_proc_data_proc_maps_s): Likewise. - -1999-04-09 Martin Baulig <martin@home-of-linux.org> - - * sysinfo.c: Copied from the Linux sysdeps directory. - -1999-03-21 Martin Baulig <martin@home-of-linux.org> - - Imported new sysctl () based interface to the Linux Kernel. - - * procdata.c: This file handles all interaction with the kernel. - - diff --git a/sysdeps/kernel/Makefile.am b/sysdeps/kernel/Makefile.am deleted file mode 100644 index f88d9136..00000000 --- a/sysdeps/kernel/Makefile.am +++ /dev/null @@ -1,47 +0,0 @@ -LINK = \ - $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ - -INCLUDES = \ - @INCLUDES@ - -backenddir = \ - @LIBGTOP_BACKEND_DIR@ - -backend_LTLIBRARIES = \ - libgtop_backend_kernel.la - -backend_DATA = \ - libgtop-kernel.backend - -libgtop_backend_kernel_la_SOURCES = \ - cpu.c mem.c swap.c uptime.c loadavg.c \ - proclist.c procstate.c procuid.c \ - proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c procargs.c procmap.c netload.c \ - procdata.c backend-kernel.c marshal.c - -libgtop_backend_kernel_la_LDFLAGS = \ - $(LT_VERSION_INFO) - -noinst_HEADERS = \ - glibtop_server.h glibtop_private.h - -BUILT_SOURCES = \ - marshal.c \ - backend-kernel.h - -EXTRA_DIST = \ - marshal.pl \ - backend-kernel.pl \ - libgtop-kernel.backend - -CLEANFILES = $(BUILT_SOURCES) - -marshal.c: marshal.pl $(top_builddir)/config.h $(top_srcdir)/features.def $(top_srcdir)/scripts/c_types.pl - $(PERL) -I $(top_srcdir)/scripts $(srcdir)/marshal.pl < $(top_srcdir)/features.def > tmp-t - mv tmp-t marshal.c - -backend-kernel.h: backend-kernel.pl $(top_builddir)/config.h $(top_srcdir)/features.def $(top_srcdir)/scripts/c_types.pl - $(PERL) -I $(top_srcdir)/scripts $(srcdir)/backend-kernel.pl < $(top_srcdir)/features.def > tmp-t - mv tmp-t backend-kernel.h - diff --git a/sysdeps/kernel/backend-kernel.c b/sysdeps/kernel/backend-kernel.c deleted file mode 100644 index e60f5950..00000000 --- a/sysdeps/kernel/backend-kernel.c +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/global.h> -#include <glibtop/xmalloc.h> - -#include <glibtop/open.h> -#include <glibtop/backend.h> -#include <glibtop-backend-private.h> - -#include <glibtop_private.h> - -static int -_open_kernel (glibtop *, glibtop_backend *, u_int64_t, const char **); - -static int -_close_kernel (glibtop *, glibtop_backend *); - -extern glibtop_call_vector glibtop_backend_kernel_call_vector; -extern glibtop_init_func_t _glibtop_init_hook_k []; - -glibtop_backend_info LibGTopBackendInfo = { - "glibtop-backend-kernel", _open_kernel, _close_kernel, - &glibtop_backend_kernel_call_vector -}; - -static int -_open_kernel (glibtop *server, glibtop_backend *backend, - u_int64_t features, const char **backend_args) -{ - glibtop_init_func_t *init_fkt; - int version, name [2] = { CTL_LIBGTOP, LIBGTOP_VERSION }; - size_t size = sizeof (int); - - if (sysctl (name, 2, &version, &size, NULL, 0)) { - if (errno == ENOTDIR) - return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; - else - glibtop_warn_io_r (server, "sysctl (libgtop/stat)"); - return -1; - } - - backend->_priv = glibtop_calloc_r - (server, 1, sizeof (glibtop_backend_private)); - - /* Do the initialization, but only if not already initialized. */ - - if ((server->flags & _GLIBTOP_INIT_STATE_SYSDEPS) == 0) { - for (init_fkt = _glibtop_init_hook_k; *init_fkt; init_fkt++) - (*init_fkt) (server); - - server->sysdeps.pointer_size = sizeof (void*)*8; - - server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS; - } - - return 0; -} - -static int -_close_kernel (glibtop *server, glibtop_backend *backend) -{ - return -1; -} - diff --git a/sysdeps/kernel/backend-kernel.pl b/sysdeps/kernel/backend-kernel.pl deleted file mode 100644 index a3ffa45b..00000000 --- a/sysdeps/kernel/backend-kernel.pl +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/perl - -require 'c_types.pl'; - -$[ = 1; # set array base to 1 -$, = ' '; # set output field separator -$\ = "\n"; # set output record separator - -$always_use_temp_storage = 1; - -sub toupper { - local($_) = @_; - tr/a-z/A-Z/; - return $_; -} - -sub tolower { - local($_) = @_; - tr/A-Z/a-z/; - return $_; -} - -print '/* backend-kernel.h */'; -print "/* This is a generated file. Please modify `backend-kernel.pl' */"; -print ''; - -print '#ifndef __GLIBTOP_BACKEND_KERNEL_H__'; -print '#define __GLIBTOP_BACKEND_KERNEL_H__'; -print ''; -print '#include <glibtop.h>'; -print '#include <glibtop/union.h>'; -print ''; -print 'BEGIN_LIBGTOP_DECLS'; -print ''; - -$feature_count = 0; - -while (<>) { - chop; # strip record separator - - if (/^[^#]/) { - &output($_); - } -} - -sub output { - local($line) = @_; - @line_fields = split(/\|/, $line, 9999); - $retval = $line_fields[1]; - $feature = $line_fields[2]; - $param_def = $line_fields[4]; - - $orig = $feature; - $feature =~ s/^@//; - $space = $feature; - $space =~ s/./ /g; - - $features{++$feature_count} = $orig; - - return if $orig =~ /^@/; - - if ($retval eq 'retval') { - $retval_param = '&retval'; - $call_prefix = ''; - $call_prefix_space = ''; - $prefix = 'retval = '; - $prefix_space = ' '; - $retval = 'int'; - } - elsif ($retval !~ /^void$/) { - $retval_param = 'NULL'; - $prefix = 'retval = '; - $prefix_space = ' '; - $call_prefix = 'retval = '; - $call_prefix_space = ' '; - } - else { - $retval_param = 'NULL'; - $call_prefix = ''; - $call_prefix_space = ''; - $prefix = ''; - $prefix_space = ''; - } - - if ($retval =~ /^(array|pointer)\((.*)\)$/) { - $retval = ($2 eq 'string') ? 'char **' : "$2 *"; - } - - $need_temp_storage = $always_use_temp_storage; - $first_param_name = ''; - - $call_param = ''; - $param_decl = ''; - $need_temp_len = 0; - $nr_params = (@params = split(/:/, $param_def, 9999)); - for ($param = 1; $param <= $nr_params; $param++) { - $list = $params[$param]; - $type = $params[$param]; - $type =~ s/\(.*//; - $list =~ s/^.*\(//; - $list =~ s/\)$//; - $count = (@fields = split(/,/, $list, 9999)); - for ($field = 1; $field <= $count; $field++) { - my $c_type = $typeinfo->{$type}->[1]; - - if ($first_param_name eq '') { - $first_param_name = $fields[$field]; - } - - if ($typeinfo->{$type}->[2]) { - $need_temp_storage = 1; - } - - if ($param_decl eq '') { - $param_decl = ",\n " . $space . ' '; - } - else { - $param_decl = $param_decl . ', '; - } - $param_decl = $param_decl . $c_type . ' ' . $fields[$field]; - $call_param = $call_param . ', ' . $fields[$field]; - } - } - - $func_decl = sprintf ("int\nglibtop_init_%s_k (glibtop *server);\n\n", - $feature); - - $func_decl .= $retval."\n"; - if ($line_fields[3] eq '') { - $func_decl .= sprintf ("glibtop_get_%s_k (glibtop *server%s);\n", - $feature, $param_decl); - } elsif ($line_fields[3] eq 'array') { - $func_decl .= sprintf ("glibtop_get_%s_k (glibtop *server, glibtop_array *array%s);\n", - $feature, $param_decl); - } elsif ($line_fields[3] =~ /^array/) { - $func_decl .= sprintf ("glibtop_get_%s_k (glibtop *server, glibtop_array *array, %s *buf%s);\n", - $feature, 'glibtop_'.$feature, $param_decl); - } else { - $func_decl .= sprintf ("glibtop_get_%s_k (glibtop *server, %s *buf%s);\n", - $feature, 'glibtop_'.$feature, $param_decl); - } - - $total_code = $func_decl; - - print $total_code; -} - -print ''; -print 'END_LIBGTOP_DECLS'; -print ''; -print '#endif'; -print ''; diff --git a/sysdeps/kernel/cpu.c b/sysdeps/kernel/cpu.c deleted file mode 100644 index 8df5fef3..00000000 --- a/sysdeps/kernel/cpu.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/cpu.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_cpu = -(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) + -(1L << GLIBTOP_CPU_NICE) + (1L << GLIBTOP_CPU_SYS) + -(1L << GLIBTOP_CPU_IDLE) + (1L << GLIBTOP_CPU_FREQUENCY); - -static const unsigned long _glibtop_sysdeps_cpu_smp = -(1L << GLIBTOP_CPU_XCPU_TOTAL) + (1L << GLIBTOP_CPU_XCPU_USER) + -(1L << GLIBTOP_CPU_XCPU_NICE) + (1L << GLIBTOP_CPU_XCPU_SYS) + -(1L << GLIBTOP_CPU_XCPU_IDLE); - -/* Init function. */ - -int -glibtop_init_cpu_k (glibtop *server) -{ - server->sysdeps.cpu = _glibtop_sysdeps_cpu; - - if (server->ncpu) - server->sysdeps.cpu |= _glibtop_sysdeps_cpu_smp; - - return 0; -} - -/* Provides information about cpu usage. */ - -int -glibtop_get_cpu_k (glibtop *server, glibtop_cpu *buf) -{ - libgtop_stat_t stat; - int retval, i; - - memset (buf, 0, sizeof (glibtop_cpu)); - - retval = glibtop_get_proc_data_stat_k (server, &stat); - if (retval) - return retval; - - buf->user = stat.cpu.user; - buf->nice = stat.cpu.nice; - buf->sys = stat.cpu.sys; - buf->idle = stat.cpu.idle; - - buf->total = buf->user + buf->nice + buf->sys + buf->idle; - buf->frequency = stat.frequency; - - buf->flags = _glibtop_sysdeps_cpu; - - if (stat.ncpu) { - for (i = 0; i < GLIBTOP_NCPU; i++) { - buf->xcpu_user [i] = stat.xcpu [i].user; - buf->xcpu_nice [i] = stat.xcpu [i].nice; - buf->xcpu_sys [i] = stat.xcpu [i].sys; - buf->xcpu_idle [i] = stat.xcpu [i].idle; - - buf->xcpu_total [i] = buf->xcpu_user [i] + buf->xcpu_nice [i] + - buf->xcpu_sys [i] + buf->xcpu_idle [i]; - } - - buf->flags |= _glibtop_sysdeps_cpu_smp; - } - - return 0; -} diff --git a/sysdeps/kernel/glibtop-backend-private.h b/sysdeps/kernel/glibtop-backend-private.h deleted file mode 100644 index 81d485b6..00000000 --- a/sysdeps/kernel/glibtop-backend-private.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_BACKEND_PRIVATE_H__ -#define __GLIBTOP_BACKEND_PRIVATE_H__ - -struct _glibtop_backend_private -{ - u_int64_t flags; -}; - -#endif diff --git a/sysdeps/kernel/glibtop_private.h b/sysdeps/kernel/glibtop_private.h deleted file mode 100644 index 73485d7e..00000000 --- a/sysdeps/kernel/glibtop_private.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_PRIVATE_H__ -#define __GLIBTOP_PRIVATE_H__ - -#include <glibtop.h> -#include <glibtop/error.h> - -#include <sys/param.h> -#include <sys/sysctl.h> -#include <sys/user.h> - -#undef LIBGTOP_VERSION -#include <linux/libgtop.h> - -BEGIN_LIBGTOP_DECLS - -#include "backend-kernel.h" - -int -glibtop_get_proc_data_stat_k (glibtop *server, libgtop_stat_t *stat); - -int -glibtop_get_proc_data_mem_k (glibtop *server, libgtop_mem_t *mem); - -int -glibtop_get_proc_data_swap_k (glibtop *server, libgtop_swap_t *swap); - -int -glibtop_get_proc_data_proclist_k (glibtop *server, - libgtop_proclist_t *proclist, - u_int64_t which, u_int64_t arg); - -int -glibtop_get_proc_data_proc_state_k (glibtop *server, - libgtop_proc_state_t *proc_state, - pid_t pid); - -int -glibtop_get_proc_data_proc_mem_k (glibtop *server, - libgtop_proc_mem_t *proc_mem, - pid_t pid); - -int -glibtop_get_proc_data_proc_signal_k (glibtop *server, - libgtop_proc_signal_t *proc_signal, - pid_t pid); - -int -glibtop_get_proc_data_proc_kernel_k (glibtop *server, - libgtop_proc_kernel_t *proc_kernel, - pid_t pid); - -int -glibtop_get_proc_data_proc_args_k (glibtop *server, pid_t pid, - char *result, size_t max_len); - -int -glibtop_get_proc_data_proc_maps_k (glibtop *server, pid_t pid, - libgtop_proc_maps_t *result, - size_t max_len); - -int -glibtop_get_proc_data_netload_k (glibtop *server, - libgtop_netload_t *netload, - const char *device); - -END_LIBGTOP_DECLS - -#endif /* __GLIBTOP_PRIVATE_H__ */ diff --git a/sysdeps/kernel/glibtop_server.h b/sysdeps/kernel/glibtop_server.h deleted file mode 100644 index 1ef2f6fc..00000000 --- a/sysdeps/kernel/glibtop_server.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_SERVER_H__ -#define __GLIBTOP_SERVER_H__ - -BEGIN_LIBGTOP_DECLS - -#define GLIBTOP_IMPL_CPU (1L << GLIBTOP_SYSDEPS_CPU) -#define GLIBTOP_IMPL_MEM (1L << GLIBTOP_SYSDEPS_MEM) -#define GLIBTOP_IMPL_SWAP (1L << GLIBTOP_SYSDEPS_SWAP) -#define GLIBTOP_IMPL_UPTIME (1L << GLIBTOP_SYSDEPS_UPTIME) -#define GLIBTOP_IMPL_LOADAVG (1L << GLIBTOP_SYSDEPS_LOADAVG) -#define GLIBTOP_IMPL_SHM_LIMITS 0 -#define GLIBTOP_IMPL_MSG_LIMITS 0 -#define GLIBTOP_IMPL_SEM_LIMITS 0 -#define GLIBTOP_IMPL_PROCLIST (1L << GLIBTOP_SYSDEPS_PROCLIST) -#define GLIBTOP_IMPL_PROC_STATE (1L << GLIBTOP_SYSDEPS_PROC_STATE) -#define GLIBTOP_IMPL_PROC_UID (1L << GLIBTOP_SYSDEPS_PROC_UID) -#define GLIBTOP_IMPL_PROC_MEM (1L << GLIBTOP_SYSDEPS_PROC_MEM) -#define GLIBTOP_IMPL_PROC_TIME (1L << GLIBTOP_SYSDEPS_PROC_TIME) -#define GLIBTOP_IMPL_PROC_SIGNAL (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL) -#define GLIBTOP_IMPL_PROC_KERNEL (1L << GLIBTOP_SYSDEPS_PROC_KERNEL) -#define GLIBTOP_IMPL_PROC_SEGMENT (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT) -#define GLIBTOP_IMPL_PROC_ARGS (1L << GLIBTOP_SYSDEPS_PROC_ARGS) -#define GLIBTOP_IMPL_PROC_MAP (1L << GLIBTOP_SYSDEPS_PROC_MAP) -#define GLIBTOP_IMPL_NETLOAD (1L << GLIBTOP_SYSDEPS_NETLOAD) -#define GLIBTOP_IMPL_NETINFO 0 -#define GLIBTOP_IMPL_INTERFACE_NAMES 0 -#define GLIBTOP_IMPL_PPP 0 - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/kernel/libgtop-kernel.backend b/sysdeps/kernel/libgtop-kernel.backend deleted file mode 100644 index 7b177f71..00000000 --- a/sysdeps/kernel/libgtop-kernel.backend +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0"?> <!-- -*-xml-*- --> -<!DOCTYPE libgtop:backends SYSTEM 'libgtop-backends.dtd'> -<libgtop:Backends xmlns:libgtop="http://www.home-of-linux.org/libgtop/1.1"> - - <libgtop:Backend> - <libgtop:Name>glibtop-backend-kernel</libgtop:Name> - <libgtop:Location> - <libgtop:LibtoolName>libgtop_backend_kernel.la</libgtop:LibtoolName> - <libgtop:ShlibName>libgtop_backend_kernel.so</libgtop:ShlibName> - </libgtop:Location> - </libgtop:Backend> - -</libgtop:Backends> diff --git a/sysdeps/kernel/loadavg.c b/sysdeps/kernel/loadavg.c deleted file mode 100644 index 588cb53a..00000000 --- a/sysdeps/kernel/loadavg.c +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/loadavg.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_loadavg = -(1L << GLIBTOP_LOADAVG_LOADAVG); - -/* Init function. */ - -int -glibtop_init_loadavg_k (glibtop *server) -{ - server->sysdeps.loadavg = _glibtop_sysdeps_loadavg; - - return 0; -} - -/* Provides load averange. */ - -int -glibtop_get_loadavg_k (glibtop *server, glibtop_loadavg *buf) -{ - libgtop_stat_t stat; - int retval; - - memset (buf, 0, sizeof (glibtop_loadavg)); - - retval = glibtop_get_proc_data_stat_k (server, &stat); - if (retval) - return retval; - - buf->loadavg [0] = stat.loadavg [0]; - buf->loadavg [1] = stat.loadavg [1]; - buf->loadavg [2] = stat.loadavg [2]; - - buf->flags = _glibtop_sysdeps_loadavg; - - return 0; -} diff --git a/sysdeps/kernel/marshal.pl b/sysdeps/kernel/marshal.pl deleted file mode 100644 index 3541dd17..00000000 --- a/sysdeps/kernel/marshal.pl +++ /dev/null @@ -1,201 +0,0 @@ -#!/usr/bin/perl - -require 'c_types.pl'; - -$[ = 1; # set array base to 1 -$, = ' '; # set output field separator -$\ = "\n"; # set output record separator - -$always_use_temp_storage = 1; - -sub toupper { - local($_) = @_; - tr/a-z/A-Z/; - return $_; -} - -sub tolower { - local($_) = @_; - tr/A-Z/a-z/; - return $_; -} - -print '/* marshal.c */'; -print "/* This is a generated file. Please modify `marshal.pl' */"; -print ''; - -print '#include <glibtop.h>'; -print '#include <glibtop/open.h>'; -print '#include <glibtop/xmalloc.h>'; -print ''; -print '#include <glibtop/sysdeps.h>'; -print '#include <glibtop/union.h>'; -print ''; -print '#include <glibtop/backend.h>'; -print ''; -print '#include <glibtop-backend-private.h>'; -print '#include <glibtop_private.h>'; -print '#include <glibtop_server.h>'; -print ''; - -$feature_count = 0; - -while (<>) { - chop; # strip record separator - - if (/^[^#]/) { - &output($_); - } -} - -sub output { - local($line) = @_; - @line_fields = split(/\|/, $line, 9999); - $retval = $line_fields[1]; - $feature = $line_fields[2]; - $param_def = $line_fields[4]; - - $orig = $feature; - $feature =~ s/^@//; - $space = $feature; - $space =~ s/./ /g; - - $features{++$feature_count} = $orig; - - return if $orig =~ /^@/; - - if ($retval eq 'retval') { - $retval_param = '&retval'; - $call_prefix = ''; - $call_prefix_space = ''; - $prefix = 'retval = '; - $prefix_space = ' '; - $retval = 'int'; - } - elsif ($retval !~ /^void$/) { - $retval_param = 'NULL'; - $prefix = 'retval = '; - $prefix_space = ' '; - $call_prefix = 'retval = '; - $call_prefix_space = ' '; - } - else { - $retval_param = 'NULL'; - $call_prefix = ''; - $call_prefix_space = ''; - $prefix = ''; - $prefix_space = ''; - } - - if ($retval =~ /^(array|pointer)\((.*)\)$/) { - $retval = ($2 eq 'string') ? 'char **' : "$2 *"; - } - - $need_temp_storage = $always_use_temp_storage; - $first_param_name = ''; - - $call_param = ''; - $param_decl = ''; - $need_temp_len = 0; - $nr_params = (@params = split(/:/, $param_def, 9999)); - for ($param = 1; $param <= $nr_params; $param++) { - $list = $params[$param]; - $type = $params[$param]; - $type =~ s/\(.*//; - $list =~ s/^.*\(//; - $list =~ s/\)$//; - $count = (@fields = split(/,/, $list, 9999)); - for ($field = 1; $field <= $count; $field++) { - my $c_type = $typeinfo->{$type}->[1]; - - if ($first_param_name eq '') { - $first_param_name = $fields[$field]; - } - - if ($typeinfo->{$type}->[2]) { - $need_temp_storage = 1; - } - - if ($param_decl eq '') { - $param_decl = ",\n " . $space . ' '; - } - else { - $param_decl = $param_decl . ', '; - } - $param_decl = $param_decl . $c_type . ' ' . $fields[$field]; - $call_param = $call_param . ', ' . $fields[$field]; - } - } - - if ($line_fields[3] eq '') { - $total_code = sprintf - ("\treturn glibtop_get_%s_k (server%s);\n", $feature, $call_param); - } elsif ($line_fields[3] eq 'array') { - $total_code = sprintf - ("\treturn glibtop_get_%s_k (server, array%s);\n", $feature, $call_param); - } elsif ($line_fields[3] =~ /^array/) { - $total_code = sprintf - ("\treturn glibtop_get_%s_k (server, array, buf%s);\n", $feature, $call_param); - } else { - $total_code = sprintf - ("\treturn glibtop_get_%s_k (server, buf%s);\n", $feature, $call_param); - } - - $func_decl = 'static '.$retval."\n"; - if ($line_fields[3] eq '') { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend%s)\n", - $feature, $param_decl); - } elsif ($line_fields[3] eq 'array') { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, glibtop_array *array%s)\n", - $feature, $param_decl); - } elsif ($line_fields[3] =~ /^array/) { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, glibtop_array *array, %s *buf%s)\n", - $feature, 'glibtop_'.$feature, $param_decl); - } else { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, %s *buf%s)\n", - $feature, 'glibtop_'.$feature, $param_decl); - } - - $total_code = sprintf ("%s{\n%s\n%s}\n", $func_decl, $total_code); - - $total_code = sprintf ("#if (GLIBTOP_IMPL_%s)\n\n%s\n#endif /* GLIBTOP_IMPL_%s */\n\n", - &toupper($feature), $total_code, - &toupper($feature)); - - print $total_code; -} - -$init_hook_code = ''; -$call_vector_code = ''; -for ($nr = 1; $nr <= $feature_count; $nr++) { - $feature = $features{$nr}; - - if ($feature =~ /^@/) { - $call_vector_code .= sprintf (qq[\tNULL,\n]); - } else { - $call_vector_code .= sprintf - (qq[\#if GLIBTOP_IMPL_%s\n\t_glibtop_get_%s_c,\n\#else\n\tNULL,\n\#endif\n], - &toupper($feature), $feature); - } - - if (!($feature =~ /^@/)) { - $init_hook_code .= sprintf - (qq[\#if GLIBTOP_IMPL_%s\n\tglibtop_init_%s_k,\n\#endif\n], - &toupper($feature), $feature); - } -} -$init_hook_code .= sprintf (qq[\tNULL\n]); - -chop $init_hook_code; -chop $call_vector_code; - -print 'glibtop_call_vector glibtop_backend_kernel_call_vector = {'; -print $call_vector_code; -print '};'; -print ''; - -print 'glibtop_init_func_t _glibtop_init_hook_k [] = {'; -print $init_hook_code; -print '};'; -print ''; - diff --git a/sysdeps/kernel/mem.c b/sysdeps/kernel/mem.c deleted file mode 100644 index 3e212018..00000000 --- a/sysdeps/kernel/mem.c +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/mem.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_mem = -(1L << GLIBTOP_MEM_TOTAL) + (1L << GLIBTOP_MEM_USED) + -(1L << GLIBTOP_MEM_FREE) + (1L << GLIBTOP_MEM_SHARED) + -(1L << GLIBTOP_MEM_BUFFER) + (1L << GLIBTOP_MEM_CACHED); - -/* Init function. */ - -int -glibtop_init_mem_k (glibtop *server) -{ - server->sysdeps.mem = _glibtop_sysdeps_mem; - - return 0; -} - -/* Provides information about memory usage. */ - -int -glibtop_get_mem_k (glibtop *server, glibtop_mem *buf) -{ - libgtop_mem_t mem; - int retval; - - memset (buf, 0, sizeof (glibtop_mem)); - - retval = glibtop_get_proc_data_mem_k (server, &mem); - if (retval) - return retval; - - buf->total = mem.totalram; - buf->used = mem.totalram - mem.freeram; - buf->free = mem.freeram; - buf->shared = mem.sharedram; - buf->buffer = mem.bufferram; - buf->cached = mem.cachedram; - - buf->flags = _glibtop_sysdeps_mem; - - return 0; -} diff --git a/sysdeps/kernel/netload.c b/sysdeps/kernel/netload.c deleted file mode 100644 index a0fc4a15..00000000 --- a/sysdeps/kernel/netload.c +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/netload.h> - -#include <glibtop_private.h> - -#include <glibtop.h> -#include <glibtop/error.h> -#include <glibtop/netload.h> - -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/ioctl.h> - -#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 -/* GNU LibC */ -#include <net/if.h> -#include <netinet/ip_icmp.h> -#include <netinet/in.h> -#include <netinet/ip.h> -#include <netinet/tcp.h> -#include <netinet/udp.h> -#include <net/if.h> -#else /* Libc 5 */ -#include <linux/if.h> -#include <linux/in.h> -#include <linux/ip.h> -#include <linux/icmp.h> -#include <linux/tcp.h> -#include <linux/udp.h> -#endif - -static const unsigned long _glibtop_sysdeps_netload = -(1L << GLIBTOP_NETLOAD_BYTES_IN) + -(1L << GLIBTOP_NETLOAD_BYTES_OUT) + -(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) + -(1L << GLIBTOP_NETLOAD_PACKETS_IN) + -(1L << GLIBTOP_NETLOAD_PACKETS_OUT) + -(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) + -(1L << GLIBTOP_NETLOAD_ERRORS_IN) + -(1L << GLIBTOP_NETLOAD_ERRORS_OUT) + -(1L << GLIBTOP_NETLOAD_ERRORS_TOTAL) + -(1L << GLIBTOP_NETLOAD_COLLISIONS); - -/* Init function. */ - -int -glibtop_init_netload_k (glibtop *server) -{ - server->sysdeps.netload = _glibtop_sysdeps_netload; - - return 0; -} - -/* Provides network statistics. */ - -int -glibtop_get_netload_k (glibtop *server, glibtop_netload *buf, - const char *interface, unsigned transport, - unsigned protocol) -{ - libgtop_netload_t netload; - int retval; - - memset (buf, 0, sizeof (glibtop_netload)); - - retval = glibtop_get_proc_data_netload_k (server, &netload, interface); - if (retval) - return retval; - - buf->bytes_in = netload.rx_bytes; - buf->bytes_out = netload.tx_bytes; - buf->bytes_total = buf->bytes_in + buf->bytes_out; - - buf->packets_in = netload.rx_packets; - buf->packets_out = netload.tx_packets; - buf->packets_total = buf->packets_in + buf->packets_out; - - buf->errors_in = netload.rx_errors; - buf->errors_out = netload.tx_errors; - buf->errors_total = buf->errors_in + buf->errors_out; - - buf->collisions = netload.collisions; - - buf->flags |= _glibtop_sysdeps_netload; - - return 0; -} diff --git a/sysdeps/kernel/procargs.c b/sysdeps/kernel/procargs.c deleted file mode 100644 index 9d3440b7..00000000 --- a/sysdeps/kernel/procargs.c +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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_private.h> - -static const unsigned long _glibtop_sysdeps_proc_args = -(1L << GLIBTOP_ARRAY_NUMBER) + (1L << GLIBTOP_ARRAY_SIZE); - -/* Init function. */ - -int -glibtop_init_proc_args_k (glibtop *server) -{ - server->sysdeps.proc_args = _glibtop_sysdeps_proc_args; - - return 0; -} - -/* Provides detailed information about a process. */ - -char ** -glibtop_get_proc_args_k (glibtop *server, glibtop_array *array, pid_t pid) -{ - char *ptr = NULL, *pos, **ptrlist; - size_t count = 0, max_len, total; - int i, ret; - - memset (array, 0, sizeof (glibtop_array)); - - max_len = PAGE_SIZE; - ptr = glibtop_malloc_r (server, max_len + 1); - - ret = glibtop_get_proc_data_proc_args_k (server, pid, ptr, max_len); - if (ret < 0) { - glibtop_free_r (server, ptr); - return NULL; - } - - total = ret; - ptr [total] = '\0'; - - for (i = 0; i <= total; i++) { - if (ptr [i]) continue; - count++; - } - - ptrlist = glibtop_calloc_r (server, count+1, sizeof (char *)); - - for (i = 0, pos = ptr; i < count; i++) { - ptrlist [i] = glibtop_strdup_r (server, pos); - pos += strlen (pos) + 1; - } - - ptrlist [count] = NULL; - - glibtop_free_r (server, ptr); - - array->number = count; - array->size = sizeof (char *); - array->flags = _glibtop_sysdeps_proc_args; - - return ptrlist; -} diff --git a/sysdeps/kernel/procdata.c b/sysdeps/kernel/procdata.c deleted file mode 100644 index 56273556..00000000 --- a/sysdeps/kernel/procdata.c +++ /dev/null @@ -1,242 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop_private.h> - -int -glibtop_get_proc_data_stat_k (glibtop *server, libgtop_stat_t *stat) -{ - int name [2] = { CTL_LIBGTOP, LIBGTOP_STAT }; - size_t size = sizeof (libgtop_stat_t); - - if (sysctl (name, 2, stat, &size, NULL, 0)) { - if (errno == ENOTDIR) - return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; - else - glibtop_warn_io_r (server, "sysctl (libgtop/stat)"); - return -1; - } - - return 0; -} - -int -glibtop_get_proc_data_mem_k (glibtop *server, libgtop_mem_t *mem) -{ - int name [2] = { CTL_LIBGTOP, LIBGTOP_MEM }; - size_t size = sizeof (libgtop_mem_t); - - if (sysctl (name, 2, mem, &size, NULL, 0)) { - if (errno == ENOTDIR) - return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; - else - glibtop_warn_io_r (server, "sysctl (libgtop/mem)"); - return -1; - } - - return 0; -} - -int -glibtop_get_proc_data_swap_k (glibtop *server, libgtop_swap_t *swap) -{ - int name [2] = { CTL_LIBGTOP, LIBGTOP_SWAP }; - size_t size = sizeof (libgtop_swap_t); - - if (sysctl (name, 2, swap, &size, NULL, 0)) { - if (errno == ENOTDIR) - return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; - else - glibtop_warn_io_r (server, "sysctl (libgtop/swap)"); - return -1; - } - - return 0; -} - -int -glibtop_get_proc_data_proclist_k (glibtop *server, - libgtop_proclist_t *proclist, - u_int64_t which, u_int64_t arg) -{ - int name [4] = { CTL_LIBGTOP, LIBGTOP_PROCLIST, which, arg }; - size_t size = sizeof (libgtop_proclist_t); - - if (sysctl (name, 4, proclist, &size, NULL, 0)) { - if (errno == ENOTDIR) - return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; - else - glibtop_warn_io_r (server, "sysctl (libgtop/proclist)"); - return -1; - } - - return 0; - -} - -int -glibtop_get_proc_data_proc_state_k (glibtop *server, - libgtop_proc_state_t *proc_state, - pid_t pid) -{ - int name [3] = { CTL_LIBGTOP, LIBGTOP_PROC_STATE, pid }; - size_t size = sizeof (libgtop_proc_state_t); - - if (sysctl (name, 3, proc_state, &size, NULL, 0)) { - if (errno == ENOTDIR) - return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; - else if (errno == ESRCH) - return -GLIBTOP_ERROR_NO_SUCH_PROCESS; - else - glibtop_warn_io_r (server, "sysctl (libgtop/proc_state)"); - return -1; - } - - return 0; -} - -int -glibtop_get_proc_data_proc_mem_k (glibtop *server, - libgtop_proc_mem_t *proc_mem, - pid_t pid) -{ - int name [3] = { CTL_LIBGTOP, LIBGTOP_PROC_MEM, pid }; - size_t size = sizeof (libgtop_proc_mem_t); - - if (sysctl (name, 3, proc_mem, &size, NULL, 0)) { - if (errno == ENOTDIR) - return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; - else if (errno == ESRCH) - return -GLIBTOP_ERROR_NO_SUCH_PROCESS; - else - glibtop_warn_io_r (server, "sysctl (libgtop/proc_mem)"); - return -1; - } - - return 0; -} - -int -glibtop_get_proc_data_proc_signal_k (glibtop *server, - libgtop_proc_signal_t *proc_signal, - pid_t pid) -{ - int name [3] = { CTL_LIBGTOP, LIBGTOP_PROC_SIGNAL, pid }; - size_t size = sizeof (libgtop_proc_signal_t); - - if (sysctl (name, 3, proc_signal, &size, NULL, 0)) { - if (errno == ENOTDIR) - return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; - else if (errno == ESRCH) - return -GLIBTOP_ERROR_NO_SUCH_PROCESS; - else - glibtop_warn_io_r (server, "sysctl (libgtop/proc_signal)"); - return -1; - } - - return 0; -} - -int -glibtop_get_proc_data_proc_kernel_k (glibtop *server, - libgtop_proc_kernel_t *proc_kernel, - pid_t pid) -{ - int name [3] = { CTL_LIBGTOP, LIBGTOP_PROC_KERNEL, pid }; - size_t size = sizeof (libgtop_proc_kernel_t); - - if (sysctl (name, 3, proc_kernel, &size, NULL, 0)) { - if (errno == ENOTDIR) - return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; - else if (errno == ESRCH) - return -GLIBTOP_ERROR_NO_SUCH_PROCESS; - else - glibtop_warn_io_r (server, "sysctl (libgtop/proc_kernel)"); - return -1; - } - - return 0; -} - -int -glibtop_get_proc_data_proc_args_k (glibtop *server, pid_t pid, - char *result, size_t max_len) -{ - int name [3] = { CTL_LIBGTOP, LIBGTOP_PROC_ARGS, pid }; - size_t size = max_len; - - if (sysctl (name, 3, result, &size, NULL, 0)) { - if (errno == ENOTDIR) - return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; - else if (errno == ESRCH) - return -GLIBTOP_ERROR_NO_SUCH_PROCESS; - else - glibtop_warn_io_r (server, "sysctl (libgtop/proc_args)"); - return -1; - } - - return size; -} - -int -glibtop_get_proc_data_proc_maps_k (glibtop *server, pid_t pid, - libgtop_proc_maps_t *result, - size_t max_len) -{ - int name [3] = { CTL_LIBGTOP, LIBGTOP_PROC_MAPS, pid }; - size_t size = max_len; - - if (sysctl (name, 3, result, &size, NULL, 0)) { - if (errno == ENOTDIR) - return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; - else if (errno == ESRCH) - return -GLIBTOP_ERROR_NO_SUCH_PROCESS; - else - glibtop_warn_io_r (server, "sysctl (libgtop/proc_maps)"); - return -1; - } - - return size; -} - -int -glibtop_get_proc_data_netload_k (glibtop *server, - libgtop_netload_t *netload, - const char *device) -{ - int name [2] = { CTL_LIBGTOP, LIBGTOP_NETLOAD }; - size_t size = sizeof (libgtop_netload_t); - - if (sysctl (name, 2, netload, &size, (char *) device, strlen (device)+1)) { - if (errno == ENOTDIR) - return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; - else - glibtop_warn_io_r (server, "sysctl (libgtop/netload)"); - return -1; - } - - return 0; -} diff --git a/sysdeps/kernel/prockernel.c b/sysdeps/kernel/prockernel.c deleted file mode 100644 index 786b2493..00000000 --- a/sysdeps/kernel/prockernel.c +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/prockernel.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_kernel = -(1L << GLIBTOP_PROC_KERNEL_MIN_FLT) + -(1L << GLIBTOP_PROC_KERNEL_MAJ_FLT) + -(1L << GLIBTOP_PROC_KERNEL_CMIN_FLT) + -(1L << GLIBTOP_PROC_KERNEL_CMAJ_FLT) + -(1L << GLIBTOP_PROC_KERNEL_KSTK_ESP) + -(1L << GLIBTOP_PROC_KERNEL_KSTK_EIP); - -static const unsigned long _glibtop_sysdeps_proc_kernel_kernel = -(1L << GLIBTOP_PROC_KERNEL_NWCHAN); - -/* Init function. */ - -int -glibtop_init_proc_kernel_k (glibtop *server) -{ - server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel | - _glibtop_sysdeps_proc_kernel_kernel; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_kernel_k (glibtop *server, glibtop_proc_kernel *buf, - pid_t pid) -{ - libgtop_proc_state_t proc_state; - libgtop_proc_kernel_t proc_kernel; - int retval; - - memset (buf, 0, sizeof (glibtop_proc_kernel)); - - retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid); - if (retval) - return retval; - - buf->min_flt = proc_state.min_flt; - buf->maj_flt = proc_state.maj_flt; - buf->cmin_flt = proc_state.cmin_flt; - buf->cmaj_flt = proc_state.cmaj_flt; - buf->kstk_esp = proc_state.kesp; - buf->kstk_eip = proc_state.keip; - - buf->flags = _glibtop_sysdeps_proc_kernel; - - retval = glibtop_get_proc_data_proc_kernel_k (server, &proc_kernel, pid); - if (retval) - return retval; - - buf->nwchan = proc_kernel.wchan; - buf->flags |= _glibtop_sysdeps_proc_kernel_kernel; - - return 0; -} diff --git a/sysdeps/kernel/proclist.c b/sysdeps/kernel/proclist.c deleted file mode 100644 index e760781a..00000000 --- a/sysdeps/kernel/proclist.c +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/xmalloc.h> -#include <glibtop/proclist.h> - -#include <glibtop_private.h> - -#define GLIBTOP_PROCLIST_FLAGS 3 - -static const unsigned long _glibtop_sysdeps_proclist = -(1L << GLIBTOP_PROCLIST_NUMBER) + (1L << GLIBTOP_PROCLIST_SIZE) + -(1L << GLIBTOP_PROCLIST_TOTAL); - -/* Init function. */ - -int -glibtop_init_proclist_k (glibtop *server) -{ - server->sysdeps.proclist = _glibtop_sysdeps_proclist; - - return 0; -} - -/* Fetch list of currently running processes. - * - * IMPORTANT NOTE: - * On error, this function MUST return NULL and set buf->flags to zero ! - * On success, it returnes a pointer to a list of buf->number elements - * each buf->size big. The total size is stored in buf->total. */ - -unsigned * -glibtop_get_proclist_k (glibtop *server, glibtop_proclist *buf, - int64_t which, int64_t arg) -{ - libgtop_proclist_t proclist; - unsigned *ret; - int i; - - memset (buf, 0, sizeof (glibtop_proclist)); - - if (glibtop_get_proc_data_proclist_k (server, &proclist, which, arg)) - return NULL; - - ret = glibtop_calloc_r (server, proclist.count, sizeof (unsigned)); - - buf->number = proclist.count; - buf->size = sizeof (unsigned); - buf->total = proclist.count * sizeof (unsigned); - - for (i = 0; i < proclist.count; i++) - ret [i] = proclist.pids [i]; - - buf->flags |= _glibtop_sysdeps_proclist; - - return ret; -} diff --git a/sysdeps/kernel/procmap.c b/sysdeps/kernel/procmap.c deleted file mode 100644 index 9c3557b7..00000000 --- a/sysdeps/kernel/procmap.c +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_map = -(1L << GLIBTOP_PROC_MAP_NUMBER) + (1L << GLIBTOP_PROC_MAP_TOTAL) + -(1L << GLIBTOP_PROC_MAP_SIZE); - -static const unsigned long _glibtop_sysdeps_map_entry = -(1L << GLIBTOP_MAP_ENTRY_START) + (1L << GLIBTOP_MAP_ENTRY_END) + -(1L << GLIBTOP_MAP_ENTRY_OFFSET) + (1L << GLIBTOP_MAP_ENTRY_PERM); - -static const unsigned long _glibtop_sysdeps_map_entry_vmfile = -(1L << GLIBTOP_MAP_ENTRY_INODE) + (1L << GLIBTOP_MAP_ENTRY_DEVICE) + -(1L << GLIBTOP_MAP_ENTRY_FILENAME); - -/* Init function. */ - -int -glibtop_init_proc_map_k (glibtop *server) -{ - server->sysdeps.proc_map = _glibtop_sysdeps_proc_map; - - return 0; -} - -/* Provides detailed information about a process. */ - -glibtop_map_entry * -glibtop_get_proc_map_k (glibtop *server, glibtop_proc_map *buf, pid_t pid) -{ - glibtop_map_entry *retval = NULL; - libgtop_proc_maps_t *maps; - size_t count, max_len, i; - int ret; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0); - - memset (buf, 0, sizeof (glibtop_proc_map)); - - /* Get number of map entries. */ - count = glibtop_get_proc_data_proc_maps_k (server, pid, NULL, 0); - - /* Allocate memory. */ - maps = glibtop_calloc_r (server, count, sizeof (libgtop_proc_maps_t)); - max_len = count * sizeof (libgtop_proc_maps_t); - - ret = glibtop_get_proc_data_proc_maps_k (server, pid, maps, max_len); - if (ret < 0) { - glibtop_free_r (server, maps); - return NULL; - } - - /* Calculate number of map entries. */ - count = ret / sizeof (libgtop_proc_maps_t); - - /* Allocate memory for the result. */ - retval = glibtop_calloc_r (server, count, sizeof (glibtop_map_entry)); - - for (i = 0; i < count; i++) { - char *filename; - - retval [i].start = maps [i].header.start; - retval [i].end = maps [i].header.end; - retval [i].offset = maps [i].header.offset; - - if (maps [i].header.perm & LIBGTOP_VM_READ) - retval [i].perm |= GLIBTOP_MAP_PERM_READ; - if (maps [i].header.perm & LIBGTOP_VM_WRITE) - retval [i].perm |= GLIBTOP_MAP_PERM_WRITE; - if (maps [i].header.perm & LIBGTOP_VM_EXEC) - retval [i].perm |= GLIBTOP_MAP_PERM_EXECUTE; - if (maps [i].header.perm & LIBGTOP_VM_SHARED) - retval [i].perm |= GLIBTOP_MAP_PERM_SHARED; - if (!(maps [i].header.perm & LIBGTOP_VM_MAYSHARE)) - retval [i].perm |= GLIBTOP_MAP_PERM_PRIVATE; - - retval [i].flags = _glibtop_sysdeps_map_entry; - - if (maps [i].header.device || maps [i].header.inode) { - retval [i].device = maps [i].header.device; - retval [i].inode = maps [i].header.inode; - - filename = maps [i].filename; - filename += maps [i].header.filename_offset; - - strncpy (retval [i].filename, filename, GLIBTOP_MAP_FILENAME_LEN); - retval [i].filename [GLIBTOP_MAP_FILENAME_LEN-1] = '\0'; - - retval [i].flags |= _glibtop_sysdeps_map_entry_vmfile; - } - } - - /* Free map entries. */ - glibtop_free_r (server, maps); - - /* Write retval. */ - buf->number = count; - buf->size = sizeof (glibtop_map_entry); - buf->total = buf->number * sizeof (glibtop_map_entry); - - buf->flags = _glibtop_sysdeps_proc_map; - - return retval; -} diff --git a/sysdeps/kernel/procmem.c b/sysdeps/kernel/procmem.c deleted file mode 100644 index 0cd33ead..00000000 --- a/sysdeps/kernel/procmem.c +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procmem.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_mem = -(1L << GLIBTOP_PROC_MEM_VSIZE) + (1L << GLIBTOP_PROC_MEM_SIZE) + -(1L << GLIBTOP_PROC_MEM_RESIDENT) + (1L << GLIBTOP_PROC_MEM_SHARE) + -(1L << GLIBTOP_PROC_MEM_RSS) + (1L << GLIBTOP_PROC_MEM_RSS_RLIM); - -#ifndef LOG1024 -#define LOG1024 10 -#endif - -/* these are for getting the memory statistics */ -static int pageshift; /* log base 2 of the pagesize */ - -/* define pagetok in terms of pageshift */ -#define pagetok(size) ((size) << pageshift) - -/* Init function. */ - -int -glibtop_init_proc_mem_k (glibtop *server) -{ - register int pagesize; - - server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem; - - /* get the page size with "getpagesize" and calculate pageshift. */ - pagesize = getpagesize (); - pageshift = 0; - while (pagesize > 1) { - pageshift++; - pagesize >>= 1; - } - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_mem_k (glibtop *server, glibtop_proc_mem *buf, - pid_t pid) -{ - libgtop_proc_mem_t proc_mem; - int retval; - - memset (buf, 0, sizeof (glibtop_proc_mem)); - - retval = glibtop_get_proc_data_proc_mem_k (server, &proc_mem, pid); - if (retval) - return retval; - - buf->vsize = proc_mem.segment.vsize; - - buf->size = proc_mem.size; - buf->resident = proc_mem.resident; - buf->share = proc_mem.share; - - buf->rss = proc_mem.rss; - buf->rss_rlim = proc_mem.rlim; - - buf->vsize <<= pageshift; - - buf->size <<= pageshift; - buf->resident <<= pageshift; - buf->share <<= pageshift; - - buf->flags = _glibtop_sysdeps_proc_mem; - - return 0; -} diff --git a/sysdeps/kernel/procsegment.c b/sysdeps/kernel/procsegment.c deleted file mode 100644 index fe385055..00000000 --- a/sysdeps/kernel/procsegment.c +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procsegment.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_segment = -(1L << GLIBTOP_PROC_SEGMENT_TEXT_RSS) + -(1L << GLIBTOP_PROC_SEGMENT_SHLIB_RSS) + -(1L << GLIBTOP_PROC_SEGMENT_DATA_RSS) + -(1L << GLIBTOP_PROC_SEGMENT_STACK_RSS) + -(1L << GLIBTOP_PROC_SEGMENT_DIRTY_SIZE); - -static const unsigned long _glibtop_sysdeps_proc_segment_state = -(1L << GLIBTOP_PROC_SEGMENT_START_CODE) + -(1L << GLIBTOP_PROC_SEGMENT_END_CODE) + -(1L << GLIBTOP_PROC_SEGMENT_START_STACK); - -#ifndef LOG1024 -#define LOG1024 10 -#endif - -/* these are for getting the memory statistics */ -static int pageshift; /* log base 2 of the pagesize */ - -/* define pagetok in terms of pageshift */ -#define pagetok(size) ((size) << pageshift) - -/* Init function. */ - -int -glibtop_init_proc_segment_k (glibtop *server) -{ - register int pagesize; - - server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment | - _glibtop_sysdeps_proc_segment_state; - - /* get the page size with "getpagesize" and calculate pageshift. */ - pagesize = getpagesize (); - pageshift = 0; - while (pagesize > 1) { - pageshift++; - pagesize >>= 1; - } - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_segment_k (glibtop *server, glibtop_proc_segment *buf, - pid_t pid) -{ - libgtop_proc_mem_t proc_mem; - libgtop_proc_state_t proc_state; - int retval; - - memset (buf, 0, sizeof (glibtop_proc_segment)); - - retval = glibtop_get_proc_data_proc_mem_k (server, &proc_mem, pid); - if (retval) - return retval; - - buf->text_rss = proc_mem.trs; - buf->shlib_rss = proc_mem.lrs; - buf->data_rss = proc_mem.drs; - buf->stack_rss = proc_mem.segment.stack; - buf->dirty_size = proc_mem.dt; - - buf->text_rss <<= pageshift; - buf->shlib_rss <<= pageshift; - buf->data_rss <<= pageshift; - buf->stack_rss <<= pageshift; - buf->dirty_size <<= pageshift; - - buf->flags = _glibtop_sysdeps_proc_segment; - - retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid); - if (retval) - return retval; - - buf->start_code = proc_state.start_code; - buf->end_code = proc_state.end_code; - buf->start_data = proc_state.start_data; - buf->end_data = proc_state.end_data; - buf->start_brk = proc_state.start_brk; - buf->end_brk = proc_state.brk; - - buf->start_stack = proc_state.start_stack; - buf->start_mmap = proc_state.start_mmap; - - buf->arg_start = proc_state.arg_start; - buf->arg_end = proc_state.arg_end; - buf->env_start = proc_state.env_start; - buf->env_end = proc_state.env_end; - - buf->flags |= _glibtop_sysdeps_proc_segment_state; - - return 0; -} diff --git a/sysdeps/kernel/procsignal.c b/sysdeps/kernel/procsignal.c deleted file mode 100644 index 4ac1878a..00000000 --- a/sysdeps/kernel/procsignal.c +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procsignal.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_signal = -(1L << GLIBTOP_PROC_SIGNAL_SIGNAL) + -(1L << GLIBTOP_PROC_SIGNAL_BLOCKED) + -(1L << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + -(1L << GLIBTOP_PROC_SIGNAL_SIGCATCH); - -/* Init function. */ - -int -glibtop_init_proc_signal_k (glibtop *server) -{ - server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_signal_k (glibtop *server, glibtop_proc_signal *buf, - pid_t pid) -{ - libgtop_proc_signal_t proc_signal; - int retval, i; - - memset (buf, 0, sizeof (glibtop_proc_signal)); - - retval = glibtop_get_proc_data_proc_signal_k (server, &proc_signal, pid); - if (retval) - return retval; - - for (i = 0; i < 1; i++) { - buf->signal [i] = proc_signal.signal [i]; - buf->blocked [i] = proc_signal.blocked [i]; - buf->sigignore [i] = proc_signal.ignore [i]; - buf->sigcatch [i] = proc_signal.catch [i]; - } - - buf->flags = _glibtop_sysdeps_proc_signal; - - return 0; -} diff --git a/sysdeps/kernel/procstate.c b/sysdeps/kernel/procstate.c deleted file mode 100644 index 50b00b3a..00000000 --- a/sysdeps/kernel/procstate.c +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procstate.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_state = -(1L << GLIBTOP_PROC_STATE_UID) + (1L << GLIBTOP_PROC_STATE_GID) + -(1L << GLIBTOP_PROC_STATE_RUID) + (1L << GLIBTOP_PROC_STATE_RGID) + -(1L << GLIBTOP_PROC_STATE_CMD) + (1L << GLIBTOP_PROC_STATE_STATE) + -(1L << GLIBTOP_PROC_STATE_HAS_CPU) + (1L << GLIBTOP_PROC_STATE_PROCESSOR) + -(1L << GLIBTOP_PROC_STATE_LAST_PROCESSOR); - -/* Init function. */ - -int -glibtop_init_proc_state_k (glibtop *server) -{ - server->sysdeps.proc_state = _glibtop_sysdeps_proc_state; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_state_k (glibtop *server, glibtop_proc_state *buf, - pid_t pid) -{ - libgtop_proc_state_t proc_state; - int retval; - - memset (buf, 0, sizeof (glibtop_proc_state)); - - retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid); - if (retval) - return retval; - - memcpy (buf->cmd, proc_state.comm, sizeof (buf->cmd)); - - if (proc_state.state & LIBGTOP_TASK_RUNNING) - buf->state |= GLIBTOP_PROCESS_RUNNING; - if (proc_state.state & LIBGTOP_TASK_INTERRUPTIBLE) - buf->state |= GLIBTOP_PROCESS_INTERRUPTIBLE; - if (proc_state.state & LIBGTOP_TASK_UNINTERRUPTIBLE) - buf->state |= GLIBTOP_PROCESS_UNINTERRUPTIBLE; - if (proc_state.state & LIBGTOP_TASK_ZOMBIE) - buf->state |= GLIBTOP_PROCESS_ZOMBIE; - if (proc_state.state & LIBGTOP_TASK_STOPPED) - buf->state |= GLIBTOP_PROCESS_STOPPED; - if (proc_state.state & LIBGTOP_TASK_SWAPPING) - buf->state |= GLIBTOP_PROCESS_SWAPPING; - - buf->uid = proc_state.euid; - buf->gid = proc_state.egid; - buf->ruid = proc_state.uid; - buf->rgid = proc_state.gid; - - buf->has_cpu = proc_state.has_cpu; - buf->processor = proc_state.processor; - buf->last_processor = proc_state.last_processor; - - buf->flags = _glibtop_sysdeps_proc_state; - - return 0; -} diff --git a/sysdeps/kernel/proctime.c b/sysdeps/kernel/proctime.c deleted file mode 100644 index 26ac25c9..00000000 --- a/sysdeps/kernel/proctime.c +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/proctime.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_time = -(1L << GLIBTOP_PROC_TIME_UTIME) + (1L << GLIBTOP_PROC_TIME_STIME) + -(1L << GLIBTOP_PROC_TIME_CUTIME) + (1L << GLIBTOP_PROC_TIME_CSTIME) + -(1L << GLIBTOP_PROC_TIME_START_TIME) + (1L << GLIBTOP_PROC_TIME_FREQUENCY); - -static const unsigned long _glibtop_sysdeps_proc_time_smp = -(1L << GLIBTOP_PROC_TIME_XCPU_UTIME) + (1L << GLIBTOP_PROC_TIME_XCPU_STIME); - -/* Init function. */ - -int -glibtop_init_proc_time_k (glibtop *server) -{ - server->sysdeps.proc_time = _glibtop_sysdeps_proc_time; - - if (server->ncpu) - server->sysdeps.proc_time |= _glibtop_sysdeps_proc_time_smp; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_time_k (glibtop *server, glibtop_proc_time *buf, - pid_t pid) -{ - libgtop_proc_state_t proc_state; - int retval, i; - - memset (buf, 0, sizeof (glibtop_proc_time)); - - retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid); - if (retval) - return retval; - - buf->start_time = proc_state.start_time; - buf->utime = proc_state.utime; - buf->stime = proc_state.stime; - buf->cutime = proc_state.cutime; - buf->cstime = proc_state.cstime; - - buf->frequency = 100; - - buf->flags = _glibtop_sysdeps_proc_time; - - for (i = 0; i < server->ncpu; i++) { - buf->xcpu_utime [i] = proc_state.per_cpu_utime [i]; - buf->xcpu_stime [i] = proc_state.per_cpu_stime [i]; - } - - if (server->ncpu) - buf->flags |= _glibtop_sysdeps_proc_time_smp; - - return 0; -} diff --git a/sysdeps/kernel/procuid.c b/sysdeps/kernel/procuid.c deleted file mode 100644 index d550b874..00000000 --- a/sysdeps/kernel/procuid.c +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procuid.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_uid = -(1L << GLIBTOP_PROC_UID_UID) + (1L << GLIBTOP_PROC_UID_EUID) + -(1L << GLIBTOP_PROC_UID_GID) + (1L << GLIBTOP_PROC_UID_EGID) + -(1L << GLIBTOP_PROC_UID_SUID) + (1L << GLIBTOP_PROC_UID_SGID) + -(1L << GLIBTOP_PROC_UID_FSUID) + (1L << GLIBTOP_PROC_UID_FSGID) + -(1L << GLIBTOP_PROC_UID_PID) + (1L << GLIBTOP_PROC_UID_PPID) + -(1L << GLIBTOP_PROC_UID_PGRP) + (1L << GLIBTOP_PROC_UID_SESSION) + -(1L << GLIBTOP_PROC_UID_TTY) + (1L << GLIBTOP_PROC_UID_TPGID) + -(1L << GLIBTOP_PROC_UID_PRIORITY) + (1L << GLIBTOP_PROC_UID_NICE) + -(1L << GLIBTOP_PROC_UID_NGROUPS) + (1L << GLIBTOP_PROC_UID_GROUPS); - -#ifndef min -#define min(a,b) ((a < b) ? a : b) -#endif - -/* Init function. */ - -int -glibtop_init_proc_uid_k (glibtop *server) -{ - server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_uid_k (glibtop *server, glibtop_proc_uid *buf, - pid_t pid) -{ - libgtop_proc_state_t proc_state; - long priority, nice; - int retval, i; - - memset (buf, 0, sizeof (glibtop_proc_uid)); - - retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid); - if (retval) - return retval; - - buf->uid = proc_state.uid; - buf->euid = proc_state.euid; - buf->gid = proc_state.gid; - buf->egid = proc_state.egid; - - buf->suid = proc_state.suid; - buf->sgid = proc_state.sgid; - buf->fsuid = proc_state.fsuid; - buf->fsgid = proc_state.fsgid; - - buf->pid = proc_state.pid; - buf->ppid = proc_state.ppid; - buf->pgrp = proc_state.pgrp; - - buf->session = proc_state.session; - buf->tty = proc_state.tty; - buf->tpgid = proc_state.tpgid; - - priority = proc_state.counter; - priority = 20 - (priority * 10 + proc_state.def_priority / 2) / - proc_state.def_priority; - nice = proc_state.priority; - nice = 20 - (nice * 20 + proc_state.def_priority / 2) / - proc_state.def_priority; - - buf->priority = priority; - buf->nice = nice; - - buf->ngroups = min (proc_state.ngroups, GLIBTOP_MAX_GROUPS); - for (i = 0; i < buf->ngroups; i++) - buf->groups [i] = proc_state.groups [i]; - - buf->flags = _glibtop_sysdeps_proc_uid; - - return 0; -} diff --git a/sysdeps/kernel/swap.c b/sysdeps/kernel/swap.c deleted file mode 100644 index 7375bc66..00000000 --- a/sysdeps/kernel/swap.c +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/swap.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_swap = -(1L << GLIBTOP_SWAP_TOTAL) + (1L << GLIBTOP_SWAP_USED) + -(1L << GLIBTOP_SWAP_FREE); - -static const unsigned long _glibtop_sysdeps_swap_stat = -(1L << GLIBTOP_SWAP_PAGEIN) + (1L << GLIBTOP_SWAP_PAGEOUT); - -/* Init function. */ - -int -glibtop_init_swap_k (glibtop *server) -{ - server->sysdeps.swap = _glibtop_sysdeps_swap | - _glibtop_sysdeps_swap_stat; - - return 0; -} - -/* Provides information about swap usage. */ - -int -glibtop_get_swap_k (glibtop *server, glibtop_swap *buf) -{ - libgtop_stat_t stat; - libgtop_swap_t swap; - int retval; - - memset (buf, 0, sizeof (glibtop_swap)); - - retval = glibtop_get_proc_data_swap_k (server, &swap); - if (retval) - return retval; - - buf->total = swap.totalswap; - buf->free = swap.freeswap; - buf->used = swap.totalswap - swap.freeswap; - - buf->flags = _glibtop_sysdeps_swap; - - retval = glibtop_get_proc_data_stat_k (server, &stat); - if (retval) - return retval; - - buf->pagein = stat.pswpin; - buf->pageout = stat.pswpout; - - buf->flags |= _glibtop_sysdeps_swap_stat; - - return 0; -} diff --git a/sysdeps/kernel/uptime.c b/sysdeps/kernel/uptime.c deleted file mode 100644 index 1deea29b..00000000 --- a/sysdeps/kernel/uptime.c +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/uptime.h> - -#include <glibtop_private.h> - -static unsigned long _glibtop_sysdeps_uptime = -(1L << GLIBTOP_UPTIME_UPTIME) + (1L << GLIBTOP_UPTIME_IDLETIME) + -(1L << GLIBTOP_UPTIME_BOOT_TIME); - -/* Init function. */ - -int -glibtop_init_uptime_k (glibtop *server) -{ - server->sysdeps.uptime = _glibtop_sysdeps_uptime; - - return 0; -} - -/* Provides uptime and idle time. */ - -int -glibtop_get_uptime_k (glibtop *server, glibtop_uptime *buf) -{ - libgtop_stat_t stat; - unsigned long total; - int retval; - - memset (buf, 0, sizeof (glibtop_uptime)); - - retval = glibtop_get_proc_data_stat_k (server, &stat); - if (retval) - return retval; - - total = stat.cpu.user + stat.cpu.nice + stat.cpu.sys + stat.cpu.idle; - - buf->uptime = (double) total / (double) stat.frequency; - buf->idletime = (double) stat.cpu.idle / (double) stat.frequency; - - buf->boot_time = stat.boot_time; - - buf->flags = _glibtop_sysdeps_uptime; - - return 0; -} diff --git a/sysdeps/linux/.cvsignore b/sysdeps/linux/.cvsignore deleted file mode 100644 index 635816db..00000000 --- a/sysdeps/linux/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -libgtop_sysdeps.la -*.lo diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog deleted file mode 100644 index 42cac47e..00000000 --- a/sysdeps/linux/ChangeLog +++ /dev/null @@ -1,160 +0,0 @@ -2000-04-24 Martin Baulig <baulig@suse.de> - - * proc_cwd.c: New file. This feature was requested by Nautilus - hacker Maciej Stachowiak and it returns the current working - directory of a process. - -2000-02-22 Martin Baulig <martin@home-of-linux.org> - - * Makefile.am: Only install the libs in $(LIBGTOP_BACKEND_DIR) - when we LIBGTOP_USE_GMODULE and in $(libdir) otherwise. - -2000-02-06 Martin Baulig <martin@home-of-linux.org> - - * ppp.c: Make this work with multiple ISDN devices. - -2000-01-22 Martin Baulig <martin@home-of-linux.org> - - * Makefile.am: Install the library in $(backenddir). - -1999-12-11 Martin Baulig <martin@home-of-linux.org> - - * cpu.c: Only set smp flags when we're really on a SMP machine. - -1999-11-28 Martin Baulig <martin@home-of-linux.org> - - * procstate.c (glibtop_get_procstate_s): Stat "/proc/<pid>" instead - of "/proc/<pid>/state" to get `uid' and `gid'. Thanks to Jason Becker - for pointing out that GTop reported wrong uid's. - -1999-11-21 Martin Baulig <martin@home-of-linux.org> - - * interfaces.c: New file. - (glibtop_init_interface_names_s): New function. - (glibtop_get_interface_names_s): New function. - -1999-11-21 Martin Baulig <martin@home-of-linux.org> - - * proclist.c: (glibtop_get_proclist_s): Support GLIBTOP_KERN_PROC_PPID. - -1999-10-19 Martin Baulig <martin@home-of-linux.org> - - * uptime.c (glibtop_get_uptime_s): Don't cast uptime and idletime - to float as suggested by John Kodis. - -1999-09-28 Radek Doulik <rodo@praha.eridan.cz> - - * proclist.c (glibtop_get_proclist_s): fixed idle processes filtering - -1999-07-29 Martin Baulig <martin@home-of-linux.org> - - * proctime.c (glibtop_get_proctime_s): Don't provide `rtime' - any longer since we must not use `rtime = utime + stime'. - -1999-02-20 Martin Baulig <martin@home-of-linux.org> - - * netload.c: Don't include <linux/ip_fw.h> for libc5 systems - since it is no longer required and makes trouble on Slakware. - -1999-01-06 Martin Baulig <martin@home-of-linux.org> - - * netload.c (glibtop_get_netload_s): Use `server->os_version_code' - instead of GLIBTOP_LINUX_VERSION_CODE. - -1999-01-06 Martin Baulig <martin@home-of-linux.org> - - Unconditionally enable SMP support for linux. - - * open.c (_glibtop_open_s): Always determine the number of CPUs - we have here, not only when SMP support was enabled. - - * cpu.c, proctime.c: Use `server->ncpu' to determine whether to - enable SMP support. - -1998-12-28 Martin Baulig <martin@home-of-linux.org> - - * netload.c: When using glibc, don't include <netinet/ip_fw.h> - any longer but all headers that were included there; we only - needed this file to get those headers. - -1998-12-09 Martin Baulig <martin@home-of-linux.org> - - * procargs.c (glibtop_get_proc_args_s): Added implementation - for this function. - -1998-12-03 Martin Baulig <martin@home-of-linux.org> - - * netload.c: No longer include <linux/version.h>, but use - GLIBTOP_LINUX_VERSION_CODE which is set by configure instead. - Define _GLIBTOP_IP_FW_ACCTIN and _GLIBTOP_IP_FW_ACCTOUT here - and use them instead of IP_FW_F_ACCTIN and IP_FW_F_ACCTOUT. - -1998-11-30 Martin Baulig <martin@home-of-linux.org> - - * netload.c: Use correct header files both for libc5 and glibc. - With Linux >= 2.1.114 we no longer use IP accounting since it - already has byte counts in /proc/net/dev. - -1998-11-22 Martin Baulig <baulig@merkur.uni-trier.de> - - * netload.c (glibtop_get_netload_s): Added implementation - for this function. - - The code here is smart enough to use /proc/net/ip_acct if - IP accounting is enabled in the kernel and activated on the - requested device and /proc/net/dev if not. - - To get separate statistics for received and transmitted - packets you need to use two accounting rules: - - ipfwadm -A in -a -P all -W eth0 - ipfwadm -A out -a -P all -W eth0 - - But before you activate IP accounting, please have a look - at /proc/net/dev - if if already contains byte counters, - then don't use IP accounting. - -1998-10-28 Martin Baulig <martin@home-of-linux.org> - - * ppp.c: Added code for ISDN here. - -1998-10-26 Martin Baulig <martin@home-of-linux.org> - - * netload.c: New file. Currently empty. - -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. - -1998-10-11 Martin Baulig <martin@home-of-linux.org> - - * procdata.c: Removed this obsolete file. - -1998-10-02 Martin Baulig <martin@home-of-linux.org> - - * proclist.c (glibtop_init_proclist_s): You can now also use the - `GLIBTOP_EXCLUDE_*' flags for the `which' parameter. - -1998-10-01 Martin Baulig <baulig@Stud.Informatik.uni-trier.de> - - * proclist.c (glibtop_init_proclist_s): Honor the `which' parameter - to select which processes to fetch. - -1998-09-12 Martin Baulig <martin@home-of-linux.org> - - * sysinfo.c: New file. - -1998-09-09 Martin Baulig <baulig@Stud.Informatik.uni-trier.de> - - * proctime.c (glibtop_get_proc_time_s): Added SMP support. - - * open.c (glibtop_init_s): Initialize `ncpu' on SMP systems. - - * cpu.c (glibtop_get_cpu_s): Added SMP support. - - * ChangeLog: New file. - diff --git a/sysdeps/linux/Makefile.am b/sysdeps/linux/Makefile.am deleted file mode 100644 index 1c55d76f..00000000 --- a/sysdeps/linux/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ - -INCLUDES = @INCLUDES@ - -dynamic_ldflags = @libgtop_dynamic_ldflags@ - -backenddir = @LIBGTOP_BACKEND_DIR@ - -if LIBGTOP_USE_GMODULE -backendlibdir = $(backenddir) -else -backendlibdir = $(libdir) -endif - -backendlib_LTLIBRARIES = libgtop_sysdeps.la - -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 proccwd.c procargs.c procmap.c \ - sysinfo.c interfaces.c netinfo.c netload.c ppp.c -libgtop_sysdeps_la_LIBADD = @GLIB_LIBS@ - -libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) $(dynamic_ldflags) - -include_HEADERS = glibtop_server.h glibtop_machine.h diff --git a/sysdeps/linux/backend-info.xml b/sysdeps/linux/backend-info.xml deleted file mode 100644 index 1ee92c4d..00000000 --- a/sysdeps/linux/backend-info.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0"?> <!-- -*-xml-*- --> -<!DOCTYPE libgtop:backendinfo SYSTEM 'libgtop-backend-info.dtd'> -<libgtop:BackendInfo xmlns:libgtop="http://www.home-of-linux.org/libgtop/1.1"> - - <name> - <short_name> - linux-sysdeps - </short_name> - - <long_name> - Linux sysdeps port. - </long_name> - </name> - - <description> - This is the Linux sysdeps port which uses the /proc filesystem - to get all the data. - </description> - - <authors> - <author> - <author_name> - Martin Baulig - </author_name> - <author_email> - martin@home-of-linux.org - </author_email> - </author> - </authors> - - <legalnotice> - <license> - GNU General Public License - </license> - </legalnotice> - -</libgtop:BackendInfo> diff --git a/sysdeps/linux/close.c b/sysdeps/linux/close.c deleted file mode 100644 index 3378b817..00000000 --- a/sysdeps/linux/close.c +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop/close.h> - -/* Closes pipe to gtop server. */ - -void -glibtop_close_s (glibtop *server) -{ } diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c deleted file mode 100644 index f8918611..00000000 --- a/sysdeps/linux/cpu.c +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/error.h> -#include <glibtop/cpu.h> - -static const unsigned long _glibtop_sysdeps_cpu = -(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) + -(1L << GLIBTOP_CPU_NICE) + (1L << GLIBTOP_CPU_SYS) + -(1L << GLIBTOP_CPU_IDLE) + (1L << GLIBTOP_CPU_FREQUENCY); - -static const unsigned long _glibtop_sysdeps_cpu_smp = -(1L << GLIBTOP_CPU_XCPU_TOTAL) + (1L << GLIBTOP_CPU_XCPU_USER) + -(1L << GLIBTOP_CPU_XCPU_NICE) + (1L << GLIBTOP_CPU_XCPU_SYS) + -(1L << GLIBTOP_CPU_XCPU_IDLE) + (1L << GLIBTOP_CPU_XCPU_FLAGS); - -/* Init function. */ - -int -glibtop_init_cpu_s (glibtop *server) -{ - server->sysdeps.cpu = _glibtop_sysdeps_cpu; - - if (server->ncpu) - server->sysdeps.cpu |= _glibtop_sysdeps_cpu_smp; - - return 0; -} - -/* Provides information about cpu usage. */ - -#define FILENAME "/proc/stat" - -int -glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) -{ - char buffer [BUFSIZ], *p; - int fd, len, i; - u_int64_t total; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0); - - memset (buf, 0, sizeof (glibtop_cpu)); - - fd = open (FILENAME, O_RDONLY); - if (fd < 0) { - glibtop_warn_io_r (server, "open (%s)", FILENAME); - return -1; - } - - len = read (fd, buffer, BUFSIZ-1); - if (len < 0) { - close (fd); - glibtop_warn_io_r (server, "read (%s)", FILENAME); - return -1; - } - - close (fd); - - buffer [len] = '\0'; - - p = skip_token (buffer); /* "cpu" */ - - buf->user = strtoul (p, &p, 0); - buf->nice = strtoul (p, &p, 0); - buf->sys = strtoul (p, &p, 0); - buf->idle = strtoul (p, &p, 0); - - total = buf->user; - total += buf->nice; - total += buf->sys; - total += buf->idle; - buf->total = total; - - buf->frequency = 100; - buf->flags = _glibtop_sysdeps_cpu; - - for (i = 0; i < server->ncpu; i++) { - if (strncmp (p+1, "cpu", 3) || !isdigit (p [4])) - break; - - buf->xcpu_flags |= (1L << (u_int64_t) i); - - p += 6; - buf->xcpu_user [i] = strtoul (p, &p, 0); - buf->xcpu_nice [i] = strtoul (p, &p, 0); - buf->xcpu_sys [i] = strtoul (p, &p, 0); - buf->xcpu_idle [i] = strtoul (p, &p, 0); - - total = buf->xcpu_user [i]; - total += buf->xcpu_nice [i]; - total += buf->xcpu_sys [i]; - total += buf->xcpu_idle [i]; - - buf->xcpu_total [i] = total; - } - - if (buf->xcpu_flags) - buf->flags |= _glibtop_sysdeps_cpu_smp; - - return 0; -} diff --git a/sysdeps/linux/glibtop_machine.h b/sysdeps/linux/glibtop_machine.h deleted file mode 100644 index dc0ee227..00000000 --- a/sysdeps/linux/glibtop_machine.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_MACHINE_H__ -#define __GLIBTOP_MACHINE_H__ - -#include <unistd.h> -#include <fcntl.h> -#include <ctype.h> - -BEGIN_LIBGTOP_DECLS - -#if _IN_LIBGTOP - -static inline char * -skip_token(const char *p) -{ - while (isspace(*p)) p++; - while (*p && !isspace(*p)) p++; - return (char *)p; -} - -#endif - -typedef struct _glibtop_machine glibtop_machine; - -struct _glibtop_machine -{ - pid_t last_pid; - int no_update; - int fd_stat, fd_meminfo, fd_loadavg; - char proc_stat [BUFSIZ], proc_statm [BUFSIZ]; - char proc_status [BUFSIZ]; -}; - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/linux/glibtop_server.h b/sysdeps/linux/glibtop_server.h deleted file mode 100644 index a8d3e083..00000000 --- a/sysdeps/linux/glibtop_server.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_SERVER_H__ -#define __GLIBTOP_SERVER_H__ - -#include <fcntl.h> -#include <ctype.h> - -BEGIN_LIBGTOP_DECLS - -#ifdef _IN_LIBGTOP - -static inline char * -skip_token (const char *p) -{ - while (isspace(*p)) p++; - while (*p && !isspace(*p)) p++; - return (char *)p; -} - -static inline char * -skip_multiple_token (const char *p, int count) -{ - int i; - - for (i = 0; i < count; i++) - p = skip_token (p); - - return (char *)p; -} - -static inline char * -skip_line (const char *p) -{ - while (*p != '\n') p++; - return (char *) ++p; -} - -static inline int -proc_file_to_buffer (char *buffer, const char *fmt, pid_t pid) -{ - char filename [BUFSIZ]; - int fd, len; - - sprintf (filename, fmt, pid); - - fd = open (filename, O_RDONLY); - if (fd < 0) return -1; - - len = read (fd, buffer, BUFSIZ-1); - close (fd); - - if (len < 0) - return -1; - - buffer [len] = '\0'; - - return 0; -} - -static inline int -proc_stat_to_buffer (char *buffer, pid_t pid) -{ - return proc_file_to_buffer (buffer, "/proc/%d/stat", pid); -} - -static inline int -proc_status_to_buffer (char *buffer, pid_t pid) -{ - return proc_file_to_buffer (buffer, "/proc/%d/status", pid); -} - -static inline int -proc_statm_to_buffer (char *buffer, pid_t pid) -{ - return proc_file_to_buffer (buffer, "/proc/%d/statm", pid); -} - -static inline char * -proc_stat_after_cmd (char *p) -{ - p = strrchr (p, ')'); - if (!p) return p; - - *p++ = '\0'; - return p; -} - -#endif - -#define GLIBTOP_SUID_CPU 0 -#define GLIBTOP_SUID_MEM 0 -#define GLIBTOP_SUID_SWAP 0 -#define GLIBTOP_SUID_UPTIME 0 -#define GLIBTOP_SUID_LOADAVG 0 -#define GLIBTOP_SUID_SHM_LIMITS 0 -#define GLIBTOP_SUID_MSG_LIMITS 0 -#define GLIBTOP_SUID_SEM_LIMITS 0 -#define GLIBTOP_SUID_PROCLIST 0 -#define GLIBTOP_SUID_PROC_STATE 0 -#define GLIBTOP_SUID_PROC_UID 0 -#define GLIBTOP_SUID_PROC_MEM 0 -#define GLIBTOP_SUID_PROC_TIME 0 -#define GLIBTOP_SUID_PROC_SIGNAL 0 -#define GLIBTOP_SUID_PROC_KERNEL 0 -#define GLIBTOP_SUID_PROC_SEGMENT 0 -#define GLIBTOP_SUID_PROC_ARGS 0 -#define GLIBTOP_SUID_PROC_MAP 0 -#define GLIBTOP_SUID_NETINFO 0 -#define GLIBTOP_SUID_NETLOAD 0 -#define GLIBTOP_SUID_INTERFACE_NAMES 0 -#define GLIBTOP_SUID_PPP 0 - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/linux/interfaces.c b/sysdeps/linux/interfaces.c deleted file mode 100644 index e3887867..00000000 --- a/sysdeps/linux/interfaces.c +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/interfaces.h> - -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/ioctl.h> -#include <netinet/in.h> -#include <net/if.h> - -static const unsigned long _glibtop_sysdeps_interface_names = -(1L << GLIBTOP_INTERFACE_NAMES_NUMBER) + -(1L << GLIBTOP_INTERFACE_NAMES_SIZE); - -/* Init function. */ - -int -glibtop_init_interface_names_s (glibtop *server) -{ - server->sysdeps.interface_names = _glibtop_sysdeps_interface_names; - - return 0; -} - -/* Provides network statistics. */ - -glibtop_interface * -glibtop_get_interface_names_s (glibtop *server, glibtop_array *array, - u_int64_t interface, u_int64_t number, - u_int64_t instance, u_int64_t strategy) -{ - GPtrArray *parray; - u_int64_t strategy_flags; - glibtop_interface *retval = NULL; - int skfd, i, n, numreqs = 30; - struct ifconf ifc; - struct ifreq *ifr; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_INTERFACE_NAMES, 0); - - memset (array, 0, sizeof (glibtop_array)); - - strategy_flags = strategy & GLIBTOP_STRATEGY_FLAGS_MASK; - strategy &= ~GLIBTOP_STRATEGY_FLAGS_MASK; - - parray = g_ptr_array_new (); - - skfd = socket (AF_INET, SOCK_DGRAM, 0); - if (!skfd) { - glibtop_error_io_r (server, "socket (AF_INET, SOCK_DGRAM, 0)"); - return NULL; - } - - ifc.ifc_buf = NULL; - for (;;) { - ifc.ifc_len = sizeof (struct ifreq) * numreqs; - ifc.ifc_buf = glibtop_realloc_r (server, ifc.ifc_buf, ifc.ifc_len); - - if (ioctl (skfd, SIOCGIFCONF, &ifc) < 0) { - glibtop_error_io_r (server, "SIOCGIFCONF"); - glibtop_free_r (server, ifc.ifc_buf); - return NULL; - } - if (ifc.ifc_len == sizeof (struct ifreq) * numreqs) { - /* assume it overflowed and try again */ - numreqs += 10; - continue; - } - break; - } - - ifr = ifc.ifc_req; - for (n = 0; n < ifc.ifc_len; n += sizeof(struct ifreq), ifr++) { - glibtop_interface *interface_ptr; - - if (strchr (ifr->ifr_name, ':')) { - /* This is a logical interface */ - if (!(strategy_flags & GLIBTOP_INTERFACES_INCLUDE_LOGICAL)) - continue; - } - - interface_ptr = g_new0 (glibtop_interface, 1); - - strcpy (interface_ptr->name, ifr->ifr_name); - - g_ptr_array_add (parray, interface_ptr); - } - - glibtop_free_r (server, ifc.ifc_buf); - - close (skfd); - - retval = glibtop_calloc_r (server, parray->len, sizeof (glibtop_interface)); - - for (i = 0; i < parray->len; i++) - retval [i] = *(glibtop_interface *) parray->pdata [i]; - - array->number = parray->len; - array->size = sizeof (glibtop_interface); - array->total = array->number * array->size; - - g_ptr_array_free (parray, TRUE); - - return retval; -} diff --git a/sysdeps/linux/loadavg.c b/sysdeps/linux/loadavg.c deleted file mode 100644 index 9bd25a87..00000000 --- a/sysdeps/linux/loadavg.c +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/error.h> -#include <glibtop/loadavg.h> - -static const unsigned long _glibtop_sysdeps_loadavg = -(1L << GLIBTOP_LOADAVG_LOADAVG); - -static const unsigned long _glibtop_sysdeps_loadavg_tasks = -(1L << GLIBTOP_LOADAVG_NR_RUNNING) + -(1L << GLIBTOP_LOADAVG_NR_TASKS) + -(1L << GLIBTOP_LOADAVG_LAST_PID); - -/* Init function. */ - -int -glibtop_init_loadavg_s (glibtop *server) -{ - server->sysdeps.loadavg = _glibtop_sysdeps_loadavg; - - return 0; -} - -/* Provides load load averange. */ - -#define FILENAME "/proc/loadavg" - -int -glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) -{ - char buffer [BUFSIZ], *p, *old; - int fd, len; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_LOADAVG, 0); - - memset (buf, 0, sizeof (glibtop_loadavg)); - - fd = open (FILENAME, O_RDONLY); - if (fd < 0) { - glibtop_warn_io_r (server, "open (%s)", FILENAME); - return -1; - } - - len = read (fd, buffer, BUFSIZ-1); - if (len < 0) { - close (fd); - glibtop_warn_io_r (server, "read (%s)", FILENAME); - return -1; - } - - close (fd); - - buffer [len] = '\0'; - - buf->loadavg [0] = (float) strtod (buffer, &p); - buf->loadavg [1] = (float) strtod (p, &p); - buf->loadavg [2] = (float) strtod (p, &p); - - buf->flags = _glibtop_sysdeps_loadavg; - - while (isspace(*p)) p++; - - /* Older Linux versions don't have the nr_running/nr_tasks fields. */ - - old = p; - while (*p) { - if (*p == '/') - break; - if (!isdigit (*p)) - return 0; - p++; - } - - buf->nr_running = strtoul (old, &p, 0); p++; - buf->nr_tasks = strtoul (p, &p, 0); - buf->last_pid = strtoul (p, &p, 0); - - buf->flags |= _glibtop_sysdeps_loadavg_tasks; - - return 0; -} diff --git a/sysdeps/linux/mem.c b/sysdeps/linux/mem.c deleted file mode 100644 index ae8770c8..00000000 --- a/sysdeps/linux/mem.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/error.h> -#include <glibtop/mem.h> - -static const unsigned long _glibtop_sysdeps_mem = -(1L << GLIBTOP_MEM_TOTAL) + (1L << GLIBTOP_MEM_USED) + -(1L << GLIBTOP_MEM_FREE) + (1L << GLIBTOP_MEM_SHARED) + -(1L << GLIBTOP_MEM_BUFFER) + (1L << GLIBTOP_MEM_CACHED) + -(1L << GLIBTOP_MEM_USER); - -/* Init function. */ - -int -glibtop_init_mem_s (glibtop *server) -{ - server->sysdeps.mem = _glibtop_sysdeps_mem; - - return 0; -} - -/* Provides information about memory usage. */ - -#define FILENAME "/proc/meminfo" - -int -glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) -{ - char buffer [BUFSIZ], *p; - int fd, len; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0); - - memset (buf, 0, sizeof (glibtop_mem)); - - fd = open (FILENAME, O_RDONLY); - if (fd < 0) { - glibtop_warn_io_r (server, "open (%s)", FILENAME); - return -1; - - } - - len = read (fd, buffer, BUFSIZ-1); - if (len < 0) { - close (fd); - glibtop_warn_io_r (server, "read (%s)", FILENAME); - return -1; - } - - close (fd); - - buffer [len] = '\0'; - - p = skip_line (buffer); - p = skip_token (p); /* "Mem:" */ - - buf->total = strtoul (p, &p, 0); - buf->used = strtoul (p, &p, 0); - buf->free = strtoul (p, &p, 0); - buf->shared = strtoul (p, &p, 0); - buf->buffer = strtoul (p, &p, 0); - buf->cached = strtoul (p, &p, 0); - - buf->user = buf->total - buf->free - buf->shared - buf->buffer; - - buf->flags = _glibtop_sysdeps_mem; - - return 0; -} diff --git a/sysdeps/linux/msg_limits.c b/sysdeps/linux/msg_limits.c deleted file mode 100644 index 2fe1d46c..00000000 --- a/sysdeps/linux/msg_limits.c +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop/msg_limits.h> - -#include <sys/ipc.h> -#include <sys/msg.h> - -static const unsigned long _glibtop_sysdeps_msg_limits = -(1L << GLIBTOP_MSG_LIMITS_MSGPOOL) + (1L << GLIBTOP_MSG_LIMITS_MSGMAP) + -(1L << GLIBTOP_MSG_LIMITS_MSGMAX) + (1L << GLIBTOP_MSG_LIMITS_MSGMNB) + -(1L << GLIBTOP_MSG_LIMITS_MSGMNI) + (1L << GLIBTOP_MSG_LIMITS_MSGSSZ) + -(1L << GLIBTOP_MSG_LIMITS_MSGTQL); - -/* Init function. */ - -int -glibtop_init_msg_limits_s (glibtop *server) -{ - server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf) -{ - struct msginfo msginfo; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0); - - memset (buf, 0, sizeof (glibtop_msg_limits)); - - buf->flags = _glibtop_sysdeps_msg_limits; - - msgctl (0, IPC_INFO, (struct msqid_ds *) &msginfo); - - buf->msgpool = msginfo.msgpool; - buf->msgmap = msginfo.msgmap; - buf->msgmax = msginfo.msgmax; - buf->msgmnb = msginfo.msgmnb; - buf->msgmni = msginfo.msgmni; - buf->msgssz = msginfo.msgssz; - buf->msgtql = msginfo.msgtql; - - return 0; -} diff --git a/sysdeps/linux/netinfo.c b/sysdeps/linux/netinfo.c deleted file mode 100644 index e15e1319..00000000 --- a/sysdeps/linux/netinfo.c +++ /dev/null @@ -1,383 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/netinfo.h> - -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/ioctl.h> - -#include <sys/sysctl.h> - -#ifndef HAVE_AFINET -#define HAVE_AFINET 1 -#endif - -#ifndef HAVE_AFINET6 -#define HAVE_AFINET6 1 -#endif - -#ifdef HAVE_AFINET6 - -#define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6" - -#define IPV6_ADDR_LOOPBACK 0x0010U -#define IPV6_ADDR_LINKLOCAL 0x0020U -#define IPV6_ADDR_SITELOCAL 0x0040U - -#define IPV6_ADDR_COMPATv4 0x0080U - -#endif /* HAVE_AFINET6 */ - -#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 -/* GNU LibC */ -#include <net/if.h> -#include <netinet/ip_icmp.h> -#include <netinet/in.h> -#include <netinet/ip.h> -#include <netinet/tcp.h> -#include <netinet/udp.h> -#include <net/if.h> -#else /* Libc 5 */ -#include <linux/if.h> -#include <linux/in.h> -#include <linux/ip.h> -#include <linux/icmp.h> -#include <linux/tcp.h> -#include <linux/udp.h> -#endif - -static const unsigned long _glibtop_sysdeps_netinfo = -(1L << GLIBTOP_NETINFO_TRANSPORT) + -(1L << GLIBTOP_NETINFO_IF_FLAGS) + -(1L << GLIBTOP_NETINFO_ADDRESS) + -(1L << GLIBTOP_NETINFO_SUBNET) + -(1L << GLIBTOP_NETINFO_MTU); - -/* Init function. */ - -int -glibtop_init_netinfo_s (glibtop *server) -{ - server->sysdeps.netinfo = _glibtop_sysdeps_netinfo; - - return 0; -} - -#ifdef HAVE_AFINET - -static int -_netinfo_ipv4 (glibtop *server, glibtop_netinfo *buf, - const char *interface, glibtop_ifaddr *address) -{ - int skfd; - - skfd = socket (AF_INET, SOCK_DGRAM, 0); - if (skfd) { - struct ifreq ifr; - unsigned flags; - - if (address) { - address->transport = GLIBTOP_TRANSPORT_IPV4; - address->flags |= (1L << GLIBTOP_IFADDR_TRANSPORT); - - buf->transport = GLIBTOP_TRANSPORT_IPV4; - buf->flags |= (1L << GLIBTOP_NETINFO_TRANSPORT); - } - - strcpy (ifr.ifr_name, interface); - if (!ioctl (skfd, SIOCGIFFLAGS, &ifr)) { - buf->flags |= (1L << GLIBTOP_NETINFO_IF_FLAGS); - flags = ifr.ifr_flags; - } else - flags = 0; - - if (flags & IFF_UP) - buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_UP); - - if (flags & IFF_BROADCAST) - buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_BROADCAST); - - if (flags & IFF_DEBUG) - buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_DEBUG); - - if (flags & IFF_LOOPBACK) - buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_LOOPBACK); - - if (flags & IFF_POINTOPOINT) - buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_POINTOPOINT); - - if (flags & IFF_RUNNING) - buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_RUNNING); - - if (flags & IFF_NOARP) - buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_NOARP); - - if (flags & IFF_PROMISC) - buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_PROMISC); - - if (flags & IFF_ALLMULTI) - buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_ALLMULTI); - - if (flags & IFF_MULTICAST) - buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_MULTICAST); - - if (address) { - strcpy (ifr.ifr_name, interface); - if (!ioctl (skfd, SIOCGIFADDR, &ifr)) { - struct sockaddr_in addr = - *(struct sockaddr_in *) &ifr.ifr_addr; - - address->addr_len = 4; - memcpy (&address->address, &addr.sin_addr.s_addr, 4); - - address->flags |= (1L << GLIBTOP_IFADDR_ADDRESS); - address->flags |= (1L << GLIBTOP_IFADDR_ADDR_LEN); - } - - strcpy (ifr.ifr_name, interface); - if (!ioctl (skfd, SIOCGIFNETMASK, &ifr)) { - struct sockaddr_in addr = - *(struct sockaddr_in *) &ifr.ifr_addr; - - memcpy (&address->subnet, &addr.sin_addr.s_addr, 4); - address->flags |= (1L << GLIBTOP_IFADDR_SUBNET); - } - } - - strcpy (ifr.ifr_name, interface); - if (!ioctl (skfd, SIOCGIFMTU, &ifr)) { - buf->mtu = ifr.ifr_mtu; - buf->flags |= (1L << GLIBTOP_NETINFO_MTU); - } - - close (skfd); - } - - return 0; -} - -#endif /* HAVE_AFINET */ - -#ifdef HAVE_AFINET6 - -static int -_parse_ipv6_address (const char *addr_string, u_int8_t *dest) -{ - int i; - - if (strlen (addr_string) != 32) - return -1; - - for (i = 0; i < 16; i++) { - char c1, c2; - int d1, d2; - - c1 = tolower (addr_string [(i<<1)]); - c2 = tolower (addr_string [(i<<1)+1]); - - if ((c1 >= '0') && (c1 <= '9')) - d1 = c1-'0'; - else if ((c1 >= 'a') && (c1 <= 'f')) - d1 = c1-'a'+10; - else - return -1; - - if ((c2 >= '0') && (c2 <= '9')) - d2 = c2-'0'; - else if ((c2 >= 'a') && (c2 <= 'f')) - d2 = c2-'a'+10; - else - return -1; - - dest [i] = (d1 << 4) + d2; - } - - return 0; -} - -static int -_netinfo_ipv6 (glibtop *server, glibtop_netinfo *buf, - const char *interface, GPtrArray *parray) -{ - FILE *f; - char addr6[40], devname[20]; - int plen, scope, dad_status, if_idx; - -#ifdef HAVE_AFINET6 - /* get common things such as mtu and if_flags */ - _netinfo_ipv4 (server, buf, interface, NULL); -#endif - - buf->transport = GLIBTOP_TRANSPORT_IPV6; - buf->flags |= (1L << GLIBTOP_NETINFO_TRANSPORT); - - f = fopen (_PATH_PROCNET_IFINET6, "r"); - - if (f != NULL) { - while (fscanf (f, "%64s %02x %02x %02x %02x %20s\n", - addr6, &if_idx, &plen, &scope, &dad_status, - devname) != EOF) { - glibtop_ifaddr address; - - memset (&address, 0, sizeof (glibtop_ifaddr)); - - if (strcmp (devname, interface)) - continue; - - if (!_parse_ipv6_address (addr6, address.address)) - address.flags |= (1L << GLIBTOP_IFADDR_ADDRESS); - - address.transport = GLIBTOP_TRANSPORT_IPV6; - address.subnet = plen; - - switch (scope) { - case 0: - address.scope = GLIBTOP_IPV6_SCOPE_GLOBAL; - break; - case IPV6_ADDR_LINKLOCAL: - address.scope = GLIBTOP_IPV6_SCOPE_LINKLOCAL; - break; - case IPV6_ADDR_SITELOCAL: - address.scope = GLIBTOP_IPV6_SCOPE_SITELOCAL; - break; - case IPV6_ADDR_COMPATv4: - address.scope = GLIBTOP_IPV6_SCOPE_COMPATv4; - break; - case IPV6_ADDR_LOOPBACK: - address.scope = GLIBTOP_IPV6_SCOPE_LOOPBACK; - break; - default: - address.scope = GLIBTOP_IPV6_SCOPE_UNKNOWN; - break; - } - - address.addr_len = 8; - - address.flags |= (1L << GLIBTOP_IFADDR_TRANSPORT) | - (1L << GLIBTOP_IFADDR_ADDR_LEN) | - (1L << GLIBTOP_IFADDR_SUBNET) | - (1L << GLIBTOP_IFADDR_SCOPE); - - g_ptr_array_add (parray, g_memdup (&address, sizeof (address))); - } - } - - fclose (f); - - return 0; -} - -#endif /* HAVE_AFINET6 */ - -/* Provides network statistics. */ - -glibtop_ifaddr * -glibtop_get_netinfo_s (glibtop *server, glibtop_array *array, - glibtop_netinfo *buf, const char *interface, - u_int64_t transport) -{ - GPtrArray *parray; - glibtop_ifaddr *retval = NULL; - int i; - - memset (buf, 0, sizeof (glibtop_netinfo)); - - if (strlen (interface) >= GLIBTOP_INTERFACE_LEN) - return NULL; - - /* Assume IPv4 is the standard until IPv6 becomes more popular. */ - if (transport == GLIBTOP_TRANSPORT_DEFAULT) - transport = GLIBTOP_TRANSPORT_ALL; - - /* Get information about all possible transport methods. */ - if (transport == GLIBTOP_TRANSPORT_ALL) { - char buffer [BUFSIZ]; - struct stat statb; - - /* We may get a little speed improvement when we use sysctl () - * directly, but the following piece of code seems very stable - * and reliable to me. - * - * The first stat() on "/proc/sys/net" is done to find out whether - * the kernel has sysctl support. - * - * January 23, 1999 - * Martin - */ - - if (!stat ("/proc/sys/net", &statb) && S_ISDIR (statb.st_mode)) { - buf->flags |= (1L << GLIBTOP_NETINFO_TRANSPORT); - - sprintf (buffer, "/proc/sys/net/ipv4/conf/%s", interface); - if (!stat (buffer, &statb) && S_ISDIR (statb.st_mode)) - buf->transport |= GLIBTOP_TRANSPORT_IPV4; - - sprintf (buffer, "/proc/sys/net/ipv6/conf/%s", interface); - if (!stat (buffer, &statb) && S_ISDIR (statb.st_mode)) - buf->transport |= GLIBTOP_TRANSPORT_IPV6; - } - } - - parray = g_ptr_array_new (); - -#ifdef HAVE_AFINET - if (transport & GLIBTOP_TRANSPORT_IPV4) { - glibtop_ifaddr address; - - memset (&address, 0, sizeof (glibtop_ifaddr)); - - _netinfo_ipv4 (server, buf, interface, &address); - if (address.flags & (1L << GLIBTOP_IFADDR_ADDRESS)) - g_ptr_array_add (parray, g_memdup (&address, sizeof (address))); - } -#endif /* HAVE_AFINET */ - -#ifdef HAVE_AFINET6 - if (transport & GLIBTOP_TRANSPORT_IPV6) - _netinfo_ipv6 (server, buf, interface, parray); -#endif /* HAVE_AFINET6 */ - - if (!parray->len) { - g_ptr_array_free (parray, TRUE); - return NULL; - } - - retval = glibtop_calloc_r (server, parray->len, sizeof (glibtop_ifaddr)); - - for (i = 0; i < parray->len; i++) - retval [i] = *(glibtop_ifaddr *) parray->pdata [i]; - - array->number = parray->len; - array->size = sizeof (glibtop_ifaddr); - array->total = array->number * array->size; - - g_ptr_array_free (parray, TRUE); - - return retval; -} diff --git a/sysdeps/linux/netload.c b/sysdeps/linux/netload.c deleted file mode 100644 index 8300fe1f..00000000 --- a/sysdeps/linux/netload.c +++ /dev/null @@ -1,288 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/netload.h> - -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/ioctl.h> - -#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 -/* GNU LibC */ -#include <net/if.h> -#include <netinet/ip_icmp.h> -#include <netinet/in.h> -#include <netinet/ip.h> -#include <netinet/tcp.h> -#include <netinet/udp.h> -#include <net/if.h> -#else /* Libc 5 */ -#include <linux/if.h> -#include <linux/in.h> -#include <linux/ip.h> -#include <linux/icmp.h> -#include <linux/tcp.h> -#include <linux/udp.h> -#endif - -#define _GLIBTOP_IP_FW_ACCTIN 0x1000 /* Account incoming packets only. */ -#define _GLIBTOP_IP_FW_ACCTOUT 0x2000 /* Account outgoing packets only. */ - -static const unsigned long _glibtop_sysdeps_netload = -(1L << GLIBTOP_NETLOAD_ERRORS_IN) + -(1L << GLIBTOP_NETLOAD_ERRORS_OUT) + -(1L << GLIBTOP_NETLOAD_COLLISIONS); - -static const unsigned long _glibtop_sysdeps_netload_bytes = -(1L << GLIBTOP_NETLOAD_BYTES_IN) + -(1L << GLIBTOP_NETLOAD_BYTES_OUT) + -(1L << GLIBTOP_NETLOAD_BYTES_TOTAL); - -static const unsigned long _glibtop_sysdeps_netload_packets = -(1L << GLIBTOP_NETLOAD_PACKETS_IN) + -(1L << GLIBTOP_NETLOAD_PACKETS_OUT) + -(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL); - -static const unsigned long _glibtop_sysdeps_netload_total = -(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) + -(1L << GLIBTOP_NETLOAD_BYTES_TOTAL); - -static const unsigned long _glibtop_sysdeps_netload_in = -(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) + -(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) + -(1L << GLIBTOP_NETLOAD_PACKETS_IN) + -(1L << GLIBTOP_NETLOAD_BYTES_IN); - -static const unsigned long _glibtop_sysdeps_netload_out = -(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) + -(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) + -(1L << GLIBTOP_NETLOAD_PACKETS_OUT) + -(1L << GLIBTOP_NETLOAD_BYTES_OUT); - -/* Init function. */ - -int -glibtop_init_netload_s (glibtop *server) -{ - server->sysdeps.netload = _glibtop_sysdeps_netload | - _glibtop_sysdeps_netload_bytes | - _glibtop_sysdeps_netload_packets; - - return 0; -} - -/* Provides network statistics. */ - -int -glibtop_get_netload_s (glibtop *server, glibtop_netload *buf, - const char *interface, unsigned transport, - unsigned protocol) -{ - char buffer [BUFSIZ], *p; - int have_bytes, fields; - FILE *f; - - memset (buf, 0, sizeof (glibtop_netload)); - - /* Linux 2.1.114 - don't know where exactly this was added, but - * recent kernels have byte count in /proc/net/dev so we don't - * need IP accounting. - */ - - if (server->os_version_code < 131442) { - - /* If IP accounting is enabled in the kernel and it is - * enabled for the requested interface, we use it to - * get the data. In this case, we don't use /proc/net/dev - * to get errors and collisions. - */ - - f = fopen ("/proc/net/ip_acct", "r"); - if (f) { - int success = 0; - - /* Skip over the header line. */ - fgets (buffer, BUFSIZ-1, f); - - while (fgets (buffer, BUFSIZ-1, f)) { - unsigned long flags, packets, bytes; - char *p, *dev; - - /* Skip over the network thing. */ - dev = skip_token (buffer) + 1; - p = skip_token (dev); - *p++ = 0; - - if (strcmp (dev, interface)) - continue; - - success = 1; - - p = skip_token (p); - - flags = strtoul (p, &p, 16); - - p = skip_multiple_token (p, 2); - - packets = strtoul (p, &p, 0); - bytes = strtoul (p, &p, 0); - - if (flags & _GLIBTOP_IP_FW_ACCTIN) { - /* Incoming packets only. */ - - buf->packets_total += packets; - buf->packets_in += packets; - - buf->bytes_total += bytes; - buf->bytes_in += bytes; - - buf->flags |= _glibtop_sysdeps_netload_in; - - } else if (flags & _GLIBTOP_IP_FW_ACCTOUT) { - /* Outgoing packets only. */ - - buf->packets_total += packets; - buf->packets_out += packets; - - buf->bytes_total += bytes; - buf->bytes_out += bytes; - - buf->flags |= _glibtop_sysdeps_netload_out; - - } else { - /* Only have total values. */ - - buf->packets_total += packets; - buf->bytes_total += bytes; - - buf->flags |= _glibtop_sysdeps_netload_total; - } - } - - fclose (f); - - if (success) return 0; - } - } - - /* Ok, either IP accounting is not enabled in the kernel or - * it was not enabled for the requested interface. */ - - f = fopen ("/proc/net/dev", "r"); - if (!f) return -1; - - /* Skip over the header line. */ - fgets (buffer, BUFSIZ-1, f); - fgets (buffer, BUFSIZ-1, f); - - /* Starting with 2.1.xx (don't know exactly which version) - * /proc/net/dev contains both byte and package counters. */ - - p = strchr (buffer, '|'); - if (!p) { - fclose (f); - return -1; - } - - /* Do we already have byte counters ? */ - have_bytes = strncmp (++p, "bytes", 5) == 0; - - /* Count remaining 'Receive' fields so we know where - * the first 'Transmit' field starts. */ - - fields = 0; - while (*p != '|') { - if (!isspace (*p++)) continue; - while (isspace (*p++)) ; - fields++; - } - - /* Should never happen. */ - if (fields < 2) { - fclose (f); - return -1; - } - fields--; - - while (fgets (buffer, BUFSIZ-1, f)) { - char *p, *dev; - - dev = buffer; - while (isspace (*dev)) dev++; - - p = strchr (dev, ':'); - if (!p) continue; - *p++ = 0; - - /* If it's not a digit, then it's most likely an error - * message like 'No statistics available'. */ - while (isspace (*p)) p++; - if (!isdigit (*p)) continue; - - if (strcmp (dev, interface)) - continue; - - /* Only read byte counts if we really have them. */ - - if (have_bytes) { - buf->bytes_in = strtoul (p, &p, 0); - fields--; - } - - buf->packets_in = strtoul (p, &p, 0); - buf->errors_in = strtoul (p, &p, 0); - - p = skip_multiple_token (p, fields); - - if (have_bytes) - buf->bytes_out = strtoul (p, &p, 0); - - buf->packets_out = strtoul (p, &p, 0); - buf->errors_out = strtoul (p, &p, 0); - - p = skip_multiple_token (p, 2); - - buf->collisions = strtoul (p, &p, 0); - - /* Compute total valules. */ - - buf->bytes_total = buf->bytes_in + buf->bytes_out; - buf->packets_total = buf->packets_in + buf->packets_out; - - /* And now the flags. */ - - buf->flags |= _glibtop_sysdeps_netload; - buf->flags |= _glibtop_sysdeps_netload_packets; - - if (have_bytes) - buf->flags |= _glibtop_sysdeps_netload_bytes; - } - - fclose (f); - - return 0; -} diff --git a/sysdeps/linux/open.c b/sysdeps/linux/open.c deleted file mode 100644 index 730a70b3..00000000 --- a/sysdeps/linux/open.c +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/cpu.h> -#include <glibtop/open.h> - -/* ===================================================== - * Linux kernel version information for procps utilities - * Copyright (c) 1996 Charles Blake <cblake@bbn.com> - */ -#include <sys/utsname.h> - -#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z) - -static int linux_version_code = 0; - -static void set_linux_version(void) { - static struct utsname uts; - int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */ - - if (linux_version_code) return; - if (uname(&uts) == -1) /* failure most likely implies impending death */ - exit(1); - if (sscanf(uts.release, "%d.%d.%d", &x, &y, &z) < 3) - fprintf(stderr, /* *very* unlikely to happen by accident */ - "Non-standard uts for running kernel:\n" - "release %s=%d.%d.%d gives version code %d\n", - uts.release, x, y, z, LINUX_VERSION(x,y,z)); - linux_version_code = LINUX_VERSION(x, y, z); -} - -/* ======================================================= */ - -/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ - -#define FILENAME "/proc/stat" - -void -glibtop_open_s (glibtop_server *server, const char *program_name, - const unsigned long features, - const unsigned flags) -{ - char buffer [BUFSIZ], *p; - int fd, len, i; - - server->name = program_name; - - set_linux_version (); - server->_priv->os_version_code = (unsigned long) linux_version_code; - - server->ncpu = 0; - - fd = open (FILENAME, O_RDONLY); - if (fd < 0) - glibtop_error_io_r (server, "open (%s)", FILENAME); - - len = read (fd, buffer, BUFSIZ-1); - if (len < 0) - glibtop_error_io_r (server, "read (%s)", FILENAME); - - close (fd); - - buffer [len] = '\0'; - - p = skip_multiple_token (buffer, 5) + 1; - - for (i = 0; i < GLIBTOP_NCPU; i++) { - - if (strncmp (p, "cpu", 3) || !isdigit (p [3])) - break; - - server->ncpu++; - - p = skip_multiple_token (p, 5) + 1; - } - -#if DEBUG - printf ("\nThis machine has %d CPUs.\n\n", server->ncpu); -#endif -} diff --git a/sysdeps/linux/ppp.c b/sysdeps/linux/ppp.c deleted file mode 100644 index 877e8c92..00000000 --- a/sysdeps/linux/ppp.c +++ /dev/null @@ -1,324 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/ppp.h> - -#include <linux/isdn.h> -#include <sys/ioctl.h> -#include <sys/stat.h> -#include <fcntl.h> - -#include <ctype.h> - -#include <glib.h> - -#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 -/* GNU LibC */ -#include <net/if.h> -#include <netinet/ip_icmp.h> -#include <netinet/in.h> -#include <netinet/ip.h> -#include <netinet/tcp.h> -#include <netinet/udp.h> -#include <net/if.h> -#include <net/if_ppp.h> -#else /* Libc 5 */ -#include <linux/if.h> -#include <linux/in.h> -#include <linux/ip.h> -#include <linux/icmp.h> -#include <linux/tcp.h> -#include <linux/udp.h> -#include <linux/isdn.h> -#endif - -static const unsigned long _glibtop_sysdeps_ppp = -(1L << GLIBTOP_PPP_STATE) + (1L << GLIBTOP_PPP_BYTES_IN) + -(1L << GLIBTOP_PPP_BYTES_OUT); - -#ifdef SIOCDEVPRIVATE -static int ip_socket; -#endif - -/* Init function. */ - -int -glibtop_init_ppp_s (glibtop *server) -{ - server->sysdeps.ppp = _glibtop_sysdeps_ppp; - -#ifdef SIOCDEVPRIVATE - /* open ip socket */ - if ((ip_socket = socket (AF_INET, SOCK_DGRAM, 0)) < 0) - return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; /* should never happen */ -#endif - - return 0; -} - -static int -get_ISDN_stats (glibtop *server, int *in, int *out) -{ - unsigned long *isdn_stats, *ptr; - int fd, i; - - *in = *out = 0; - - isdn_stats = glibtop_calloc_r (server, ISDN_MAX_CHANNELS * 2, - sizeof (unsigned long)); - - fd = open ("/dev/isdninfo", O_RDONLY); - if (fd < 0) { - glibtop_free_r (server, isdn_stats); - return FALSE; - } - - if ((ioctl (fd, IIOCGETCPS, isdn_stats) < 0) && (errno != 0)) { - glibtop_free_r (server, isdn_stats); - close (fd); - - return FALSE; - } - - for (i = 0, ptr = isdn_stats; i < ISDN_MAX_CHANNELS; i++) { - *in += *ptr++; *out += *ptr++; - } - - glibtop_free_r (server, isdn_stats); - close (fd); - - return TRUE; -} - -static int -is_ISDN_on (glibtop *server, int device, int *online) -{ - FILE *f = 0; - char buffer [BUFSIZ], *p; - int i; - - /* Perhaps I should try to explain this code a little bit. - * - * ------------------------------------------------------------ - * This is from the manpage of isdninfo(4): - * - * DESCRIPTION - * /dev/isdninfo is a character device with major number 45 - * and minor number 255. It delivers status information from - * the Linux ISDN subsystem to user level. - * - * DATA FORMAT - * When reading from this device, the current status of the - * Linux ISDN subsystem is delivered in 6 lines of text. Each - * line starts with a tag string followed by a colon and - * whitespace. After that the status values are appended sep- - * arated by whitespace. - * - * flags is the tag of line 5. In this line for every driver - * slot, it's B-Channel status is shown. If no driver - * is registered in a slot, a ? is shown. For every - * established B-Channel of the driver, a bit is set - * in the shown value. The driver's first channel is - * mapped to bit 0, the second channel to bit 1 and so - * on. - * ------------------------------------------------------------ - * - * So we open /dev/isdninfo, discard the first four lines of text - * and then check whether we have something that is not `0' or `?' - * in one of the flags fields. - * - * Sounds complicated, but I don't see any other way to check whether - * we are connected. Also, this is the method some other ISDN tools - * for Linux use. - * - * Martin - */ - - f = fopen ("/dev/isdninfo", "r"); - - if (!f) return FALSE; - - for (i = 0; i < 5; i++) { - if (fgets (buffer, BUFSIZ, f) == NULL) { - fclose (f); - return FALSE; - } - } - - if (strncmp (buffer, "flags:", 6)) { - fclose (f); - return FALSE; - } - - p = buffer+6; - - for (i = 0; i <= device; i++) { - char *end = p; - - while (isspace (*p)) - p++; - - for (end = p; *end && !isspace (*end); end++) - ; - - if (*end == 0) - break; - else - *end++ = 0; - - if (i < device) { - p = end; - continue; - } - - fclose (f); - - if (strlen (p) != 1) - return FALSE; - - if (*p == '0') { - *online = FALSE; - return TRUE; - } else if (*p == '1') { - *online = TRUE; - return TRUE; - } - - return FALSE; - } - - fclose (f); - - return FALSE; -} - -static int -is_Modem_on (glibtop *server, int device) -{ - gchar buf[64], lock_file [BUFSIZ]; - pid_t pid = -1; - FILE *f = 0; - - sprintf (lock_file, LIBGTOP_MODEM_LOCKFILE, device); - - f = fopen (lock_file, "r"); - - if(!f) return FALSE; - - if (fgets (buf, sizeof(buf), f) == NULL) { - fclose (f); - return FALSE; - } - - fclose (f); - - pid = (pid_t) strtol (buf, NULL, 10); - if (pid < 1 || (kill (pid, 0) == -1 && errno != EPERM)) return FALSE; - - return TRUE; -} - -static int -get_Modem_stats (int device, int *in, int *out) -{ - struct ifreq ifreq; - struct ppp_stats stats; - char device_name [IFNAMSIZ]; - - sprintf (device_name, "ppp%d", device); - - memset (&ifreq, 0, sizeof(ifreq)); - strncpy (ifreq.ifr_ifrn.ifrn_name, device_name, IFNAMSIZ); - ifreq.ifr_ifru.ifru_data = (caddr_t)&stats; - -#ifdef SIOCDEVPRIVATE - /* open ip socket */ - if ((ip_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - { - g_print("could not open an ip socket\n"); - return 1; - } - - - - if ((ioctl (ip_socket, SIOCDEVPRIVATE, (caddr_t)&ifreq) < 0)) { - *in = *out = 0; /* failure means ppp is not up */ - return FALSE; - } else { - *in = stats.p.ppp_ibytes; - *out = stats.p.ppp_obytes; - return TRUE; - } -#else /* not SIOCDEVPRIVATE */ - *in = *out = 0; - return FALSE; -#endif /* not SIOCDEVPRIVATE */ -} - -/* Provides PPP/ISDN information. */ - -int -glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, - unsigned short use_isdn) -{ - int in, out, online; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PPP, 0); - - memset (buf, 0, sizeof (glibtop_ppp)); - - if (use_isdn) { - /* ISDN */ - if (is_ISDN_on (server, device, &online)) { - buf->state = online ? GLIBTOP_PPP_STATE_ONLINE : - GLIBTOP_PPP_STATE_HANGUP; - buf->flags |= (1L << GLIBTOP_PPP_STATE); - } - - if (get_ISDN_stats (server, &in, &out)) { - buf->bytes_in = in; - buf->bytes_out = out; - buf->flags |= (1L << GLIBTOP_PPP_BYTES_IN) | - (1L << GLIBTOP_PPP_BYTES_OUT); - } - } else { - /* Modem */ - buf->state = is_Modem_on (server, device) ? - GLIBTOP_PPP_STATE_ONLINE : GLIBTOP_PPP_STATE_HANGUP; - buf->flags |= (1L << GLIBTOP_PPP_STATE); - - if (get_Modem_stats (device, &in, &out)) { - buf->bytes_in = in; - buf->bytes_out = out; - buf->flags |= (1L << GLIBTOP_PPP_BYTES_IN) | - (1L << GLIBTOP_PPP_BYTES_OUT); - } - } - - return 0; -} diff --git a/sysdeps/linux/procargs.c b/sysdeps/linux/procargs.c deleted file mode 100644 index 9ff15cab..00000000 --- a/sysdeps/linux/procargs.c +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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 = -(1L << GLIBTOP_ARRAY_NUMBER) + (1L << GLIBTOP_ARRAY_SIZE); - -/* Init function. */ - -int -glibtop_init_proc_args_s (glibtop *server) -{ - server->sysdeps.proc_args = _glibtop_sysdeps_proc_args; - - return 0; -} - -/* Provides detailed information about a process. */ - -char ** -glibtop_get_proc_args_s (glibtop *server, glibtop_array *array, pid_t pid) -{ - char fn [BUFSIZ], buffer [BUFSIZ], *ptr = NULL, *pos, **ptrlist; - size_t count = 0, max_len, total = 0, len; - int cmdline, i; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_ARGS, 0); - - memset (array, 0, sizeof (glibtop_array)); - - max_len = BUFSIZ; - ptr = glibtop_malloc_r (server, max_len + 1); - - sprintf (fn, "/proc/%d/cmdline", pid); - - cmdline = open (fn, O_RDONLY); - if (cmdline < 0) return NULL; - - while (1) { - len = read (cmdline, buffer, BUFSIZ-1); - if (len < 0) { - close (cmdline); - glibtop_free_r (server, ptr); - return NULL; - } - - if (len == 0) - break; - - ptr = glibtop_realloc_r (server, ptr, total+len+1); - memcpy (ptr+total, buffer, len); - *(ptr+total+len) = 0; - total += len; - } - - close (cmdline); - - ptr [total] = '\0'; - - for (i = 0; i <= total; i++) { - if (ptr [i]) continue; - count++; - } - - ptrlist = glibtop_calloc_r (server, count+1, sizeof (char *)); - - for (i = 0, pos = ptr; i < count; i++) { - ptrlist [i] = glibtop_strdup_r (server, pos); - pos += strlen (pos) + 1; - } - - ptrlist [count] = NULL; - - glibtop_free_r (server, ptr); - - array->number = count; - array->size = sizeof (char *); - array->flags = _glibtop_sysdeps_proc_args; - - return ptrlist; -} diff --git a/sysdeps/linux/proccwd.c b/sysdeps/linux/proccwd.c deleted file mode 100644 index 5be9f91e..00000000 --- a/sysdeps/linux/proccwd.c +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/proccwd.h> - -static const unsigned long _glibtop_sysdeps_proc_cwd = -(1L << GLIBTOP_PROC_CWD_SIZE); - -static const unsigned long _glibtop_sysdeps_proc_cwd_stat = -(1L << GLIBTOP_PROC_CWD_DEVICE) + (1L << GLIBTOP_PROC_CWD_INODE); - -/* Init function. */ - -int -glibtop_init_proc_cwd_s (glibtop *server) -{ - server->sysdeps.proc_cwd = _glibtop_sysdeps_proc_cwd | - _glibtop_sysdeps_proc_cwd_stat; - - return 0; -} - -/* Provides detailed information about a process. */ - -char * -glibtop_get_proc_cwd_s (glibtop *server, glibtop_proc_cwd *buf, pid_t pid) -{ - char fn [BUFSIZ], buffer [BUFSIZ], *retval = NULL; - struct stat statb; - int len; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_CWD, 0); - - memset (buf, 0, sizeof (glibtop_proc_cwd)); - - sprintf (fn, "/proc/%d/cwd", pid); - - if (stat (fn, &statb)) { - /* If we can't even stat () than we can't readlink (). */ - if (errno != EACCES) { - /* Don't make too much unnecessary noise here. */ - glibtop_warn_io_r (server, "stat (%s)", fn); - } - return retval; - } - - buf->device = statb.st_dev; - buf->inode = statb.st_ino; - buf->flags = _glibtop_sysdeps_proc_cwd_stat; - - len = readlink (fn, buffer, BUFSIZ-1); - - if (len < 0) { - glibtop_warn_io_r (server, "readlink (%s)", fn); - return NULL; - } - - buffer [len] = '\0'; - - retval = glibtop_strdup_r (server, buffer); - - buf->size = len+1; - buf->flags |= _glibtop_sysdeps_proc_cwd; - - return retval; -} diff --git a/sysdeps/linux/prockernel.c b/sysdeps/linux/prockernel.c deleted file mode 100644 index f0e180ae..00000000 --- a/sysdeps/linux/prockernel.c +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/prockernel.h> - -static const unsigned long _glibtop_sysdeps_proc_kernel = -(1L << GLIBTOP_PROC_KERNEL_K_FLAGS) + (1L << GLIBTOP_PROC_KERNEL_MIN_FLT) + -(1L << GLIBTOP_PROC_KERNEL_MAJ_FLT) + (1L << GLIBTOP_PROC_KERNEL_CMIN_FLT) + -(1L << GLIBTOP_PROC_KERNEL_CMAJ_FLT) + (1L << GLIBTOP_PROC_KERNEL_KSTK_ESP) + -(1L << GLIBTOP_PROC_KERNEL_KSTK_EIP) + (1L << GLIBTOP_PROC_KERNEL_WCHAN); - -/* Init function. */ - -int -glibtop_init_proc_kernel_s (glibtop *server) -{ - server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) -{ - char buffer [BUFSIZ], *p; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0); - - memset (buf, 0, sizeof (glibtop_proc_kernel)); - - if (proc_stat_to_buffer (buffer, pid)) - return -1; - - p = proc_stat_after_cmd (buffer); - if (!p) return -1; - - p = skip_multiple_token (p, 6); - - buf->k_flags = strtoul (p, &p, 0); - buf->min_flt = strtoul (p, &p, 0); - buf->cmin_flt = strtoul (p, &p, 0); - buf->maj_flt = strtoul (p, &p, 0); - buf->cmaj_flt = strtoul (p, &p, 0); - - p = skip_multiple_token (p, 15); - - buf->kstk_esp = strtoul (p, &p, 0); - buf->kstk_eip = strtoul (p, &p, 0); - - p = skip_multiple_token (p, 4); - - buf->nwchan = strtoul (p, &p, 0); - - buf->flags = _glibtop_sysdeps_proc_kernel; - - return 0; -} diff --git a/sysdeps/linux/proclist.c b/sysdeps/linux/proclist.c deleted file mode 100644 index e7d47774..00000000 --- a/sysdeps/linux/proclist.c +++ /dev/null @@ -1,244 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/xmalloc.h> -#include <glibtop/proclist.h> - -#include <glibtop/procuid.h> -#include <glibtop/procstate.h> - -#include <sys/stat.h> -#include <unistd.h> -#include <dirent.h> -#include <ctype.h> - -static const unsigned long _glibtop_sysdeps_proclist = -(1L << GLIBTOP_PROCLIST_TOTAL) + (1L << GLIBTOP_PROCLIST_NUMBER) + -(1L << GLIBTOP_PROCLIST_SIZE); - -/* Init function. */ - -int -glibtop_init_proclist_s (glibtop *server) -{ - server->sysdeps.proclist = _glibtop_sysdeps_proclist; - - return 0; -} - -#define BLOCK_COUNT 256 -#define BLOCK_SIZE (BLOCK_COUNT * sizeof (unsigned)) - -/* Fetch list of currently running processes. - * - * The interface of this function is a little bit different from the others: - * buf->flags is only set if the call succeeded, in this case pids_chain, - * a list of the pids of all currently running processes is returned, - * buf->number is the number of elements of this list and buf->size is - * the size of one single element (sizeof (unsigned)). The total size is - * stored in buf->total. - * - * The calling function has to free the memory to which a pointer is returned. - * - * On error, NULL is returned and buf->flags is zero. */ - -unsigned * -glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf, - int64_t which, int64_t arg) -{ - DIR *proc; - struct dirent *entry; - char buffer [BUFSIZ]; - unsigned count, total, pid; - unsigned pids [BLOCK_COUNT], *pids_chain = NULL; - unsigned pids_size = 0, pids_offset = 0, new_size; - struct stat statb; - int len, i, ok; - - glibtop_proc_uid procuid; - glibtop_proc_state procstate; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROCLIST, 0); - - memset (buf, 0, sizeof (glibtop_proclist)); - - proc = opendir ("/proc"); - if (!proc) return NULL; - - /* read every every entry in /proc */ - - for (count = total = 0, entry = readdir (proc); - entry; entry = readdir (proc)) { - ok = 1; len = strlen (entry->d_name); - - /* does it consist entirely of digits? */ - - for (i = 0; i < len; i++) - if (!isdigit (entry->d_name [i])) ok = 0; - if (!ok) continue; - - /* convert it in a number */ - - if (sscanf (entry->d_name, "%u", &pid) != 1) continue; - - /* is it really a directory? */ - - sprintf (buffer, "/proc/%d", pid); - - if (stat (buffer, &statb)) continue; - - if (!S_ISDIR (statb.st_mode)) continue; - - switch (which & GLIBTOP_KERN_PROC_MASK) { - case GLIBTOP_KERN_PROC_ALL: - break; - case GLIBTOP_KERN_PROC_PID: - if ((unsigned) arg != pid) - continue; - break; - case GLIBTOP_KERN_PROC_UID: - if ((uid_t) arg != statb.st_uid) - continue; - break; - case GLIBTOP_KERN_PROC_PGRP: - /* Do you really, really need this ? */ - glibtop_get_proc_uid_s (server, &procuid, pid); - if (procuid.flags & (1L << GLIBTOP_PROC_UID_PGRP)) - if ((int) arg != procuid.pgrp) - continue; - break; - case GLIBTOP_KERN_PROC_PPID: - /* Do you really, really need this ? */ - glibtop_get_proc_uid_s (server, &procuid, pid); - if (procuid.flags & (1L << GLIBTOP_PROC_UID_PPID)) - if ((int) arg != procuid.ppid) - continue; - break; - case GLIBTOP_KERN_PROC_SESSION: - /* Do you really, really need this ? */ - glibtop_get_proc_uid_s (server, &procuid, pid); - if (procuid.flags & (1L << GLIBTOP_PROC_UID_SESSION)) - if ((int) arg != procuid.session) - continue; - break; - case GLIBTOP_KERN_PROC_TTY: - /* Do you really, really need this ? */ - glibtop_get_proc_uid_s (server, &procuid, pid); - if (procuid.flags & (1L << GLIBTOP_PROC_UID_TTY)) - if ((int) arg != procuid.tty) - continue; - break; - case GLIBTOP_KERN_PROC_RUID: - /* Do you really, really need this ? */ - glibtop_get_proc_uid_s (server, &procuid, pid); - if (procuid.flags & (1L << GLIBTOP_PROC_UID_EUID)) - if ((int) arg != procuid.euid) - continue; - break; - } - - if (which & GLIBTOP_EXCLUDE_NOTTY) { - glibtop_get_proc_uid_s (server, &procuid, pid); - if (procuid.flags & (1L << GLIBTOP_PROC_UID_TTY)) - if (procuid.tty == -1) continue; - } - - if (which & GLIBTOP_EXCLUDE_IDLE) { - glibtop_get_proc_state_s (server, &procstate, pid); - if (procstate.flags & (1L << GLIBTOP_PROC_STATE_STATE)) - if (!(procstate.state & GLIBTOP_PROCESS_RUNNING)) continue; - } - - if (which & GLIBTOP_EXCLUDE_SYSTEM) { - glibtop_get_proc_uid_s (server, &procuid, pid); - if (procuid.flags & (1L << GLIBTOP_PROC_UID_UID)) - if (procuid.uid == 0) continue; - } - - /* Fine. Now we first try to store it in pids. If this buffer is - * full, we copy it to the pids_chain. */ - - if (count >= BLOCK_COUNT) { - /* The following call to glibtop_realloc will be - * equivalent to glibtop_malloc () if `pids_chain' is - * NULL. We just calculate the new size and copy `pids' - * to the beginning of the newly allocated block. */ - - new_size = pids_size + BLOCK_SIZE; - - pids_chain = glibtop_realloc_r - (server, pids_chain, new_size); - - memcpy (pids_chain + pids_offset, pids, BLOCK_SIZE); - - pids_size = new_size; - - pids_offset += BLOCK_COUNT; - - count = 0; - } - - /* pids is now big enough to hold at least one single pid. */ - - pids [count++] = pid; - - total++; - } - - closedir (proc); - - /* count is only zero if an error occured (one a running Linux system, - * we have at least one single process). */ - - if (!count) return NULL; - - /* The following call to glibtop_realloc will be equivalent to - * glibtop_malloc if pids_chain is NULL. We just calculate the - * new size and copy pids to the beginning of the newly allocated - * block. */ - - new_size = pids_size + count * sizeof (unsigned); - - pids_chain = glibtop_realloc_r (server, pids_chain, new_size); - - memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned)); - - pids_size = new_size; - - pids_offset += BLOCK_COUNT; - - /* Since everything is ok now, we can set buf->flags, fill in the - * remaining fields and return the `pids_chain'. */ - - buf->flags = _glibtop_sysdeps_proclist; - - buf->size = sizeof (unsigned); - buf->number = total; - - buf->total = total * sizeof (unsigned); - - return pids_chain; -} diff --git a/sysdeps/linux/procmap.c b/sysdeps/linux/procmap.c deleted file mode 100644 index 23ca2675..00000000 --- a/sysdeps/linux/procmap.c +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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 = -(1L << GLIBTOP_PROC_MAP_NUMBER) + (1L << GLIBTOP_PROC_MAP_TOTAL) + -(1L << GLIBTOP_PROC_MAP_SIZE); - -static const unsigned long _glibtop_sysdeps_map_entry = -(1L << GLIBTOP_MAP_ENTRY_START) + (1L << GLIBTOP_MAP_ENTRY_END) + -(1L << GLIBTOP_MAP_ENTRY_OFFSET) + (1L << GLIBTOP_MAP_ENTRY_PERM) + -(1L << GLIBTOP_MAP_ENTRY_INODE) + (1L << GLIBTOP_MAP_ENTRY_DEVICE) + -(1L << GLIBTOP_MAP_ENTRY_FILENAME); - -/* Init function. */ - -int -glibtop_init_proc_map_s (glibtop *server) -{ - server->sysdeps.proc_map = _glibtop_sysdeps_proc_map; - - return 0; -} - -/* Provides detailed information about a process. */ - -glibtop_map_entry * -glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) -{ - char fn [BUFSIZ]; - glibtop_map_entry *entry_list = NULL; - int rv, n = 0; - FILE *maps; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0); - - memset (buf, 0, sizeof (glibtop_proc_map)); - - sprintf (fn, "/proc/%d/maps", pid); - - maps = fopen (fn, "r"); - if (!maps) return NULL; - - do { - short dev_major, dev_minor; - unsigned long start, end, offset, inode, perm; - char flags [5], *format; - size_t size; - - if (sizeof (void*) == 8) - format = "%16lx-%16lx %4c\n %16lx %02hx:%02hx %ld"; - else - format = "%08lx-%08lx %4c\n %08lx %02hx:%02hx %ld"; - - rv = fscanf (maps, format, - &start, &end, flags, &offset, - &dev_major, &dev_minor, &inode); - - flags [4] = 0; - - /* Compute access permissions. */ - - perm = 0; - - if (flags [0] == 'r') - perm |= GLIBTOP_MAP_PERM_READ; - if (flags [1] == 'w') - perm |= GLIBTOP_MAP_PERM_WRITE; - if (flags [2] == 'x') - perm |= GLIBTOP_MAP_PERM_EXECUTE; - if (flags [3] == 's') - perm |= GLIBTOP_MAP_PERM_SHARED; - if (flags [3] == 'p') - perm |= GLIBTOP_MAP_PERM_PRIVATE; - - /* Read filename. */ - - fn [0] = fgetc (maps); - - if (fn [0] != '\n' && fn [0] != EOF) { - - fscanf (maps, "%*[ ]%[^\n]\n", fn); - - } else fn [0] = 0; - - size = (n+1) * sizeof (glibtop_map_entry); - - entry_list = glibtop_realloc_r (server, entry_list, size); - - memset (&(entry_list [n]), 0, sizeof (glibtop_map_entry)); - - entry_list [n].flags = _glibtop_sysdeps_map_entry; - - entry_list [n].start = (u_int64_t) start; - entry_list [n].end = (u_int64_t) end; - entry_list [n].offset = (u_int64_t) offset; - entry_list [n].perm = (u_int64_t) perm; - entry_list [n].device = (u_int64_t) (dev_major << 8) + - (u_int64_t) dev_minor; - entry_list [n].inode = (u_int64_t) inode; - - strncpy (entry_list [n].filename, fn, GLIBTOP_MAP_FILENAME_LEN); - entry_list [n].filename [GLIBTOP_MAP_FILENAME_LEN] = 0; - - n++; - - } while (rv != EOF && rv && fn [0] != EOF); - - fclose (maps); - - buf->number = n; - buf->size = sizeof (glibtop_map_entry); - buf->total = n * sizeof (glibtop_map_entry); - - return entry_list; -} diff --git a/sysdeps/linux/procmem.c b/sysdeps/linux/procmem.c deleted file mode 100644 index df052bf3..00000000 --- a/sysdeps/linux/procmem.c +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procmem.h> - -static const unsigned long _glibtop_sysdeps_proc_mem = -(1L << GLIBTOP_PROC_MEM_VSIZE) + (1L << GLIBTOP_PROC_MEM_RSS) + -(1L << GLIBTOP_PROC_MEM_RSS_RLIM); - -static const unsigned long _glibtop_sysdeps_proc_mem_statm = -(1L << GLIBTOP_PROC_MEM_SIZE) + (1L << GLIBTOP_PROC_MEM_RESIDENT) + -(1L << GLIBTOP_PROC_MEM_SHARE); - -#ifndef LOG1024 -#define LOG1024 10 -#endif - -/* these are for getting the memory statistics */ -static int pageshift; /* log base 2 of the pagesize */ - -/* define pagetok in terms of pageshift */ -#define pagetok(size) ((size) << pageshift) - -/* Init function. */ - -int -glibtop_init_proc_mem_s (glibtop *server) -{ - register int pagesize; - - server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem | - _glibtop_sysdeps_proc_mem_statm; - - /* get the page size with "getpagesize" and calculate pageshift - * from it */ - pagesize = getpagesize (); - pageshift = 0; - while (pagesize > 1) { - pageshift++; - pagesize >>= 1; - } - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) -{ - char buffer [BUFSIZ], *p; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0); - - memset (buf, 0, sizeof (glibtop_proc_mem)); - - if (proc_stat_to_buffer (buffer, pid)) - return -1; - - p = proc_stat_after_cmd (buffer); - if (!p) return -1; - - p = skip_multiple_token (p, 20); - - buf->vsize = strtoul (p, &p, 0); - buf->rss = strtoul (p, &p, 0); - buf->rss_rlim = strtoul (p, &p, 0); - - buf->flags = _glibtop_sysdeps_proc_mem; - - if (proc_statm_to_buffer (buffer, pid)) - return -1; - - buf->size = strtoul (buffer, &p, 0); - buf->resident = strtoul (p, &p, 0); - buf->share = strtoul (p, &p, 0); - - buf->size <<= pageshift; - buf->resident <<= pageshift; - buf->share <<= pageshift; - buf->rss <<= pageshift; - - buf->flags |= _glibtop_sysdeps_proc_mem_statm; - - return 0; -} diff --git a/sysdeps/linux/procsegment.c b/sysdeps/linux/procsegment.c deleted file mode 100644 index 3d476237..00000000 --- a/sysdeps/linux/procsegment.c +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/error.h> -#include <glibtop/procsegment.h> - -static const unsigned long _glibtop_sysdeps_proc_segment = -(1L << GLIBTOP_PROC_SEGMENT_START_CODE) + -(1L << GLIBTOP_PROC_SEGMENT_END_CODE) + -(1L << GLIBTOP_PROC_SEGMENT_START_STACK); - -static const unsigned long _glibtop_sysdeps_proc_segment_statm = -(1L << GLIBTOP_PROC_SEGMENT_TEXT_RSS) + -/* Disabled due to bug in the Linux Kernel. */ -/* (1L << GLIBTOP_PROC_SEGMENT_SHLIB_RSS) + */ -(1L << GLIBTOP_PROC_SEGMENT_DATA_RSS) + -(1L << GLIBTOP_PROC_SEGMENT_DIRTY_SIZE); - -#ifndef LOG1024 -#define LOG1024 10 -#endif - -/* these are for getting the memory statistics */ -static int pageshift; /* log base 2 of the pagesize */ - -/* define pagetok in terms of pageshift */ -#define pagetok(size) ((size) << pageshift) - -/* Init function. */ - -int -glibtop_init_proc_segment_s (glibtop *server) -{ - register int pagesize; - - server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment | - _glibtop_sysdeps_proc_segment_statm; - - /* get the page size with "getpagesize" and calculate pageshift - * from it */ - pagesize = getpagesize (); - pageshift = 0; - while (pagesize > 1) { - pageshift++; - pagesize >>= 1; - } - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, - pid_t pid) -{ - char buffer [BUFSIZ], *p; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0); - - memset (buf, 0, sizeof (glibtop_proc_segment)); - - if (proc_stat_to_buffer (buffer, pid)) - return -1; - - p = proc_stat_after_cmd (buffer); - if (!p) return -1; - - p = skip_multiple_token (p, 23); - - buf->start_code = strtoul (p, &p, 0); - buf->end_code = strtoul (p, &p, 0); - buf->start_stack = strtoul (p, &p, 0); - - buf->flags = _glibtop_sysdeps_proc_segment; - - if (proc_statm_to_buffer (buffer, pid)) - return 0; - - p = skip_multiple_token (buffer, 3); - - /* This doesn't work very well due to a bug in the Linux kernel. - * I'll submit a patch to the kernel mailing list soon. */ - - buf->text_rss = strtoul (p, &p, 0); - buf->shlib_rss = strtoul (p, &p, 0); - buf->data_rss = strtoul (p, &p, 0); - buf->dirty_size = strtoul (p, &p, 0); - - buf->text_rss <<= pageshift; - buf->shlib_rss <<= pageshift; - buf->data_rss <<= pageshift; - buf->dirty_size <<= pageshift; - - buf->flags |= _glibtop_sysdeps_proc_segment_statm; - - return 0; -} diff --git a/sysdeps/linux/procsignal.c b/sysdeps/linux/procsignal.c deleted file mode 100644 index 97a8970e..00000000 --- a/sysdeps/linux/procsignal.c +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procsignal.h> - -static const unsigned long _glibtop_sysdeps_proc_signal = -(1L << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1L << GLIBTOP_PROC_SIGNAL_BLOCKED) + -(1L << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1L << GLIBTOP_PROC_SIGNAL_SIGCATCH); - -/* Init function. */ - -int -glibtop_init_proc_signal_s (glibtop *server) -{ - server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) -{ - char buffer [BUFSIZ], *p; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0); - - memset (buf, 0, sizeof (glibtop_proc_signal)); - - if (proc_stat_to_buffer (buffer, pid)) - return -1; - - p = proc_stat_after_cmd (buffer); - if (!p) return -1; - - p = skip_multiple_token (p, 28); - - buf->signal [0] = strtoul (p, &p, 0); - buf->blocked [0] = strtoul (p, &p, 0); - buf->sigignore [0] = strtoul (p, &p, 0); - buf->sigcatch [0] = strtoul (p, &p, 0); - - buf->flags = _glibtop_sysdeps_proc_signal; - - return 0; -} diff --git a/sysdeps/linux/procstate.c b/sysdeps/linux/procstate.c deleted file mode 100644 index 51354352..00000000 --- a/sysdeps/linux/procstate.c +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procstate.h> - -#include <sys/stat.h> - -static const unsigned long _glibtop_sysdeps_proc_state = -(1L << GLIBTOP_PROC_STATE_CMD); - -static const unsigned long _glibtop_sysdeps_proc_state_uid = -(1L << GLIBTOP_PROC_STATE_UID) + (1L << GLIBTOP_PROC_STATE_GID); - -/* Init function. */ - -int -glibtop_init_proc_state_s (glibtop *server) -{ - server->sysdeps.proc_state = _glibtop_sysdeps_proc_state | - _glibtop_sysdeps_proc_state_uid; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) -{ - char buffer [BUFSIZ], state, *p; - struct stat statb; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_STATE, 0); - - memset (buf, 0, sizeof (glibtop_proc_state)); - - /* IMPORTANT NOTICE: For security reasons it is extremely important - * that the 'uid' and 'gid' fields have correct - * values; NEVER set their flags values if this - * is not the case !!! */ - - sprintf (buffer, "/proc/%d", pid); - - if (stat (buffer, &statb)) - return -1; - - /* For security reasons we use stat () since it is - * more failsafe than parsing the file. */ - - buf->uid = statb.st_uid; - buf->gid = statb.st_gid; - - buf->flags = _glibtop_sysdeps_proc_state_uid; - - sprintf (buffer, "/proc/%d", pid); - - /* Now we read the remaining fields. */ - - if (proc_stat_to_buffer (buffer, pid)) - return -1; - - p = strrchr (buffer, ')'); *p = '\0'; - state = p [2]; - - p = skip_token (buffer); p++; /* pid */ - if (*p++ != '(') - glibtop_error_r (server, "Bad data in /proc/%d/stat", pid); - - strncpy (buf->cmd, p, sizeof (buf->cmd)-1); - buf->cmd [sizeof (buf->cmd)-1] = 0; - - buf->flags |= _glibtop_sysdeps_proc_state; - - switch (state) { - case 'R': - buf->state = GLIBTOP_PROCESS_RUNNING; - break; - case 'S': - buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE; - break; - case 'D': - buf->state = GLIBTOP_PROCESS_UNINTERRUPTIBLE; - break; - case 'Z': - buf->state = GLIBTOP_PROCESS_ZOMBIE; - break; - case 'T': - buf->state = GLIBTOP_PROCESS_STOPPED; - break; - case 'W': - buf->state = GLIBTOP_PROCESS_SWAPPING; - break; - default: - return -1; - } - - buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE); - - return 0; -} diff --git a/sysdeps/linux/proctime.c b/sysdeps/linux/proctime.c deleted file mode 100644 index 9cd50fbd..00000000 --- a/sysdeps/linux/proctime.c +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/proctime.h> - -static const unsigned long _glibtop_sysdeps_proc_time = -(1L << GLIBTOP_PROC_TIME_UTIME) + (1L << GLIBTOP_PROC_TIME_CUTIME) + -(1L << GLIBTOP_PROC_TIME_STIME) + (1L << GLIBTOP_PROC_TIME_CSTIME) + -(1L << GLIBTOP_PROC_TIME_FREQUENCY) + (1L << GLIBTOP_PROC_TIME_TIMEOUT) + -(1L << GLIBTOP_PROC_TIME_IT_REAL_VALUE) + (1L << GLIBTOP_PROC_TIME_START_TIME); - -static const unsigned long _glibtop_sysdeps_proc_time_smp = -(1L << GLIBTOP_PROC_TIME_XCPU_UTIME) + (1L << GLIBTOP_PROC_TIME_XCPU_STIME); - -/* Init function. */ - -int -glibtop_init_proc_time_s (glibtop *server) -{ - server->sysdeps.proc_time = _glibtop_sysdeps_proc_time; - - if (server->ncpu) - server->sysdeps.proc_time |= _glibtop_sysdeps_proc_time_smp; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) -{ - char buffer [BUFSIZ], *p; - int i; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_TIME, 0); - - memset (buf, 0, sizeof (glibtop_proc_time)); - - if (proc_stat_to_buffer (buffer, pid)) - return -1; - - p = proc_stat_after_cmd (buffer); - if (!p) return -1; - - p = skip_multiple_token (p, 11); - - buf->utime = strtoul (p, &p, 0); - buf->stime = strtoul (p, &p, 0); - buf->cutime = strtoul (p, &p, 0); - buf->cstime = strtoul (p, &p, 0); - - p = skip_multiple_token (p, 2); - - buf->timeout = strtoul (p, &p, 0); - buf->it_real_value = strtoul (p, &p, 0); - buf->start_time = strtoul (p, &p, 0); - - buf->frequency = 100; - - buf->flags = _glibtop_sysdeps_proc_time; - - if (!server->ncpu) - return 0; - - if (proc_file_to_buffer (buffer, "/proc/%d/cpu", pid)) - return -1; - - p = skip_token (buffer); - buf->utime = strtoul (p, &p, 0); - buf->stime = strtoul (p, &p, 0); - - for (i = 0; i < GLIBTOP_NCPU; i++) { - if (strncmp (p+1, "cpu", 3) || !isdigit (p [4])) - break; - - p += 6; - buf->xcpu_utime [i] = strtoul (p, &p, 0); - buf->xcpu_stime [i] = strtoul (p, &p, 0); - } - - buf->flags |= _glibtop_sysdeps_proc_time_smp; - - return 0; -} diff --git a/sysdeps/linux/procuid.c b/sysdeps/linux/procuid.c deleted file mode 100644 index 628655f7..00000000 --- a/sysdeps/linux/procuid.c +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procuid.h> - -static const unsigned long _glibtop_sysdeps_proc_uid = -(1L << GLIBTOP_PROC_UID_UID) + (1L << GLIBTOP_PROC_UID_EUID) + -(1L << GLIBTOP_PROC_UID_GID) + (1L << GLIBTOP_PROC_UID_EGID); - -static const unsigned long _glibtop_sysdeps_proc_uid_stat = -(1L << GLIBTOP_PROC_UID_PID) + (1L << GLIBTOP_PROC_UID_PPID) + -(1L << GLIBTOP_PROC_UID_PGRP) + (1L << GLIBTOP_PROC_UID_SESSION) + -(1L << GLIBTOP_PROC_UID_TTY) + (1L << GLIBTOP_PROC_UID_TPGID) + -(1L << GLIBTOP_PROC_UID_PRIORITY) + (1L << GLIBTOP_PROC_UID_NICE); - -#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z) - -/* Init function. */ - -int -glibtop_init_proc_uid_s (glibtop *server) -{ - server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid | - _glibtop_sysdeps_proc_uid_stat; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) -{ - char buffer [BUFSIZ], *p; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_UID, 0); - - memset (buf, 0, sizeof (glibtop_proc_uid)); - - if (proc_status_to_buffer (buffer, pid)) - return -1; - - /* Search substring 'Pid:' */ - - p = strstr (buffer, "\nPid:"); - if (!p) return -1; - - p = skip_token (p); /* "Pid:" */ - buf->pid = strtoul (p, &p, 0); - - p = skip_token (p); /* "PPid:" */ - buf->ppid = strtoul (p, &p, 0); - - /* Maybe future Linux versions place something between - * "PPid" and "Uid", so we catch this here. */ - p = strstr (p, "\nUid:"); - if (!p) return -1; - - p = skip_token (p); /* "Uid:" */ - buf->uid = strtoul (p, &p, 0); - buf->euid = strtoul (p, &p, 0); - - /* We don't know how many entries on the "Uid:" line - * future Linux version will have, so we catch this here. */ - p = strstr (p, "\nGid:"); - if (!p) return -1; - - p = skip_token (p); /* "Gid:" */ - buf->gid = strtoul (p, &p, 0); - buf->egid = strtoul (p, &p, 0); - - buf->flags = _glibtop_sysdeps_proc_uid; - - if (proc_stat_to_buffer (buffer, pid)) - return -1; - - p = proc_stat_after_cmd (buffer); - if (!p) return -1; - - p = skip_multiple_token (p, 2); - - buf->pgrp = strtoul (p, &p, 0); - buf->session = strtoul (p, &p, 0); - buf->tty = strtoul (p, &p, 0); - buf->tpgid = strtoul (p, &p, 0); - - p = skip_multiple_token (p, 9); - - buf->priority = strtoul (p, &p, 0); - buf->nice = strtoul (p, &p, 0); - - if (buf->tty == 0) - /* the old notty val, update elsewhere bef. moving to 0 */ - buf->tty = -1; - - if (server->_param.os_version_code < LINUX_VERSION(1,3,39)) { - /* map old meanings to new */ - buf->priority = 2*15 - buf->priority; - buf->nice = 15 - buf->nice; - } - if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1) - /* when tty wasn't full devno */ - buf->tty = 4*0x100 + buf->tty; - - buf->flags |= _glibtop_sysdeps_proc_uid_stat; - - return 0; -} diff --git a/sysdeps/linux/sem_limits.c b/sysdeps/linux/sem_limits.c deleted file mode 100644 index 33ae6b29..00000000 --- a/sysdeps/linux/sem_limits.c +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop/sem_limits.h> - -#include <sys/ipc.h> -#include <sys/sem.h> - -#ifdef _SEM_SEMUN_UNDEFINED - -/* glibc 2.1 will no longer defines semun, instead it defines - * _SEM_SEMUN_UNDEFINED so users can define semun on their own. - * Thanks to Albert K T Hui <avatar@deva.net>. */ - -union semun -{ - int val; - struct semid_ds *buf; - unsigned short int *array; - struct seminfo *__buf; -}; -#endif - -static unsigned long _glibtop_sysdeps_sem_limits = -(1L << GLIBTOP_SEM_LIMITS_SEMMAP) + (1L << GLIBTOP_SEM_LIMITS_SEMMNI) + -(1L << GLIBTOP_SEM_LIMITS_SEMMNS) + (1L << GLIBTOP_SEM_LIMITS_SEMMNU) + -(1L << GLIBTOP_SEM_LIMITS_SEMMSL) + (1L << GLIBTOP_SEM_LIMITS_SEMOPM) + -(1L << GLIBTOP_SEM_LIMITS_SEMUME) + (1L << GLIBTOP_SEM_LIMITS_SEMUSZ) + -(1L << GLIBTOP_SEM_LIMITS_SEMVMX) + (1L << GLIBTOP_SEM_LIMITS_SEMAEM); - -/* Init function. */ - -int -glibtop_init_sem_limits_s (glibtop *server) -{ - server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf) -{ - struct seminfo seminfo; - union semun arg; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0); - - memset (buf, 0, sizeof (glibtop_sem_limits)); - - buf->flags = _glibtop_sysdeps_sem_limits; - - arg.array = (ushort *) &seminfo; - semctl (0, 0, IPC_INFO, arg); - - buf->semmap = seminfo.semmap; - buf->semmni = seminfo.semmni; - buf->semmns = seminfo.semmns; - buf->semmnu = seminfo.semmnu; - buf->semmsl = seminfo.semmsl; - buf->semopm = seminfo.semopm; - buf->semume = seminfo.semume; - buf->semusz = seminfo.semusz; - buf->semvmx = seminfo.semvmx; - buf->semaem = seminfo.semaem; - - return 0; -} diff --git a/sysdeps/linux/shm_limits.c b/sysdeps/linux/shm_limits.c deleted file mode 100644 index e4e218b4..00000000 --- a/sysdeps/linux/shm_limits.c +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop/shm_limits.h> - -#include <sys/ipc.h> -#include <sys/shm.h> - -static unsigned long _glibtop_sysdeps_shm_limits = -(1L << GLIBTOP_SHM_LIMITS_SHMMAX) + (1L << GLIBTOP_SHM_LIMITS_SHMMIN) + -(1L << GLIBTOP_SHM_LIMITS_SHMMNI) + (1L << GLIBTOP_SHM_LIMITS_SHMSEG) + -(1L << GLIBTOP_SHM_LIMITS_SHMALL); - -/* Init function. */ - -int -glibtop_init_shm_limits_s (glibtop *server) -{ - server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf) -{ - struct shminfo shminfo; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0); - - memset (buf, 0, sizeof (glibtop_shm_limits)); - - buf->flags = _glibtop_sysdeps_shm_limits; - - shmctl (0, IPC_INFO, (struct shmid_ds *) &shminfo); - - buf->shmmax = shminfo.shmmax; - buf->shmmin = shminfo.shmmin; - buf->shmmni = shminfo.shmmni; - buf->shmseg = shminfo.shmseg; - buf->shmall = shminfo.shmall; - - return 0; -} diff --git a/sysdeps/linux/swap.c b/sysdeps/linux/swap.c deleted file mode 100644 index 911d2a48..00000000 --- a/sysdeps/linux/swap.c +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/error.h> -#include <glibtop/swap.h> - -#include <fcntl.h> - -static unsigned long _glibtop_sysdeps_swap = -(1L << GLIBTOP_SWAP_TOTAL) + (1L << GLIBTOP_SWAP_USED) + -(1L << GLIBTOP_SWAP_FREE); - -static unsigned long _glibtop_sysdeps_swap_paging = -(1L << GLIBTOP_SWAP_PAGEIN) + (1L << GLIBTOP_SWAP_PAGEOUT); - -/* Init function. */ - -int -glibtop_init_swap_s (glibtop *server) -{ - server->sysdeps.swap = _glibtop_sysdeps_swap | - _glibtop_sysdeps_swap_paging; - - return 0; -} - -/* Provides information about swap usage. */ - -#define MEMINFO "/proc/meminfo" -#define PROC_STAT "/proc/stat" - -int -glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) -{ - char buffer [BUFSIZ], *p; - int fd, len; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_SWAP, 0); - - memset (buf, 0, sizeof (glibtop_swap)); - - fd = open (MEMINFO, O_RDONLY); - if (fd < 0) { - glibtop_warn_io_r (server, "open (%s)", MEMINFO); - return -1; - } - - len = read (fd, buffer, BUFSIZ-1); - if (len < 0) { - close (fd); - glibtop_warn_io_r (server, "read (%s)", MEMINFO); - return -1; - } - - close (fd); - - buffer [len] = '\0'; - - p = skip_line (buffer); - p = skip_line (p); - p = skip_token (p); /* "Swap:" */ - - buf->total = strtoul (p, &p, 0); - buf->used = strtoul (p, &p, 0); - buf->free = strtoul (p, &p, 0); - - buf->flags = _glibtop_sysdeps_swap; - - fd = open (PROC_STAT, O_RDONLY); - if (fd < 0) { - glibtop_warn_io_r (server, "open (%s)", PROC_STAT); - return -1; - } - - len = read (fd, buffer, BUFSIZ-1); - if (len < 0) { - close (fd); - glibtop_warn_io_r (server, "read (%s)", PROC_STAT); - return -1; - } - - close (fd); - - buffer [len] = '\0'; - - p = strstr (buffer, "\nswap"); - if (p == NULL) return 0; - - p = skip_token (p); - - buf->pagein = strtoul (p, &p, 0); - buf->pageout = strtoul (p, &p, 0); - - buf->flags |= _glibtop_sysdeps_swap_paging; - - return 0; -} diff --git a/sysdeps/linux/sysinfo.c b/sysdeps/linux/sysinfo.c deleted file mode 100644 index c24d3984..00000000 --- a/sysdeps/linux/sysinfo.c +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/cpu.h> -#include <glibtop/sysinfo.h> - -static const unsigned long _glibtop_sysdeps_sysinfo = -(1L << GLIBTOP_SYSINFO_CPUINFO); - -static glibtop_sysinfo sysinfo; - -static void -init_sysinfo (glibtop *server) -{ - char buffer [BUFSIZ]; - static int init = 0; - glibtop_entry *cpuinfo = NULL; - FILE *f; - - if (init) return; - - init = TRUE; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0); - - memset (&sysinfo, 0, sizeof (glibtop_sysinfo)); - - g_return_if_fail (f = fopen ("/proc/cpuinfo", "r")); - - while (fgets (buffer, BUFSIZ, f)) { - char *p, *start, *key, *value; - - if (cpuinfo == NULL) { - cpuinfo = &sysinfo.cpuinfo [sysinfo.ncpu++]; - - cpuinfo->labels = g_ptr_array_new (); - - cpuinfo->values = g_hash_table_new (NULL, NULL); - - if (sysinfo.ncpu > GLIBTOP_NCPU) - sysinfo.ncpu = GLIBTOP_NCPU; - } - - p = strchr (buffer, ':'); - if (!p) continue; - - /* Remove leading spaces from `p'. */ - *p = '\0'; start = p; p++; - while (isspace (*p)) p++; - - /* Remove trailing spaces from `buffer'. */ - while ((start > buffer) && (*start) && isspace (*start)) - *start-- = '\0'; - - key = g_strdup (buffer); - value = g_strdup (p); - - g_ptr_array_add (cpuinfo->labels, key); - - g_hash_table_insert (cpuinfo->values, key, value); - } - - fclose (f); - - sysinfo.flags = _glibtop_sysdeps_sysinfo; -} - -glibtop_sysinfo * -glibtop_get_sysinfo_s (glibtop *server) -{ - init_sysinfo (server); - return &sysinfo; -} diff --git a/sysdeps/linux/uptime.c b/sysdeps/linux/uptime.c deleted file mode 100644 index 6746fb89..00000000 --- a/sysdeps/linux/uptime.c +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/error.h> -#include <glibtop/uptime.h> - -static unsigned long _glibtop_sysdeps_uptime = -(1L << GLIBTOP_UPTIME_UPTIME) + (1L << GLIBTOP_UPTIME_IDLETIME); - -/* Init function. */ - -int -glibtop_init_uptime_s (glibtop *server) -{ - server->sysdeps.uptime = _glibtop_sysdeps_uptime; - - return 0; -} - -/* Provides uptime and idle time. */ - -#define FILENAME "/proc/uptime" - -int -glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) -{ - char buffer [BUFSIZ], *p; - int fd, len; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_UPTIME, 0); - - memset (buf, 0, sizeof (glibtop_uptime)); - - fd = open (FILENAME, O_RDONLY); - if (fd < 0) { - glibtop_warn_io_r (server, "open (%s)", FILENAME); - return -1; - } - - len = read (fd, buffer, BUFSIZ-1); - if (len < 0) { - close (fd); - glibtop_warn_io_r (server, "read (%s)", FILENAME); - return -1; - } - - close (fd); - - buffer [len] = '\0'; - - buf->uptime = strtod (buffer, &p); - buf->idletime = strtod (p, &p); - - buf->flags = _glibtop_sysdeps_uptime; - - return 0; -} diff --git a/sysdeps/osf1/.cvsignore b/sysdeps/osf1/.cvsignore deleted file mode 100644 index ee69efbb..00000000 --- a/sysdeps/osf1/.cvsignore +++ /dev/null @@ -1,21 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -close.lo -cpu.lo -libgtop_sysdeps.la -libsysdeps.la -loadavg.lo -mem.lo -msg_limits.lo -open.lo -proclist.lo -sem_limits.lo -shm_limits.lo -swap.lo -sysdeps.lo -uptime.lo -so_locations -*.lo -*.la diff --git a/sysdeps/osf1/AUTHORS b/sysdeps/osf1/AUTHORS deleted file mode 100644 index 702002a3..00000000 --- a/sysdeps/osf1/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Martin Baulig (martin@home-of-linux.org) diff --git a/sysdeps/osf1/ChangeLog b/sysdeps/osf1/ChangeLog deleted file mode 100644 index d4206564..00000000 --- a/sysdeps/osf1/ChangeLog +++ /dev/null @@ -1,23 +0,0 @@ -2000-02-24 Martin Baulig <martin@home-of-linux.org> - - Applied a patch from Aron Griffis <agriffis@bigfoot.com>. - - * glibtop_machine.h: Don't declare table () here. - * netinfo.c: Reflect latest interface changes. - -1999-05-11 Martin Baulig <martin@home-of-linux.org> - - * procstate.c: Fixed implementation of the `state' field; added - `ruid' and `rgid' fields. - -1999-02-19 Martin Baulig <martin@home-of-linux.org> - - * procmap.c, procargs.c, netload.c: Copied from stub_suid. - - * proclist.c, procsegment.c: Make them compile again. - -1998-10-25 Martin Baulig <martin@home-of-linux.org> - - * ChangeLog: New file. - * ppp.c: New file. - diff --git a/sysdeps/osf1/Makefile.am b/sysdeps/osf1/Makefile.am deleted file mode 100644 index dee12078..00000000 --- a/sysdeps/osf1/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ - -INCLUDES = @INCLUDES@ - -lib_LTLIBRARIES = libgtop_sysdeps.la libgtop_sysdeps_suid.la - -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 ppp.c -libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) -libgtop_sysdeps_la_LIBADD = -lmach - -libgtop_sysdeps_suid_la_SOURCES = open_suid.c close_suid.c proclist.c \ - procstate.c procuid.c proctime.c procmem.c \ - procsignal.c prockernel.c procsegment.c \ - procmap.c procargs.c netload.c netinfo.c \ - interfaces.c -libgtop_sysdeps_suid_la_LDFLAGS = $(LT_VERSION_INFO) -libgtop_sysdeps_suid_la_LIBADD = -lmach - -include_HEADERS = glibtop_server.h glibtop_machine.h - -noinst_HEADERS = glibtop_suid.h diff --git a/sysdeps/osf1/close.c b/sysdeps/osf1/close.c deleted file mode 100644 index 3378b817..00000000 --- a/sysdeps/osf1/close.c +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop/close.h> - -/* Closes pipe to gtop server. */ - -void -glibtop_close_s (glibtop *server) -{ } diff --git a/sysdeps/osf1/close_suid.c b/sysdeps/osf1/close_suid.c deleted file mode 100644 index 95bffec1..00000000 --- a/sysdeps/osf1/close_suid.c +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop/close.h> - -/* Closes pipe to gtop server. */ - -void -glibtop_close_p (glibtop *server) -{ } diff --git a/sysdeps/osf1/cpu.c b/sysdeps/osf1/cpu.c deleted file mode 100644 index fdebff3c..00000000 --- a/sysdeps/osf1/cpu.c +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/cpu.h> - -static const unsigned long _glibtop_sysdeps_cpu = -(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) + -(1L << GLIBTOP_CPU_NICE) + (1L << GLIBTOP_CPU_SYS) + -(1L << GLIBTOP_CPU_IDLE) + (1L << GLIBTOP_CPU_FREQUENCY); - -/* Init function. */ - -int -glibtop_init_cpu_s (glibtop *server) -{ - server->sysdeps.cpu = _glibtop_sysdeps_cpu; - - return 0; -} - -/* Provides information about cpu usage. */ - -int -glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) -{ - struct tbl_sysinfo sysinfo; - int ret; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0); - - memset (buf, 0, sizeof (glibtop_cpu)); - - ret = table (TBL_SYSINFO, 0, (char *) &sysinfo, 1, - sizeof (struct tbl_sysinfo)); - - if (ret != 1) return -1; - - buf->flags = _glibtop_sysdeps_cpu; - - buf->user = sysinfo.si_user; - buf->nice = sysinfo.si_nice; - buf->sys = sysinfo.si_sys; - buf->idle = sysinfo.si_idle; - - buf->total = sysinfo.si_user + sysinfo.si_nice + - sysinfo.si_sys + sysinfo.si_idle; - - buf->frequency = sysinfo.si_hz; - - return 0; -} diff --git a/sysdeps/osf1/glibtop_machine.h b/sysdeps/osf1/glibtop_machine.h deleted file mode 100644 index f8d26de9..00000000 --- a/sysdeps/osf1/glibtop_machine.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_MACHINE_H__ -#define __GLIBTOP_MACHINE_H__ - -#include <sys/table.h> - -/* The following are defined in <sys/table.h>. */ - -#undef sys -#undef user -#undef idle - -BEGIN_LIBGTOP_DECLS - -typedef struct _glibtop_machine glibtop_machine; - -struct _glibtop_machine -{ - uid_t uid, euid; /* Real and effective user id */ - gid_t gid, egid; /* Real and effective group id */ - unsigned proctable_entries; /* Max entries in the proctable */ -}; - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/osf1/glibtop_server.h b/sysdeps/osf1/glibtop_server.h deleted file mode 100644 index 8a5756f7..00000000 --- a/sysdeps/osf1/glibtop_server.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_SERVER_H__ -#define __GLIBTOP_SERVER_H__ - -BEGIN_LIBGTOP_DECLS - -#define GLIBTOP_SUID_CPU 0 -#define GLIBTOP_SUID_MEM 0 -#define GLIBTOP_SUID_SWAP 0 -#define GLIBTOP_SUID_UPTIME 0 -#define GLIBTOP_SUID_LOADAVG 0 -#define GLIBTOP_SUID_SHM_LIMITS 0 -#define GLIBTOP_SUID_MSG_LIMITS 0 -#define GLIBTOP_SUID_SEM_LIMITS 0 -#define GLIBTOP_SUID_PROCLIST (1 << GLIBTOP_SYSDEPS_PROCLIST) -#define GLIBTOP_SUID_PROC_STATE (1 << GLIBTOP_SYSDEPS_PROC_STATE) -#define GLIBTOP_SUID_PROC_UID (1 << GLIBTOP_SYSDEPS_PROC_UID) -#define GLIBTOP_SUID_PROC_MEM (1 << GLIBTOP_SYSDEPS_PROC_MEM) -#define GLIBTOP_SUID_PROC_TIME (1 << GLIBTOP_SYSDEPS_PROC_TIME) -#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_MAP (1 << GLIBTOP_SYSDEPS_PROC_MAP) -#define GLIBTOP_SUID_PROC_ARGS (1 << GLIBTOP_SYSDEPS_PROC_ARGS) -#define GLIBTOP_SUID_NETLOAD (1 << GLIBTOP_SYSDEPS_NETLOAD) -#define GLIBTOP_SUID_NETINFO (1 << GLIBTOP_SYSDEPS_NETINFO) -#define GLIBTOP_SUID_INTERFACE_NAMES (1 << GLIBTOP_SYSDEPS_INTERFACE_NAMES) -#define GLIBTOP_SUID_PPP 0 - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/osf1/glibtop_suid.h b/sysdeps/osf1/glibtop_suid.h deleted file mode 100644 index 451e959f..00000000 --- a/sysdeps/osf1/glibtop_suid.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_SUID_H__ -#define __GLIBTOP_SUID_H__ - -#include <sys/table.h> - -BEGIN_LIBGTOP_DECLS - -static inline void glibtop_suid_enter (glibtop *server) { - setreuid (server->_priv->machine.uid, server->_priv->machine.euid); -} - -static inline void glibtop_suid_leave (glibtop *server) { - if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid)) - _exit (1); -} - -void -glibtop_init_p (glibtop *server, const unsigned long features, - const unsigned flags); -void -glibtop_open_p (glibtop *server, const char *program_name, - const unsigned long features, - const unsigned flags); - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/osf1/interfaces.c b/sysdeps/osf1/interfaces.c deleted file mode 100644 index b9dd54a0..00000000 --- a/sysdeps/osf1/interfaces.c +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/interfaces.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_interface_names = -(1L << GLIBTOP_INTERFACE_NAMES_NUMBER) + -(1L << GLIBTOP_INTERFACE_NAMES_SIZE); - -/* Init function. */ - -int -glibtop_init_interface_names_p (glibtop *server) -{ - server->sysdeps.interface_names = _glibtop_sysdeps_interface_names; - - return 0; -} - -/* Provides network statistics. */ - -glibtop_interface * -glibtop_get_interface_names_p (glibtop *server, glibtop_array *array, - u_int64_t interface, u_int64_t number, - u_int64_t instance, u_int64_t strategy) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_INTERFACE_NAMES, 0); - - memset (array, 0, sizeof (glibtop_array)); - - return NULL; -} diff --git a/sysdeps/osf1/loadavg.c b/sysdeps/osf1/loadavg.c deleted file mode 100644 index 60f90cdd..00000000 --- a/sysdeps/osf1/loadavg.c +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/error.h> -#include <glibtop/loadavg.h> - -static const unsigned long _glibtop_sysdeps_loadavg = -(1L << GLIBTOP_LOADAVG_LOADAVG); - -/* Init function. */ - -int -glibtop_init_loadavg_s (glibtop *server) -{ - server->sysdeps.loadavg = _glibtop_sysdeps_loadavg; - - return 0; -} - -/* Provides load averange. */ - -int -glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) -{ - struct tbl_loadavg loadavg; - int ret; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_LOADAVG, 0); - - memset (buf, 0, sizeof (glibtop_loadavg)); - - ret = table (TBL_LOADAVG, 0, (char *) &loadavg, 1, - sizeof (struct tbl_loadavg)); - - if (ret != 1) return -1; - - buf->flags = _glibtop_sysdeps_loadavg; - - if (loadavg.tl_lscale == 0) { - buf->loadavg [0] = loadavg.tl_avenrun.d [0]; - buf->loadavg [1] = loadavg.tl_avenrun.d [1]; - buf->loadavg [2] = loadavg.tl_avenrun.d [2]; - } else { - buf->loadavg [0] = - (double) loadavg.tl_avenrun.l [0] / - (double) loadavg.tl_mach_factor [0]; - buf->loadavg [1] = - (double) loadavg.tl_avenrun.l [1] - / (double) loadavg.tl_mach_factor [1]; - buf->loadavg [2] = - (double) loadavg.tl_avenrun.l [2] / - (double) loadavg.tl_mach_factor [2]; - } - - return 0; -} diff --git a/sysdeps/osf1/mem.c b/sysdeps/osf1/mem.c deleted file mode 100644 index 4f0aef36..00000000 --- a/sysdeps/osf1/mem.c +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/mem.h> - -#include <sys/vm.h> - -#include <mach.h> -#include <mach/mach_types.h> -#include <mach/vm_statistics.h> - -static const unsigned long _glibtop_sysdeps_mem = -(1L << GLIBTOP_MEM_TOTAL) + (1L << GLIBTOP_MEM_USED) + -(1L << GLIBTOP_MEM_FREE); - -/* Init function. */ - -int -glibtop_init_mem_s (glibtop *server) -{ - server->sysdeps.mem = _glibtop_sysdeps_mem; - - return 0; -} - -/* Provides information about memory usage. */ - -int -glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) -{ - vm_statistics_data_t vmstats; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0); - - memset (buf, 0, sizeof (glibtop_mem)); - - buf->flags = _glibtop_sysdeps_mem; - - (void) vm_statistics(task_self(), &vmstats); - - buf->free = vmstats.free_count * vmstats.pagesize; - buf->used = vmstats.active_count * vmstats.pagesize; - - /* [FIXME]: Is this correct? */ - - buf->total = (vmstats.active_count + vmstats.inactive_count + - vmstats.free_count + vmstats.wire_count) * - vmstats.pagesize; - - return 0; -} diff --git a/sysdeps/osf1/msg_limits.c b/sysdeps/osf1/msg_limits.c deleted file mode 100644 index 62083e82..00000000 --- a/sysdeps/osf1/msg_limits.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/msg_limits.h> - -static const unsigned long _glibtop_sysdeps_msg_limits = -(1L << GLIBTOP_MSG_LIMITS_MSGMAP) + (1L << GLIBTOP_MSG_LIMITS_MSGMAX) + -(1L << GLIBTOP_MSG_LIMITS_MSGMNB) + (1L << GLIBTOP_MSG_LIMITS_MSGMNI) + -(1L << GLIBTOP_MSG_LIMITS_MSGTQL); - -/* Init function. */ - -int -glibtop_init_msg_limits_s (glibtop *server) -{ - server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf) -{ - int ret, value; - - glibtop_init_s (&server, 0, 0); - - memset (buf, 0, sizeof (glibtop_msg_limits)); - - ret = table (TBL_MSGINFO, MSGINFO_MAX, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_MSG_LIMITS_MSGMAX); - - buf->msgmax = value; - - ret = table (TBL_MSGINFO, MSGINFO_MNB, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_MSG_LIMITS_MSGMNB); - - buf->msgmnb = value; - - ret = table (TBL_MSGINFO, MSGINFO_MNI, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_MSG_LIMITS_MSGMNI); - - buf->msgmni = value; - - ret = table (TBL_MSGINFO, MSGINFO_TQL, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_MSG_LIMITS_MSGTQL); - - buf->msgtql = value; - - return 0; -} diff --git a/sysdeps/osf1/netinfo.c b/sysdeps/osf1/netinfo.c deleted file mode 100644 index 6747a4bb..00000000 --- a/sysdeps/osf1/netinfo.c +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/netinfo.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_netinfo = 0; - -/* Init function. */ - -int -glibtop_init_netinfo_p (glibtop *server) -{ - server->sysdeps.netinfo = _glibtop_sysdeps_netinfo; - - return 0; -} - -/* Provides Network statistics. */ - -glibtop_ifaddr * -glibtop_get_netinfo_p (glibtop *server, - glibtop_array *array, - glibtop_netinfo *buf, - const char *interface, - u_int64_t transport) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_NETINFO, 0); - - memset (buf, 0, sizeof (glibtop_netinfo)); - - return 0; -} diff --git a/sysdeps/osf1/netload.c b/sysdeps/osf1/netload.c deleted file mode 100644 index 1e2f7ec7..00000000 --- a/sysdeps/osf1/netload.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/netload.h> - -static const unsigned long _glibtop_sysdeps_netload = 0; - -/* Init function. */ - -int -glibtop_init_netload_p (glibtop *server) -{ - server->sysdeps.netload = _glibtop_sysdeps_netload; - - return 0; -} - -/* Provides Network statistics. */ - -int -glibtop_get_netload_p (glibtop *server, glibtop_netload *buf, - const char *interface, unsigned transport, - unsigned protocol) -{ - memset (buf, 0, sizeof (glibtop_netload)); - - return 0; -} diff --git a/sysdeps/osf1/open.c b/sysdeps/osf1/open.c deleted file mode 100644 index d667a18f..00000000 --- a/sysdeps/osf1/open.c +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/open.h> - -#include <unistd.h> -#include <sys/types.h> - -/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ - -void -glibtop_open_s (glibtop *server, const char *program_name, - const unsigned long features, const unsigned flags) -{ } diff --git a/sysdeps/osf1/open_suid.c b/sysdeps/osf1/open_suid.c deleted file mode 100644 index fda98d8c..00000000 --- a/sysdeps/osf1/open_suid.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/open.h> - -#include <glibtop_suid.h> - -#include <unistd.h> -#include <sys/types.h> - -/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - -void -glibtop_init_p (glibtop *server, const unsigned long features, - const unsigned flags) -{ - glibtop_init_func_t *init_fkt; - - if (server == NULL) - glibtop_error_r (NULL, "glibtop_init_p (server == NULL)"); - - /* Do the initialization, but only if not already initialized. */ - - if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) { - glibtop_open_p (server, "glibtop", features, flags); - - for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++) - (*init_fkt) (server); - - server->flags |= _GLIBTOP_INIT_STATE_INIT; - } -} - -/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - -void -glibtop_open_p (glibtop *server, const char *program_name, - const unsigned long features, const unsigned flags) -{ - /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ - - server->name = program_name; - - server->_priv->machine.uid = getuid (); - server->_priv->machine.euid = geteuid (); - server->_priv->machine.gid = getgid (); - server->_priv->machine.egid = getegid (); - - server->_priv->machine.proctable_entries = table - (TBL_PROCINFO, 0, NULL, INT_MAX, 0); - - /* Drop priviledges; we only become root when necessary. - - setreuid (ruid, euid) - set real and effective user id; - setregid (rgid, egid) - set real and effective group id; - - */ - - if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid)) - _exit (1); - - if (setregid (server->_priv->machine.egid, server->_priv->machine.gid)) - _exit (1); - - /* !!! END OF SUID ROOT PART !!! */ - - /* Our effective uid is now those of the user invoking the server, - so we do no longer have any priviledges. - */ -} diff --git a/sysdeps/osf1/ppp.c b/sysdeps/osf1/ppp.c deleted file mode 100644 index c60a31d0..00000000 --- a/sysdeps/osf1/ppp.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/ppp.h> - -static const unsigned long _glibtop_sysdeps_ppp = 0; - -/* Init function. */ - -int -glibtop_init_ppp_s (glibtop *server) -{ - server->sysdeps.ppp = _glibtop_sysdeps_ppp; - - return 0; -} - -/* Provides PPP/ISDN information. */ - -int -glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, - unsigned short isdn) -{ - memset (buf, 0, sizeof (glibtop_ppp)); - return 0; -} diff --git a/sysdeps/osf1/procargs.c b/sysdeps/osf1/procargs.c deleted file mode 100644 index 980b0ba3..00000000 --- a/sysdeps/osf1/procargs.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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. */ - -int -glibtop_init_proc_args_p (glibtop *server) -{ - server->sysdeps.proc_args = _glibtop_sysdeps_proc_args; - - return 0; -} - -/* Provides detailed information about a process. */ - -char ** -glibtop_get_proc_args_p (glibtop *server, glibtop_array *array, pid_t pid) -{ - memset (array, 0, sizeof (glibtop_array)); - return NULL; -} diff --git a/sysdeps/osf1/procdata.c b/sysdeps/osf1/procdata.c deleted file mode 100644 index b4dea48a..00000000 --- a/sysdeps/osf1/procdata.c +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/procdata.h> - -#include <sys/user.h> -#include <sys/time.h> -#include <sys/resource.h> - -#include <mach.h> -#include <mach/mach_types.h> -#include <mach/task_info.h> - -/* Provides detailed information about a process. */ - -#define BIT_SHIFT(x) (1L << (x % 64)) - -static const unsigned long _glibtop_sysdeps_procdata_0 = -BIT_SHIFT(GLIBTOP_PROCDATA_CMD) + -BIT_SHIFT(GLIBTOP_PROCDATA_STATE) + -BIT_SHIFT(GLIBTOP_PROCDATA_UID) + -BIT_SHIFT(GLIBTOP_PROCDATA_PID) + -BIT_SHIFT(GLIBTOP_PROCDATA_PPID) + -BIT_SHIFT(GLIBTOP_PROCDATA_PGRP) + -BIT_SHIFT(GLIBTOP_PROCDATA_TTY) + -BIT_SHIFT(GLIBTOP_PROCDATA_K_FLAGS) + -BIT_SHIFT(GLIBTOP_PROCDATA_SESSION) + -BIT_SHIFT(GLIBTOP_PROCDATA_TPGID) + -BIT_SHIFT(GLIBTOP_PROCDATA_SIGIGNORE) + -BIT_SHIFT(GLIBTOP_PROCDATA_SIGCATCH) + -BIT_SHIFT(GLIBTOP_PROCDATA_SIGNAL) + -BIT_SHIFT(GLIBTOP_PROCDATA_NICE); - -static const unsigned long _glibtop_sysdeps_procdata_1 = 0; - -void -glibtop_get_procdata_r (glibtop *server, glibtop_procdata *buf, pid_t pid) -{ - struct tbl_procinfo procinfo; - task_basic_info_data_t taskinfo; - struct user u; - task_t thistask; - int ret, info_count; - - memset (buf, 0, sizeof (glibtop_procdata)); - - glibtop_init (); - - memset (buf, 0, sizeof (glibtop_procdata)); - - ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1, - sizeof (struct tbl_procinfo)); - - if (ret != 1) return; - - strcpy (buf->cmd, procinfo.pi_comm); - - buf->uid = procinfo.pi_uid; - buf->pid = procinfo.pi_pid; - buf->ppid = procinfo.pi_ppid; - buf->pgrp = procinfo.pi_pgrp; - buf->tty = procinfo.pi_ttyd; - buf->k_flags = procinfo.pi_flag; - buf->session = procinfo.pi_session; - buf->tpgid = procinfo.pi_tpgrp; - buf->sigignore = procinfo.pi_sigignore; - buf->sigcatch = procinfo.pi_sigcatch; - buf->signal = procinfo.pi_sig; - - buf->flags [0] += _glibtop_sysdeps_procdata_0; - - if (procinfo.pi_status != PI_ACTIVE) return; - - /* From that point on, we are only interested in active processes. */ - - buf->nice = getpriority (PRIO_PROCESS, pid); - - /* Get task structure. */ - - ret = task_by_unix_pid (task_self(), procinfo.pi_pid, &thistask); - - if (ret != KERN_SUCCESS) return; - - /* Get taskinfo about this task. */ - - info_count = TASK_BASIC_INFO_COUNT; - - ret = task_info (thistask, TASK_BASIC_INFO, (task_info_t) &taskinfo, &info_count); - - if (ret != KERN_SUCCESS) return; - - buf->priority = taskinfo.base_priority; - buf->resident = taskinfo.resident_size; - buf->rss = taskinfo.resident_size; - buf->vsize = taskinfo.virtual_size; - - buf->flags [0] += BIT_SHIFT(GLIBTOP_PROCDATA_PRIORITY) + - BIT_SHIFT(GLIBTOP_PROCDATA_RESIDENT) + - BIT_SHIFT(GLIBTOP_PROCDATA_RSS) + - BIT_SHIFT(GLIBTOP_PROCDATA_VSIZE); - - ret = table (TBL_UAREA, pid, (char *) &u, 1, - sizeof (struct user)); - - if (ret != 1) return; - - buf->start_code = (unsigned long) u.u_text_start; - buf->end_code = (unsigned long) u.u_data_start; - buf->start_stack = (unsigned long) u.u_stack_start; - - buf->trs = u.u_tsize; - buf->drs = u.u_dsize; - - buf->start_time = u.u_start.tv_sec; - - buf->utime = u.u_ru.ru_utime.tv_sec; - buf->stime = u.u_ru.ru_stime.tv_sec; - buf->cutime = u.u_cru.ru_utime.tv_sec; - buf->cstime = u.u_cru.ru_stime.tv_sec; - - buf->flags [0] += BIT_SHIFT(GLIBTOP_PROCDATA_START_TIME) + - BIT_SHIFT(GLIBTOP_PROCDATA_UTIME) + BIT_SHIFT(GLIBTOP_PROCDATA_STIME) + - BIT_SHIFT(GLIBTOP_PROCDATA_CUTIME) + BIT_SHIFT(GLIBTOP_PROCDATA_CSTIME) + - BIT_SHIFT(GLIBTOP_PROCDATA_TRS) + BIT_SHIFT(GLIBTOP_PROCDATA_DRS); - - buf->flags [1] += BIT_SHIFT(GLIBTOP_PROCDATA_START_CODE) + - BIT_SHIFT(GLIBTOP_PROCDATA_END_CODE) + - BIT_SHIFT(GLIBTOP_PROCDATA_START_STACK); -} diff --git a/sysdeps/osf1/prockernel.c b/sysdeps/osf1/prockernel.c deleted file mode 100644 index 135dbad0..00000000 --- a/sysdeps/osf1/prockernel.c +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/prockernel.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_kernel = 0; - -/* Init function. */ - -int -glibtop_init_proc_kernel_p (glibtop *server) -{ - server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf, - pid_t pid) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0); - - memset (buf, 0, sizeof (glibtop_proc_kernel)); - - return 0; -} diff --git a/sysdeps/osf1/proclist.c b/sysdeps/osf1/proclist.c deleted file mode 100644 index ce400878..00000000 --- a/sysdeps/osf1/proclist.c +++ /dev/null @@ -1,176 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/proclist.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proclist = -(1L << GLIBTOP_PROCLIST_TOTAL) + (1L << GLIBTOP_PROCLIST_NUMBER) + -(1L << GLIBTOP_PROCLIST_SIZE); - -/* Init function. */ - -int -glibtop_init_proclist_p (glibtop *server) -{ - server->sysdeps.proclist = _glibtop_sysdeps_proclist; - - return 0; -} - -/* How many elements are there per proctable entry? */ - -#define ELEMENTS_PER_ENTRY 8 - -/* We have a buffer for BLOCK_COUNT pids; when it's full, it is copied - * to a newly realloc()ed area. */ - -#define BLOCK_COUNT 256 -#define BLOCK_SIZE (BLOCK_COUNT * sizeof (unsigned)) - -/* Fetch list of currently running processes. - * - * The interface of this function is a little bit different from the others: - * buf->flags is only set if the call succeeded, in this case pids_chain, - * a list of the pids of all currently running processes is returned, - * buf->number is the number of elements of this list and buf->size is - * the size of one single element (sizeof (unsigned)). The total size is - * stored in buf->total. - * - * The calling function has to free the memory to which a pointer is returned. - * - * On error, NULL is returned and buf->flags is zero. */ - -/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - -unsigned * -glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf, - int64_t which, int64_t arg) -{ - unsigned count = 0, total = 0; - unsigned pids [BLOCK_COUNT], *pids_chain = NULL; - unsigned pids_size = 0, pids_offset = 0, new_size; - struct tbl_procinfo procinfo [8]; - int entry, max_elements, k; - - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROCLIST, 0); - - memset (buf, 0, sizeof (glibtop_proclist)); - - for (entry = 0; entry < server->_priv->machine.proctable_entries; - entry += ELEMENTS_PER_ENTRY) - { - /* !!! THE FOLLOWING CODE RUNS SUID ROOT - - * CHANGE WITH CAUTION !!! */ - - glibtop_suid_enter (server); - - max_elements = table - (TBL_PROCINFO, entry, (char *) &procinfo, - ELEMENTS_PER_ENTRY, sizeof (struct tbl_procinfo)); - - glibtop_suid_leave (server); - - /* !!! END OF SUID ROOT PART !!! */ - - for (k = 0; k < max_elements; k++) - { - /* Does this entry contain a real process? */ - - if (procinfo [k].pi_status == 0) - continue; - - /* Fine. Now we first try to store it in pids. - * If this buffer is full, we copy it to the - * pids_chain. */ - - if (count >= BLOCK_COUNT) { - - /* The following call to glibtop_realloc () - * will be equivalent to glibtop_malloc () - * if `pids_chain' is NULL. We just calculate - * the new size and copy `pids' to the - * beginning of the newly allocated block. */ - - new_size = pids_size + BLOCK_SIZE; - - pids_chain = glibtop_realloc_r - (server, pids_chain, new_size); - - memcpy (pids_chain + pids_offset, - pids, BLOCK_SIZE); - - pids_size = new_size; - - pids_offset += BLOCK_COUNT; - - count = 0; - } - - /* pids is now big enough to hold at least - * one single pid. */ - - pids [count++] = procinfo [k].pi_pid; - - total++; - } - } - - /* count is only zero if an error occured - * (eg. the server is not suid root). */ - - if (!count) return NULL; - - /* The following call to glibtop_realloc () will be equivalent to - * glibtop_malloc () if `pids_chain' is NULL. We just calculate the - * new size and copy `pids' to the beginning of the newly allocated - * block. */ - - new_size = pids_size + count * sizeof (unsigned); - - pids_chain = glibtop_realloc_r (server, pids_chain, new_size); - - memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned)); - - pids_size = new_size; - - pids_offset += BLOCK_COUNT; - - /* Since everything is ok now, we can set buf->flags, fill in the - * remaining fields and return `pids_chain'. */ - - buf->flags = _glibtop_sysdeps_proclist; - - buf->size = sizeof (unsigned); - buf->number = total; - - buf->total = total * sizeof (unsigned); - - return pids_chain; -} diff --git a/sysdeps/osf1/procmap.c b/sysdeps/osf1/procmap.c deleted file mode 100644 index a6e95674..00000000 --- a/sysdeps/osf1/procmap.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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. */ - -int -glibtop_init_proc_map_p (glibtop *server) -{ - server->sysdeps.proc_map = _glibtop_sysdeps_proc_map; - - return 0; -} - -/* Provides detailed information about a process. */ - -glibtop_map_entry * -glibtop_get_proc_map_p (glibtop *server, glibtop_array *array, pid_t pid) -{ - memset (array, 0, sizeof (glibtop_array)); - return NULL; -} diff --git a/sysdeps/osf1/procmem.c b/sysdeps/osf1/procmem.c deleted file mode 100644 index 3f1dabd2..00000000 --- a/sysdeps/osf1/procmem.c +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procmem.h> - -#include <glibtop_suid.h> - -#include <sys/user.h> -#include <sys/time.h> -#include <sys/resource.h> - -#include <mach.h> -#include <mach/mach_types.h> -#include <mach/task_info.h> - -static const unsigned long _glibtop_sysdeps_proc_mem = -(1L << GLIBTOP_PROC_MEM_VSIZE) + (1L << GLIBTOP_PROC_MEM_RESIDENT) + -(1L << GLIBTOP_PROC_MEM_RSS); - -/* Init function. */ - -int -glibtop_init_proc_mem_p (glibtop *server) -{ - server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf, - pid_t pid) -{ - task_basic_info_data_t taskinfo; - int ret, info_count; - task_t thistask; - struct user u; - - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_MEM, 0); - - memset (buf, 0, sizeof (glibtop_proc_mem)); - - /* Get task structure. */ - - ret = task_by_unix_pid (task_self(), pid, &thistask); - - if (ret != KERN_SUCCESS) return -1; - - /* Get taskinfo about this task. */ - - info_count = TASK_BASIC_INFO_COUNT; - - ret = task_info (thistask, TASK_BASIC_INFO, - (task_info_t) &taskinfo, &info_count); - - if (ret != KERN_SUCCESS) return -1; - - buf->resident = taskinfo.resident_size; - buf->rss = taskinfo.resident_size; - buf->vsize = taskinfo.virtual_size; - - /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - - glibtop_suid_enter (server); - - ret = table (TBL_UAREA, pid, (char *) &u, 1, - sizeof (struct user)); - - glibtop_suid_leave (server); - - /* !!! END OF SUID ROOT PART !!! */ - - if (ret != 1) return -1; - - buf->rss_rlim = u.u_rlimit [RLIMIT_RSS].rlim_cur; - - buf->share = u.u_ru.ru_ixrss; - - buf->flags |= (1L << GLIBTOP_PROC_MEM_RSS_RLIM) | - (1L << GLIBTOP_PROC_MEM_SHARE); - - return 0; -} diff --git a/sysdeps/osf1/procsegment.c b/sysdeps/osf1/procsegment.c deleted file mode 100644 index dc67a87d..00000000 --- a/sysdeps/osf1/procsegment.c +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procsegment.h> - -#include <glibtop_suid.h> - -#include <sys/user.h> - -static const unsigned long _glibtop_sysdeps_proc_segment = -(1L << GLIBTOP_PROC_SEGMENT_TEXT_RSS) + -(1L << GLIBTOP_PROC_SEGMENT_DATA_RSS) + -(1L << GLIBTOP_PROC_SEGMENT_START_CODE) + -(1L << GLIBTOP_PROC_SEGMENT_END_CODE) + -(1L << GLIBTOP_PROC_SEGMENT_START_STACK); - -/* Init function. */ - -int -glibtop_init_proc_segment_p (glibtop *server) -{ - server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf, - pid_t pid) -{ - int ret; - struct user u; - - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0); - - memset (buf, 0, sizeof (glibtop_proc_segment)); - - /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - - glibtop_suid_enter (server); - - ret = table (TBL_UAREA, pid, (char *) &u, 1, - sizeof (struct user)); - - glibtop_suid_leave (server); - - /* !!! END OF SUID ROOT PART !!! */ - - if (ret != 1) return -1; - - buf->start_code = (unsigned long) u.u_text_start; - buf->end_code = (unsigned long) u.u_data_start; - buf->start_stack = (unsigned long) u.u_stack_start; - - buf->text_rss = u.u_tsize; - buf->data_rss = u.u_dsize; - - buf->flags = _glibtop_sysdeps_proc_segment; - - return 0; -} diff --git a/sysdeps/osf1/procsignal.c b/sysdeps/osf1/procsignal.c deleted file mode 100644 index 7c487980..00000000 --- a/sysdeps/osf1/procsignal.c +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procsignal.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_signal = -(1L << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1L << GLIBTOP_PROC_SIGNAL_BLOCKED) + -(1L << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1L << GLIBTOP_PROC_SIGNAL_SIGCATCH); - -/* Init function. */ - -int -glibtop_init_proc_signal_p (glibtop *server) -{ - server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf, - pid_t pid) -{ - struct tbl_procinfo procinfo; - int ret; - - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0); - - memset (buf, 0, sizeof (glibtop_proc_signal)); - - /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - - glibtop_suid_enter (server); - - ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1, - sizeof (struct tbl_procinfo)); - - glibtop_suid_leave (server); - - /* !!! END OF SUID ROOT PART !!! */ - - if (ret != 1) return -1; - - buf->signal [0] = procinfo.pi_sig; - buf->blocked [0] = procinfo.pi_sigmask; - buf->sigignore [0] = procinfo.pi_sigignore; - buf->sigcatch [0] = procinfo.pi_sigcatch; - - buf->flags = _glibtop_sysdeps_proc_signal; - - return 0; -} diff --git a/sysdeps/osf1/procstate.c b/sysdeps/osf1/procstate.c deleted file mode 100644 index c8bb4692..00000000 --- a/sysdeps/osf1/procstate.c +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procstate.h> - -#include <glibtop_suid.h> - -#include <mach.h> -#include <mach/mach_types.h> -#include <mach/task_info.h> - -static const unsigned long _glibtop_sysdeps_proc_state = -(1L << GLIBTOP_PROC_STATE_CMD) + -(1L << GLIBTOP_PROC_STATE_UID) + (1L << GLIBTOP_PROC_STATE_GID) + -(1L << GLIBTOP_PROC_STATE_RUID) + (1L << GLIBTOP_PROC_STATE_RGID); - -/* Init function. */ - -int -glibtop_init_proc_state_p (glibtop *server) -{ - server->sysdeps.proc_state = _glibtop_sysdeps_proc_state; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf, - pid_t pid) -{ - struct tbl_procinfo procinfo; - int minim_state = 99, ret; - task_t thistask; - - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_STATE, 0); - - memset (buf, 0, sizeof (glibtop_proc_state)); - - /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - - glibtop_suid_enter (server); - - ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1, - sizeof (struct tbl_procinfo)); - - glibtop_suid_leave (server); - - /* !!! END OF SUID ROOT PART !!! */ - - if (ret != 1) return -1; - - /* Check whether the process actually exists. */ - if (procinfo.pi_status == PI_EMPTY) return -1; - - /* Check whether it is not a zombie. */ - if (procinfo.pi_status == PI_ZOMBIE) { - buf->state = GLIBTOP_PROCESS_ZOMBIE; - buf->flags = (1L << GLIBTOP_PROC_STATE_STATE); - return -1; - } - - strncpy (buf->cmd, procinfo.pi_comm, sizeof (buf->cmd)-1); - - buf->cmd [sizeof (buf->cmd)-1] = 0; - - buf->uid = procinfo.pi_svuid; - buf->gid = procinfo.pi_svgid; - buf->ruid = procinfo.pi_ruid; - buf->rgid = procinfo.pi_rgid; - - buf->flags = _glibtop_sysdeps_proc_state; - - /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - - glibtop_suid_enter (server); - - /* Get task structure. */ - ret = task_by_unix_pid (task_self(), procinfo.pi_pid, &thistask); - - if (ret == KERN_SUCCESS) { - thread_array_t threadarr; - unsigned int threadarr_l; - thread_basic_info_t threadinfo; - thread_basic_info_data_t threadinfodata; - int j; - - /* Get thread array. */ - (void) task_threads (thistask, &threadarr, &threadarr_l); - - threadinfo = &threadinfodata; - for (j = 0; j < threadarr_l; j++) { - unsigned int threadinfo_l = THREAD_BASIC_INFO_COUNT; - int tret; - - tret = thread_info (threadarr [j], THREAD_BASIC_INFO, - (thread_info_t) threadinfo, &threadinfo_l); - - if (tret == KERN_SUCCESS) { - if (minim_state > threadinfo->run_state) - minim_state=threadinfo->run_state; - } - } - } - - glibtop_suid_leave (server); - - /* !!! END OF SUID ROOT PART !!! */ - - if (ret != KERN_SUCCESS) return -1; - - switch (minim_state) { - case TH_STATE_RUNNING: - buf->state = GLIBTOP_PROCESS_RUNNING; - break; - case TH_STATE_UNINTERRUPTIBLE: - buf->state = GLIBTOP_PROCESS_UNINTERRUPTIBLE; - break; - case TH_STATE_WAITING: - buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE; - break; - case TH_STATE_STOPPED: - case TH_STATE_HALTED: - buf->state = GLIBTOP_PROCESS_STOPPED; - break; - default: - if (ret != KERN_SUCCESS) - buf->state = GLIBTOP_PROCESS_ZOMBIE; - break; - } - - if (buf->state) - buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE); - - return 0; -} diff --git a/sysdeps/osf1/proctime.c b/sysdeps/osf1/proctime.c deleted file mode 100644 index 975647c1..00000000 --- a/sysdeps/osf1/proctime.c +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/proctime.h> - -#include <glibtop_suid.h> - -#include <sys/user.h> -#include <sys/time.h> - -static const unsigned long _glibtop_sysdeps_proc_time = -(1L << GLIBTOP_PROC_TIME_UTIME) + (1L << GLIBTOP_PROC_TIME_CUTIME) + -(1L << GLIBTOP_PROC_TIME_STIME) + (1L << GLIBTOP_PROC_TIME_CSTIME) + -(1L << GLIBTOP_PROC_TIME_START_TIME); - -/* Init function. */ - -int -glibtop_init_proc_time_p (glibtop *server) -{ - server->sysdeps.proc_time = _glibtop_sysdeps_proc_time; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf, - pid_t pid) -{ - struct user u; - int ret; - - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_TIME, 0); - - memset (buf, 0, sizeof (glibtop_proc_time)); - - /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - - glibtop_suid_enter (server); - - ret = table (TBL_UAREA, pid, (char *) &u, 1, - sizeof (struct user)); - - glibtop_suid_leave (server); - - /* !!! END OF SUID ROOT PART !!! */ - - if (ret != 1) return -1; - - buf->start_time = u.u_start.tv_sec; - - buf->utime = u.u_ru.ru_utime.tv_sec; - buf->stime = u.u_ru.ru_stime.tv_sec; - buf->cutime = u.u_cru.ru_utime.tv_sec; - buf->cstime = u.u_cru.ru_stime.tv_sec; - - buf->flags = _glibtop_sysdeps_proc_time; - - return 0; -} diff --git a/sysdeps/osf1/procuid.c b/sysdeps/osf1/procuid.c deleted file mode 100644 index cbbbdec0..00000000 --- a/sysdeps/osf1/procuid.c +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procuid.h> - -#include <glibtop_suid.h> - -#include <sys/table.h> -#include <sys/resource.h> - -#include <mach.h> -#include <mach/mach_types.h> -#include <mach/task_info.h> - -/* Provides detailed information about a process. */ - -static const unsigned long _glibtop_sysdeps_proc_uid = -(1L << GLIBTOP_PROC_UID_UID) + (1L << GLIBTOP_PROC_UID_EUID) + -(1L << GLIBTOP_PROC_UID_GID) + (1L << GLIBTOP_PROC_UID_EGID) + -(1L << GLIBTOP_PROC_UID_PID) + (1L << GLIBTOP_PROC_UID_PPID) + -(1L << GLIBTOP_PROC_UID_PGRP) + (1L << GLIBTOP_PROC_UID_SESSION) + -(1L << GLIBTOP_PROC_UID_TTY) + (1L << GLIBTOP_PROC_UID_TPGID); - -/* Init function. */ - -int -glibtop_init_proc_uid_p (glibtop *server) -{ - server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid; - - return 0; -} - -int -glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf, - pid_t pid) -{ - struct tbl_procinfo procinfo; - task_basic_info_data_t taskinfo; - int ret, info_count; - task_t thistask; - - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_UID, 0); - - memset (buf, 0, sizeof (glibtop_proc_uid)); - - /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - - glibtop_suid_enter (server); - - ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1, - sizeof (struct tbl_procinfo)); - - glibtop_suid_leave (server); - - /* !!! END OF SUID ROOT PART !!! */ - - if (ret != 1) return -1; - - buf->uid = procinfo.pi_ruid; - buf->euid = procinfo.pi_svuid; - buf->gid = procinfo.pi_rgid; - buf->egid = procinfo.pi_svgid; - - buf->pid = procinfo.pi_pid; - buf->ppid = procinfo.pi_ppid; - buf->pgrp = procinfo.pi_pgrp; - buf->tty = procinfo.pi_ttyd; - buf->session = procinfo.pi_session; - buf->tpgid = procinfo.pi_tpgrp; - - buf->flags = _glibtop_sysdeps_proc_uid; - - /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - - glibtop_suid_enter (server); - - /* Get task structure. */ - - ret = task_by_unix_pid (task_self(), procinfo.pi_pid, &thistask); - - if (ret == KERN_SUCCESS) { - - /* Get taskinfo about this task. */ - - info_count = TASK_BASIC_INFO_COUNT; - - ret = task_info (thistask, TASK_BASIC_INFO, - (task_info_t) &taskinfo, &info_count); - - /* `ret' is evaluated outside the `if' clause. */ - } - - glibtop_suid_leave (server); - - /* !!! END OF SUID ROOT PART !!! */ - - if (ret != KERN_SUCCESS) return -1; - - buf->priority = taskinfo.base_priority; - - buf->flags += (1L << GLIBTOP_PROC_UID_PRIORITY); - - errno = 0; - - ret = getpriority (PRIO_PROCESS, pid); - - if ((ret == -1) && (errno != 0)) return -1; - - buf->nice = ret; - - buf->flags += (1L << GLIBTOP_PROC_UID_NICE); - - return 0; -} diff --git a/sysdeps/osf1/sem_limits.c b/sysdeps/osf1/sem_limits.c deleted file mode 100644 index 1bb10123..00000000 --- a/sysdeps/osf1/sem_limits.c +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/sem_limits.h> - -static unsigned long _glibtop_sysdeps_sem_limits = -(1L << GLIBTOP_SEM_LIMITS_SEMMNI) + (1L << GLIBTOP_SEM_LIMITS_SEMMSL) + -(1L << GLIBTOP_SEM_LIMITS_SEMOPM) + (1L << GLIBTOP_SEM_LIMITS_SEMVMX) + -(1L << GLIBTOP_SEM_LIMITS_SEMAEM); - -/* Init function. */ - -int -glibtop_init_sem_limits_s (glibtop *server) -{ - server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits; - - return 0; -} - -/* Provides information about sysv sem limits. */ - -int -glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf) -{ - int ret, value; - - glibtop_init_s (&server, 0, 0); - - memset (buf, 0, sizeof (glibtop_sem_limits)); - - ret = table (TBL_SEMINFO, SEMINFO_MNI, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMMNI); - - buf->semmni = value; - - - ret = table (TBL_SEMINFO, SEMINFO_MSL, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMMSL); - - buf->semmsl = value; - - - ret = table (TBL_SEMINFO, SEMINFO_OPM, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMOPM); - - buf->semopm = value; - - - ret = table (TBL_SEMINFO, SEMINFO_UME, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMUME); - - buf->semume = value; - - - ret = table (TBL_SEMINFO, SEMINFO_VMX, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMVMX); - - buf->semvmx = value; - - - ret = table (TBL_SEMINFO, SEMINFO_AEM, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMAEM); - - buf->semaem = value; - - return 0; -} diff --git a/sysdeps/osf1/shm_limits.c b/sysdeps/osf1/shm_limits.c deleted file mode 100644 index bcb97946..00000000 --- a/sysdeps/osf1/shm_limits.c +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/shm_limits.h> - -static unsigned long _glibtop_sysdeps_shm_limits = -(1L << GLIBTOP_SHM_LIMITS_SHMMAX) + (1L << GLIBTOP_SHM_LIMITS_SHMMIN) + -(1L << GLIBTOP_SHM_LIMITS_SHMMNI) + (1L << GLIBTOP_SHM_LIMITS_SHMSEG); - -/* Init function. */ - -int -glibtop_init_shm_limits_s (glibtop *server) -{ - server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf) -{ - int ret, value; - - glibtop_init_s (&server, 0, 0); - - memset (buf, 0, sizeof (glibtop_shm_limits)); - - ret = table (TBL_SHMINFO, SHMINFO_MAX, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_SHM_LIMITS_SHMMAX); - - buf->shmmax = value; - - - ret = table (TBL_SHMINFO, SHMINFO_MIN, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_SHM_LIMITS_SHMMIN); - - buf->shmmin = value; - - - ret = table (TBL_SHMINFO, SHMINFO_MNI, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_SHM_LIMITS_SHMMNI); - - buf->shmmni = value; - - - ret = table (TBL_SHMINFO, SHMINFO_SEG, (char *) &value, 1, - sizeof (value)); - - if (ret != 1) return -1; - - buf->flags += (1L << GLIBTOP_SHM_LIMITS_SHMSEG); - - buf->shmseg = value; - - return 0; -} diff --git a/sysdeps/osf1/swap.c b/sysdeps/osf1/swap.c deleted file mode 100644 index 52776c35..00000000 --- a/sysdeps/osf1/swap.c +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/swap.h> - -static unsigned long _glibtop_sysdeps_swap = -(1L << GLIBTOP_SWAP_TOTAL) + (1L << GLIBTOP_SWAP_USED) + -(1L << GLIBTOP_SWAP_FREE); - -/* Init function. */ - -int -glibtop_init_swap_s (glibtop *server) -{ - server->sysdeps.swap = _glibtop_sysdeps_swap; - - return 0; -} - -/* Provides information about swap usage. */ - -int -glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) -{ - struct tbl_swapinfo swapinfo; - int i; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_SWAP, 0); - - memset (buf, 0, sizeof (glibtop_swap)); - - i = 0; - - while (table (TBL_SWAPINFO, i, (char *) &swapinfo, 1, - sizeof (struct tbl_swapinfo)) > 0) { - buf->total += swapinfo.size * getpagesize (); - buf->free += swapinfo.free * getpagesize (); - i++; - } - - buf->flags = _glibtop_sysdeps_swap; - - buf->used = buf->total - buf->free; - - return 0; -} diff --git a/sysdeps/osf1/uptime.c b/sysdeps/osf1/uptime.c deleted file mode 100644 index 875714ab..00000000 --- a/sysdeps/osf1/uptime.c +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/uptime.h> - -#include <time.h> - -static unsigned long _glibtop_sysdeps_uptime = -(1L << GLIBTOP_UPTIME_UPTIME); - -/* Init function. */ - -int -glibtop_init_uptime_s (glibtop *server) -{ - server->sysdeps.uptime = _glibtop_sysdeps_uptime; - - return 0; -} - -/* Provides uptime and idle time. */ - -int -glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) -{ - struct tbl_sysinfo sysinfo; - int ret; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_UPTIME, 0); - - memset (buf, 0, sizeof (glibtop_uptime)); - - ret = table (TBL_SYSINFO, 0, (char *) &sysinfo, 1, - sizeof (struct tbl_sysinfo)); - - if (ret != 1) return -1; - - buf->uptime = (double) (time (NULL) - sysinfo.si_boottime); - - buf->flags = _glibtop_sysdeps_uptime; - - return 0; -} diff --git a/sysdeps/solaris/.cvsignore b/sysdeps/solaris/.cvsignore deleted file mode 100644 index facaec43..00000000 --- a/sysdeps/solaris/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -libgtop_sysdeps.la -*.lo -libgtop_sysdeps_suid.la diff --git a/sysdeps/solaris/AUTHORS b/sysdeps/solaris/AUTHORS deleted file mode 100644 index 37b903af..00000000 --- a/sysdeps/solaris/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Drazen Kacar (dave@srce.hr) -Martin Baulig (martin@home-of-linux.org) diff --git a/sysdeps/solaris/ChangeLog b/sysdeps/solaris/ChangeLog deleted file mode 100644 index 5f6ebc22..00000000 --- a/sysdeps/solaris/ChangeLog +++ /dev/null @@ -1,290 +0,0 @@ -2000-02-22 Martin Baulig <martin@home-of-linux.org> - - * Makefile.am: Only install the libs in $(LIBGTOP_BACKEND_DIR) - when we LIBGTOP_USE_GMODULE and in $(libdir) otherwise. - -2000-02-16 Martin Baulig <martin@home-of-linux.org> - - * Makefile.am: Install libraries in $(backenddir). - -1999-12-25 Martin Baulig <martin@home-of-linux.org> - - * safeio.h: Removed. This is now included in <glibtop_private.h>. - - * netinfo.c: New file. - - * glibtop_private.h: Added function prototypes for everything - from safeio.c. - -1999-10-17 Martin Baulig <martin@home-of-linux.org> - - * Makefile.am (libgtop_sysdeps_la_LIBADD): Added `@DL_LIB@'. - -1999-09-28 Drazen Kacar <dave@srce.hr> - - * proclist.c (glibtop_get_proclist_s): Bugfix. It wasn't - excluding system, non-tty or idle processes if that was - requested. - -1999-07-29 Martin Baulig <martin@home-of-linux.org> - - * proctime.c (glibtop_get_proc_time_p): Fix bug reported by - Takis Psarogiannakopoulos: `start_time' are seconds since the - epoch as it is stated in the manual. - -1999-07-16 Drazen Kacar <dave@srce.hr> - - * proclist.c: Bug fix. All Solaris versions have RUID and - RGID in /proc. - -1999-06-07 Drazen Kacar <dave@srce.hr> - - * glibtop_machine.h, open.c, procargs.c, proclist.c, procmap.c: - Solaris 2.5 & 2.5.1 portability fixes, based on patches - from Steve Murphy <murf@e-tools.com>. - -1999-05-30 Drazen Kacar <dave@srce.hr> - - * procargs.c: Fixed bug in calculation of process argument list. - -1999-05-27 Drazen Kacar <dave@srce.hr> - - * glibtop_machine.h, open.c, procmap.c: Get the file name - from inode number. - -1999-05-17 Drazen Kacar <dave@srce.hr> - - * procargs.c: Implemented what Solaris has to offer cheaply. - It sucks, but digging in process address space would be - too slow. - -1999-05-11 Drazen Kacar <dave@srce.hr> - - * proctime.c: Return 0 usage times for scheaduler (PID 0). - -1999-05-10 Drazen Kacar <dave@srce.hr> - - * proclist.c: Added process selection mechanism. It's not - included in Solaris 2.5 build, since we first have to decide - what will be dispatched to daemon. - -1999-05-10 Drazen Kacar <dave@srce.hr> - - There be some useful documentation now. Syncing... - - * mem.c: Output values in bytes, as the documentation requires. - It was a bit odd when gtop reported 256K of total memory. - -1999-05-09 Drazen Kacar <dave@srce.hr> - - * glibtop_machine.h, procdata.c, proclist.c, procmap.c, procmem.c, - procsignal.c, procstate.c, procuid.c, open.c, mem.c: Initial - Solaris 2.5 port. It's far from being complete and hasn't been - tested properly. We'll need setuid root daemon, which is - currently not implemented. #ifdef symbols to check are - HAVE_PROCFS_H and KSTAT_DATA_UINT32. These will be defined on - Solaris 2.6 and later, but not on earlier releases. - -1999-05-08 Drazen Kacar <dave@srce.hr> - - * safeio.c, safeio.h: Added s_open(), s_close() etc. with EINTR - wrappers. - - * procdata.c, procmap.c, proclist.c: Use them. - -1999-05-08 Drazen Kacar <dave@srce.hr> - - * procmem.c: Use bytes as units for memory consumption. - -1999-05-08 Drazen Kacar <dave@srce.hr> - - * procuid.c: Fixed nice value. - -1999-05-08 Martin Baulig <martin@home-of-linux.org> - - Use the setgid server for IPC Limits. - - * shm_limits.c, msg_limits.c, sem_limits.c: Moved them into the - setgid server since they need to access kvm data. - - * open_suid.c, close_suid.c: New file. We do the initialization and cleanup - for the setgid server here. - - * glibtop_suid.h: New file. We include this in the setgid files. - - * open.c: Moved kvm opening code into open_suid.c. - -1999-05-07 Drazen Kacar <dave@srce.hr> - - * glibtop_machine.h, open.c, mem.c, procmem.c: machine.pagesize - is now number of bits we need for shifting, ie. 2^pagesize - will give pagesize in Kb. - -1999-05-07 Drazen Kacar <dave@srce.hr> - - * procmem.c: Implemented size, vsize, resident and rss. - -1999-05-06 Drazen Kacar <dave@srce.hr> - - * siglist.c: Fixed, valid for Solaris 2.6 & 7. - -1999-05-06 Drazen Kacar <dave@srce.hr> - - * glibtop_private.h, procuid.c, procdata.c: List of supplementary - groups was not correct. Fixed. - -1999-05-04 Drazen Kacar <dave@srce.hr> - - * glibtop_machine.h: Changed boot time to unsigned long long. - - * open.c: Added proper type checking for boot value. There's - no point in saving a few nanoseconds in init function. And - one day it will become 64-bit value. - - In glibtop_get_kstats(): Don't reread vminfo_snaptime when - reinitializing kstats. - -1999-05-03 Drazen Kacar <dave@srce.hr> - - * glibtop_private.h: Fixed typoo. - - * procmap.c (glibtop_get_proc_map_s): Implemented start, end, - offset and perm for mapped segments. File name and inode - should be accessible from bunyip kstat data. The only - obstacle is that the data format is undocumented and - possibly not the same accross releases. - -1999-05-03 Drazen Kacar <dave@srce.hr> - - * glibtop_private.h, procdata.c (glibtop_get_proc_status_s): - Read pstatus info from /proc - - * procsignal.c (glibtop_get_proc_signal_s): Implemented - set of pending and blocked signals. The rest should probably - be read from /proc/<pid>/sigact, but I'm not sure it's - worth implementing before thread API comes into place. - - * siglist.c: Added Solaris 7 signals. Someone will gettextize - it eventually. Besides, signal list should become a pointer - instead of being fixed field. We need some run time initializations. - The code is written, but commented out. - -1999-05-03 Drazen Kacar <dave@srce.hr> - - * glibtop_private.h: Ups, forgot to put prototypes in. - -1999-05-02 Drazen Kacar <dave@srce.hr> - - * open.c (glibtop_get_kstats): Yet another kstat_chain_update - check. Added machine.cpu_stat_kstat[x] = NULL when processor - x is not configured. - - * procdata.c (glibtop_get_proc_credentials_s): Read prcred - structure from /proc. - - * procstate.c (glibtop_get_proc_state_s): Added ruid, rgid, - has_cpu, processor and last_processor. - - * procuid.c (glibtop_get_proc_uid_s): Added priority, nice, - suid, sgid, ngroups and groups. The last four will be - filled only if our process has the authority to read prcred - structure of another process. - -1999-05-02 Drazen Kacar <dave@srce.hr> - - procdata.c: Use pread() instead of read(). - -1999-05-02 Drazen Kacar <dave@srce.hr> - - * glibtop_machine.h: added fields for page size, clock ticks and - boot time. These are constants. Also added three new kstats. - - * open.c (glibtop_get_kstats): Initialize kstats in *server. - We need to call this at init time (obviously) and each time - kstat_chain_update() says that kstat chain has changed. In this - case all kstat pointers and data are invalid, so we need to - reinitialize everything. - - (glibtop_open_s): Made it call glibtop_get_kstats(). Added - initialization for run time constants in struct machine. - - * cpu.c (glibtop_get_cpu_s): Call kstat_chain_update(). - See if processor is on-line and set bits in xcpu_flags. - Added frequency (bad name, should have been ticks). - - * swap.c (glibtop_get_swap_s): Call kstat_chain_update(). - I probably broke vminfo_snaptime consistency. Fix later. - - * uptime.c (glibtop_get_uptime_s): Implemented uptime and boot_time. - Still looking for a sane way to get idletime. - - * mem.c (glibtop_get_mem_s): Implemented. Will use bunyip - module if it's loaded. Or when it gets loaded. kstat_chain_update() - is our friend. And with a friends like that... - - * loadavg.c (glibtop_get_loadavg_s): Solaris 2.6 code brought - into sync with everything else. - - * msg_limits.c (glibtop_init_msg_limits_s): Implemented. - - * sem_limits.c (glibtop_get_sem_limits_s): Implemented. - - Solaris takes kernel modularity too seriously. We can't get - IPC configuration data if the kernel module is not loaded and - it won't be loaded until some process actually asks for a - particular IPC resource. There's no way to tell our applications - about this. Possible API additions? - - All three IPC functions should go into daemon, but I'm keeping - them in the normal library because I can't build daemon yet. All - praise 64 bits! - -1999-04-29 Drazen Kacar <dave@srce.hr> - - * glibtop_machine.h: added field for kvm descriptor. - - * open.c: added code for opening kernel name space. - - * shm_limits.c: implemented. - -1999-03-31 Drazen Kacar <dave@srce.hr> - - * loadavg.c: make it work with Solaris 2.6 and older. A part - of it should be moved to open.c. - -1999-03-19 Martin Baulig <martin@home-of-linux.org> - - Added first kstat based implementation for Solaris 7. - - * open.c (glibtop_open_s): Walk kstat list and save interesting - kstats in the `server->machine'. - - * cpu.c: This can already provide `idle', `user' and `sys' with - full SMP support. - - * swap.c: This can already provide `total', `used' and `free'. - -1999-03-17 Martin Baulig <martin@home-of-linux.org> - - Initial import of my Solaris 7 port. - - * loadavg.c: We use getloadavg () to get the `loadavg' field. - - * procdata.c: This file will handle all interaction with the - /proc filesystem. - (glibtop_get_proc_data_psinfo_s): Read `/proc/<pid>/psinfo' and - return the resulting `struct psinfo'. - (glibtop_get_proc_data_usage_s): Read `/proc/<pid>/usage' and - return the resulting `struct prusage'. - - * proclist.c: We use readdir () on /proc to get the list of - all pids. - - * procstate.c: Read `uid' and `gid' from the `struct psinfo'. - - * proctime.c: Read `start_time', `rtime', `utime' and `stime' - from the `struct prusage'. - - * procuid.c: Read `euid', `uid', `egid', `gid', `pid', `ppid', - `pgrp', `session' and `tty' from the `struct psinfo'. - diff --git a/sysdeps/solaris/Makefile.am b/sysdeps/solaris/Makefile.am deleted file mode 100644 index 1eda61b7..00000000 --- a/sysdeps/solaris/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ - -INCLUDES = @INCLUDES@ - -dynamic_ldflags = @libgtop_dynamic_ldflags@ - -backenddir = @LIBGTOP_BACKEND_DIR@ - -if LIBGTOP_USE_GMODULE -backendlibdir = $(backenddir) -else -backendlibdir = $(libdir) -endif - -backendlib_LTLIBRARIES = libgtop_sysdeps.la libgtop_sysdeps_suid.la - -libgtop_sysdeps_la_SOURCES = open.c close.c cpu.c mem.c \ - safeio.c swap.c uptime.c loadavg.c \ - proclist.c procstate.c procuid.c \ - proctime.c procmem.c procsignal.c \ - prockernel.c procsegment.c procargs.c \ - procmap.c netload.c netinfo.c ppp.c \ - procdata.c interfaces.c - -libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) $(dynamic_ldflags) - -libgtop_sysdeps_suid_la_SOURCES = open_suid.c close_suid.c \ - shm_limits.c msg_limits.c sem_limits.c - -libgtop_sysdeps_suid_la_LDFLAGS = $(LT_VERSION_INFO) $(dynamic_ldflags) - - -include_HEADERS = glibtop_server.h glibtop_machine.h -noinst_HEADERS = glibtop_private.h glibtop_suid.h - diff --git a/sysdeps/solaris/close.c b/sysdeps/solaris/close.c deleted file mode 100644 index 3378b817..00000000 --- a/sysdeps/solaris/close.c +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop/close.h> - -/* Closes pipe to gtop server. */ - -void -glibtop_close_s (glibtop *server) -{ } diff --git a/sysdeps/solaris/close_suid.c b/sysdeps/solaris/close_suid.c deleted file mode 100644 index 95bffec1..00000000 --- a/sysdeps/solaris/close_suid.c +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop/close.h> - -/* Closes pipe to gtop server. */ - -void -glibtop_close_p (glibtop *server) -{ } diff --git a/sysdeps/solaris/cpu.c b/sysdeps/solaris/cpu.c deleted file mode 100644 index 08098183..00000000 --- a/sysdeps/solaris/cpu.c +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/cpu.h> - -#include <assert.h> -#include <sys/processor.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_cpu = -(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) + -(1L << GLIBTOP_CPU_SYS) + (1L << GLIBTOP_CPU_IDLE) + -(1L << GLIBTOP_CPU_XCPU_TOTAL) + (1L << GLIBTOP_CPU_XCPU_USER) + -(1L << GLIBTOP_CPU_XCPU_SYS) + (1L << GLIBTOP_CPU_XCPU_IDLE) + -(1L << GLIBTOP_CPU_FREQUENCY) + (1L << GLIBTOP_CPU_XCPU_FLAGS); - -/* Init function. */ - -int -glibtop_init_cpu_s (glibtop *server) -{ - server->sysdeps.cpu = _glibtop_sysdeps_cpu; - - return 0; -} - -/* Provides information about cpu usage. */ - -int -glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) -{ - kstat_ctl_t *kc = server->_priv->machine.kc; - cpu_stat_t cpu_stat; - processorid_t cpu; - int ncpu, found; - kid_t ret; - - memset (buf, 0, sizeof (glibtop_cpu)); - - if(!kc) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - switch(kstat_chain_update(kc)) - { - case -1: assert(0); /* Debugging purposes, shouldn't happen */ - case 0: break; - default: glibtop_get_kstats(server); - } - ncpu = server->ncpu; - if (ncpu > GLIBTOP_NCPU) - ncpu = GLIBTOP_NCPU; - - for (cpu = 0, found = 0; cpu < GLIBTOP_NCPU && found != ncpu; cpu++) - { - kstat_t *ksp = server->_priv->machine.cpu_stat_kstat [cpu]; - if (!ksp) continue; - - ++found; - if(p_online(cpu, P_STATUS) == P_ONLINE) - buf->xcpu_flags |= (1L << cpu); - else - continue; - ret = kstat_read (kc, ksp, &cpu_stat); - - if (ret == -1) { - glibtop_warn_io_r (server, "kstat_read (cpu_stat%d)", cpu); - continue; - } - - buf->xcpu_idle [cpu] = cpu_stat.cpu_sysinfo.cpu [CPU_IDLE]; - buf->xcpu_user [cpu] = cpu_stat.cpu_sysinfo.cpu [CPU_USER]; - buf->xcpu_sys [cpu] = cpu_stat.cpu_sysinfo.cpu [CPU_KERNEL]; - - buf->xcpu_total [cpu] = buf->xcpu_idle [cpu] + buf->xcpu_user [cpu] + - buf->xcpu_sys [cpu]; - - buf->idle += cpu_stat.cpu_sysinfo.cpu [CPU_IDLE]; - buf->user += cpu_stat.cpu_sysinfo.cpu [CPU_USER]; - buf->sys += cpu_stat.cpu_sysinfo.cpu [CPU_KERNEL]; - } - - buf->total = buf->idle + buf->user + buf->sys; - buf->frequency = server->_priv->machine.ticks; - - buf->flags = _glibtop_sysdeps_cpu; - - return 0; -} diff --git a/sysdeps/solaris/glibtop_machine.h b/sysdeps/solaris/glibtop_machine.h deleted file mode 100644 index b3eb413c..00000000 --- a/sysdeps/solaris/glibtop_machine.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_MACHINE_H__ -#define __GLIBTOP_MACHINE_H__ - -#include <sys/param.h> -#ifdef HAVE_PROCFS_H -#include <procfs.h> -#else -#include <sys/procfs.h> -#endif -#include <fcntl.h> - -#include <kstat.h> -#include <kvm.h> -#include <sys/sysinfo.h> - -BEGIN_LIBGTOP_DECLS - -typedef struct _glibtop_machine glibtop_machine; - -struct _glibtop_machine -{ - uid_t uid, euid; - gid_t gid, egid; - pid_t me; /* Don't ask why we need this */ - - kvm_t *kd; - - kstat_ctl_t *kc; - - kstat_t *vminfo_kstat; - hrtime_t vminfo_snaptime; - vminfo_t vminfo; - - kstat_t *cpu_stat_kstat [64]; - - kstat_t *system; /* boot_time & avenrun* where needed */ - kstat_t *syspages; /* memory usage */ - kstat_t *bunyip; /* more memory usage */ - - int pagesize; /* in bits to shift, ie. 2^pagesize gives Kb */ - int ticks; /* clock ticks, as returned by sysconf() */ - unsigned long long boot; /* boot time, although it's ui32 in kstat */ - void *libproc; /* libproc handle */ -#if GLIBTOP_SOLARIS_RELEASE >= 560 - void (*objname)(void *, uintptr_t, const char *, size_t); - struct ps_prochandle *(*pgrab)(pid_t, int, int *); - void (*pfree)(void *); -#else - void *filler[3]; -#endif -}; - -END_LIBGTOP_DECLS - -#endif __GLIBTOP_MACHINE_H__ diff --git a/sysdeps/solaris/glibtop_private.h b/sysdeps/solaris/glibtop_private.h deleted file mode 100644 index 06790cce..00000000 --- a/sysdeps/solaris/glibtop_private.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_PRIVATE_H__ -#define __GLIBTOP_PRIVATE_H__ - -#include <glibtop.h> -#include <glibtop/error.h> - -#include <sys/param.h> -#include <kstat.h> -#include <fcntl.h> -#if defined(HAVE_PROCFS_H) -# include <procfs.h> -#elif defined(HAVE_SYS_PROCFS_H) -# include <sys/procfs.h> -#else -# error Cannot compile without <procfs.h> or <sys/procfs.h> -#endif - -BEGIN_LIBGTOP_DECLS - -#ifdef HAVE_PROCFS_H - -/* Read /proc/<pid>/psinfo */ -int glibtop_get_proc_data_psinfo_s(glibtop *, struct psinfo *, pid_t pid); - -/* Read /proc/<pid>/status */ -int glibtop_get_proc_status_s(glibtop *, struct pstatus *, pid_t); -#else -int glibtop_get_proc_data_psinfo_s(glibtop *, struct prpsinfo *, pid_t); -int glibtop_get_proc_status_s(glibtop *, struct prstatus *, pid_t); -#endif - -/* Read /proc/<pid>/usage */ -int glibtop_get_proc_data_usage_s(glibtop *, struct prusage *, pid_t); - -/* Read /proc/<pid>/cred */ -int glibtop_get_proc_credentials_s(glibtop *, struct prcred *, gid_t *, pid_t); - -/* Reread kstat chains */ -void glibtop_get_kstats(glibtop *); - -/* safeio.c */ - -int s_open (const char *, int); -int s_stat (const char *, struct stat *); -int s_close (int); -ssize_t s_pread (int, void *, size_t, off_t); -int s_closedir (DIR *); - -END_LIBGTOP_DECLS - -#endif __GLIBTOP_PRIVATE_H__ diff --git a/sysdeps/solaris/glibtop_server.h b/sysdeps/solaris/glibtop_server.h deleted file mode 100644 index 3e8a1838..00000000 --- a/sysdeps/solaris/glibtop_server.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_SERVER_H__ -#define __GLIBTOP_SERVER_H__ - -BEGIN_LIBGTOP_DECLS - -#define GLIBTOP_SUID_CPU 0 -#define GLIBTOP_SUID_MEM 0 -#define GLIBTOP_SUID_SWAP 0 -#define GLIBTOP_SUID_UPTIME 0 -#define GLIBTOP_SUID_LOADAVG 0 -#define GLIBTOP_SUID_SHM_LIMITS (1L << GLIBTOP_SYSDEPS_SHM_LIMITS) -#define GLIBTOP_SUID_MSG_LIMITS (1L << GLIBTOP_SYSDEPS_MSG_LIMITS) -#define GLIBTOP_SUID_SEM_LIMITS (1L << GLIBTOP_SYSDEPS_SEM_LIMITS) -#define GLIBTOP_SUID_PROCLIST 0 -#define GLIBTOP_SUID_PROC_STATE 0 -#define GLIBTOP_SUID_PROC_UID 0 -#define GLIBTOP_SUID_PROC_MEM 0 -#define GLIBTOP_SUID_PROC_TIME 0 -#define GLIBTOP_SUID_PROC_SIGNAL 0 -#define GLIBTOP_SUID_PROC_KERNEL 0 -#define GLIBTOP_SUID_PROC_SEGMENT 0 -#define GLIBTOP_SUID_PROC_ARGS 0 -#define GLIBTOP_SUID_PROC_MAP 0 -#define GLIBTOP_SUID_NETINFO 0 -#define GLIBTOP_SUID_NETLOAD 0 -#define GLIBTOP_SUID_INTERFACE_NAMES 0 -#define GLIBTOP_SUID_PPP 0 - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/solaris/glibtop_suid.h b/sysdeps/solaris/glibtop_suid.h deleted file mode 100644 index 3923f034..00000000 --- a/sysdeps/solaris/glibtop_suid.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_SUID_H__ -#define __GLIBTOP_SUID_H__ - -BEGIN_LIBGTOP_DECLS - -static inline void glibtop_suid_enter (glibtop *server) { - setreuid (server->_priv->machine.uid, server->_priv->machine.euid); -}; - -static inline void glibtop_suid_leave (glibtop *server) { - if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid)) - _exit (1); -}; - -void -glibtop_init_p (glibtop *server, const unsigned long features, - const unsigned flags); -void -glibtop_open_p (glibtop *server, const char *program_name, - const unsigned long features, - const unsigned flags); - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/solaris/interfaces.c b/sysdeps/solaris/interfaces.c deleted file mode 100644 index ea4aa0e8..00000000 --- a/sysdeps/solaris/interfaces.c +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/interfaces.h> - -static const unsigned long _glibtop_sysdeps_interface_names = -(1L << GLIBTOP_INTERFACE_NAMES_NUMBER) + -(1L << GLIBTOP_INTERFACE_NAMES_SIZE); - -/* Init function. */ - -int -glibtop_init_interface_names_s (glibtop *server) -{ - server->sysdeps.interface_names = _glibtop_sysdeps_interface_names; - - return 0; -} - -/* Provides network statistics. */ - -glibtop_interface * -glibtop_get_interface_names_s (glibtop *server, glibtop_interface_names *buf, - u_int64_t interface, u_int64_t number, - u_int64_t instance, u_int64_t strategy) -{ - glibtop_init_s (&server, GLIBTOP_SYSDEPS_INTERFACE_NAMES, 0); - - memset (buf, 0, sizeof (glibtop_interface_names)); - - return NULL; -} diff --git a/sysdeps/solaris/loadavg.c b/sysdeps/solaris/loadavg.c deleted file mode 100644 index 154685f5..00000000 --- a/sysdeps/solaris/loadavg.c +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/loadavg.h> - -#ifdef HAVE_GETLOADAVG -#include <sys/loadavg.h> -#else -#include <assert.h> -#include <sys/param.h> -#include <kstat.h> -#endif - -static const unsigned long _glibtop_sysdeps_loadavg = -(1L << GLIBTOP_LOADAVG_LOADAVG); - -/* Init function. */ - -int -glibtop_init_loadavg_s (glibtop *server) -{ - server->sysdeps.loadavg = _glibtop_sysdeps_loadavg; - - return 0; -} - -/* Provides load average. */ - -int -glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) -{ -#ifndef HAVE_GETLOADAVG - kstat_ctl_t *kc; - kstat_t *ksp; - int i; - static char *avestrings[] = { "avenrun_1min", - "avenrun_5min", - "avenrun_15min" }; -#endif - memset (buf, 0, sizeof (glibtop_loadavg)); - -#ifdef HAVE_GETLOADAVG - if (getloadavg (buf->loadavg, 3) < 0) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; -#else - if(!(kc = server->_priv->machine.kc)) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - switch(kstat_chain_update(kc)) { - case -1: assert(0); /* Debugging, shouldn't happen */ - case 0: break; - default: glibtop_get_kstats(server); - } - if(!(ksp = server->_priv->machine.system)) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - if(kstat_read(kc, ksp, NULL) < 0) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - for(i = 0; i < 3; ++i) { /* Do we have a countof macro? */ - kstat_named_t *kn; - - kn = (kstat_named_t *)kstat_data_lookup(ksp, avestrings[i]); - if(kn) - buf->loadavg[i] = (double)kn->value.ul / FSCALE; - } -#endif - buf->flags = _glibtop_sysdeps_loadavg; - - return 0; -} diff --git a/sysdeps/solaris/mem.c b/sysdeps/solaris/mem.c deleted file mode 100644 index 08071ae4..00000000 --- a/sysdeps/solaris/mem.c +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/mem.h> - -#include <assert.h> -#include <unistd.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_mem_os_sysconf = -(1L << GLIBTOP_MEM_TOTAL); -static const unsigned long _glibtop_sysdeps_mem_os_kstat = -(1L << GLIBTOP_MEM_FREE) + (1L << GLIBTOP_MEM_USED) + -(1L << GLIBTOP_MEM_LOCKED); -static const unsigned long _glibtop_sysdeps_mem_bunyip = -(1L << GLIBTOP_MEM_SHARED) + (1L << GLIBTOP_MEM_BUFFER) + -(1L << GLIBTOP_MEM_USER); - -/* Init function. */ - -int -glibtop_init_mem_s (glibtop *server) -{ - server->sysdeps.mem = _glibtop_sysdeps_mem_os_sysconf + - _glibtop_sysdeps_mem_os_kstat + _glibtop_sysdeps_mem_bunyip; - - return 0; -} - -/* Provides information about memory usage. */ - -int -glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) -{ - kstat_ctl_t *kc = server->_priv->machine.kc; - kstat_t *ksp; - kstat_named_t *kn; - int pagesize = server->_priv->machine.pagesize; - -#ifndef KSTAT_DATA_UINT32 -#define ui32 ul -#endif - - memset (buf, 0, sizeof (glibtop_mem)); - - buf->total = (u_int64_t)sysconf(_SC_PHYS_PAGES) << pagesize << 10; - buf->flags = _glibtop_sysdeps_mem_os_sysconf; - - if(!kc) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - switch(kstat_chain_update(kc)) - { - case -1: assert(0); /* Debugging purposes, shouldn't happen */ - case 0: break; - default: glibtop_get_kstats(server); - } - - if((ksp = server->_priv->machine.syspages) && kstat_read(kc, ksp, NULL) >= 0) - { - kn = (kstat_named_t *)kstat_data_lookup(ksp, "pagesfree"); - if(kn) - { -#ifdef _LP64 - buf->free = kn->value.ui64 << pagesize << 10; -#else - buf->free = kn->value.ui32 << pagesize << 10; -#endif - buf->used = buf->total - buf->free; - } - kn = (kstat_named_t *)kstat_data_lookup(ksp, "pageslocked"); - if(kn) -#ifdef _LP64 - buf->locked = kn->value.ui64 << pagesize; -#else - buf->locked = kn->value.ui32 << pagesize; -#endif - buf->flags += _glibtop_sysdeps_mem_os_kstat; - } - - /* Bunyip module provides data in multiples of system page size */ - - if((ksp = server->_priv->machine.bunyip) && kstat_read(kc, ksp, NULL) >= 0) - { - kn = (kstat_named_t *)kstat_data_lookup(ksp, "pages_anon"); - if(kn) -#ifdef _LP64 - buf->user = kn->value.ui64 << pagesize << 10; -#else - buf->user = kn->value.ui32 << pagesize << 10; -#endif - kn = (kstat_named_t *)kstat_data_lookup(ksp, "pages_exec"); - if(kn) -#ifdef _LP64 - buf->shared = kn->value.ui64 << pagesize << 10; -#else - buf->shared = kn->value.ui32 << pagesize << 10; -#endif - kn = (kstat_named_t *)kstat_data_lookup(ksp, "pages_vnode"); - if(kn) -#ifdef _LP64 - buf->buffer = kn->value.ui64 << pagesize << 10; -#else - buf->buffer = kn->value.ui32 << pagesize << 10; -#endif - buf->flags += _glibtop_sysdeps_mem_bunyip; - } - - return 0; -} diff --git a/sysdeps/solaris/msg_limits.c b/sysdeps/solaris/msg_limits.c deleted file mode 100644 index 6542690f..00000000 --- a/sysdeps/solaris/msg_limits.c +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/msg_limits.h> - -#include <kvm.h> -#include <sys/msg.h> - -static struct nlist nlst[] = { {"msginfo"}, {NULL} }; -static const unsigned long _glibtop_sysdeps_msg_limits = -(1L << GLIBTOP_MSG_LIMITS_MSGPOOL) + (1L << GLIBTOP_MSG_LIMITS_MSGMAP) + -(1L << GLIBTOP_MSG_LIMITS_MSGMAX) + (1L << GLIBTOP_MSG_LIMITS_MSGMNB) + -(1L << GLIBTOP_MSG_LIMITS_MSGMNI) + (1L << GLIBTOP_MSG_LIMITS_MSGSSZ) + -(1L << GLIBTOP_MSG_LIMITS_MSGTQL); - -/* Init function. */ - -int -glibtop_init_msg_limits_p (glibtop *server) -{ - kvm_t *kd = server->_priv->machine.kd; - - if(kd && !kvm_nlist(kd, nlst)) - server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits; - else - server->sysdeps.msg_limits = 0; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf) -{ - kvm_t *kd = server->_priv->machine.kd; - struct msginfo minfo; - - memset (buf, 0, sizeof (glibtop_msg_limits)); - - if(!(server->sysdeps.msg_limits)) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - if(kvm_read(kd, nlst[0].n_value, (void *)&minfo, - sizeof(struct msginfo)) != sizeof(struct msginfo)) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - - buf->msgmap = minfo.msgmap; - buf->msgmax = minfo.msgmax; - buf->msgmnb = minfo.msgmnb; - buf->msgmni = minfo.msgmni; - buf->msgssz = minfo.msgssz; - buf->msgtql = minfo.msgtql; - buf->msgpool = minfo.msgmni * minfo.msgmnb >> 10; - buf->flags = _glibtop_sysdeps_msg_limits; - - return 0; -} diff --git a/sysdeps/solaris/netinfo.c b/sysdeps/solaris/netinfo.c deleted file mode 100644 index 16cfcec5..00000000 --- a/sysdeps/solaris/netinfo.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/netinfo.h> - -static const unsigned long _glibtop_sysdeps_netinfo = 0; - -/* Init function. */ - -int -glibtop_init_netinfo_s (glibtop *server) -{ - server->sysdeps.netinfo = _glibtop_sysdeps_netinfo; - - return 0; -} - -/* Provides network statistics. */ - -glibtop_ifaddr * -glibtop_get_netinfo_s (glibtop *server, glibtop_array *array, - glibtop_netinfo *buf, const char *interface, - u_int64_t transport) -{ - memset (buf, 0, sizeof (glibtop_netinfo)); - - return NULL; -} diff --git a/sysdeps/solaris/netload.c b/sysdeps/solaris/netload.c deleted file mode 100644 index 8f34d41b..00000000 --- a/sysdeps/solaris/netload.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/netload.h> - -static const unsigned long _glibtop_sysdeps_netload = 0; - -/* Init function. */ - -int -glibtop_init_netload_s (glibtop *server) -{ - server->sysdeps.netload = _glibtop_sysdeps_netload; - - return 0; -} - -/* Provides network statistics. */ - -int -glibtop_get_netload_s (glibtop *server, glibtop_netload *buf, - const char *interface, unsigned transport, - unsigned protocol) -{ - memset (buf, 0, sizeof (glibtop_netload)); - - return 0; -} diff --git a/sysdeps/solaris/open.c b/sysdeps/solaris/open.c deleted file mode 100644 index 5ee019ff..00000000 --- a/sysdeps/solaris/open.c +++ /dev/null @@ -1,235 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop/open.h> - -#include <unistd.h> -#include <dlfcn.h> -#include <sys/types.h> -#include <sys/processor.h> - -#include <glibtop_private.h> - -/* We need to call this when kstat_chain_update() returns new KID. - * In that case all kstat pointers and data are invalid, so we - * need to reread everything. The condition shouldn't happen very - * often. - */ - -void -glibtop_get_kstats(glibtop *server) -{ - kstat_ctl_t *kc = server->_priv->machine.kc; - kstat_t *ksp; - int nproc_same, new_ncpu; - - new_ncpu = sysconf(_SC_NPROCESSORS_CONF); - - if(!kc) - { - server->ncpu = new_ncpu; - server->_priv->machine.vminfo_kstat = NULL; - server->_priv->machine.system = NULL; - server->_priv->machine.syspages = NULL; - server->_priv->machine.bunyip = NULL; - return; - } - - do { - ksp = kstat_lookup(kc, "unix", -1, "vminfo"); - server->_priv->machine.vminfo_kstat = ksp; - if(ksp) - { - kstat_read(kc, ksp, &server->_priv->machine.vminfo); - /* Don't change snaptime if we only need to reinitialize kstats */ - if(!(server->_priv->machine.vminfo_snaptime)) - server->_priv->machine.vminfo_snaptime = ksp->ks_snaptime; - } - - /* We don't know why was kstat chain invalidated. It could have - been because the number of processors changed. The sysconf() - man page says that values returned won't change during the - life time of a process, but let's hope that's just an error in - the documentation. */ - - if((nproc_same = new_ncpu) == server->ncpu) - { - int checked, i; - char cpu[20]; - - for(i = 0, checked = 0; i < GLIBTOP_NCPU || checked == new_ncpu; ++i) - if(server->_priv->machine.cpu_stat_kstat[i]) - { - sprintf(cpu, "cpu_stat%d", i); - if(!(server->_priv->machine.cpu_stat_kstat[i] = - kstat_lookup(kc, "cpu_stat", -1, cpu))) - { - nproc_same = 0; - break; - } - ++checked; - } - } - if(!nproc_same) - { - processorid_t p; - int found; - char cpu[20]; - - if(new_ncpu > GLIBTOP_NCPU) - new_ncpu = GLIBTOP_NCPU; - server->ncpu = new_ncpu; - for(p = 0, found = 0; p < GLIBTOP_NCPU && found != new_ncpu; ++p) - { - if(p_online(p, P_STATUS) < 0) - { - server->_priv->machine.cpu_stat_kstat[p] = NULL; - continue; - } - sprintf(cpu, "cpu_stat%d", (int)p); - server->_priv->machine.cpu_stat_kstat[p] = - kstat_lookup(kc, "cpu_stat", -1, cpu); - ++found; - } - } - - server->_priv->machine.system = kstat_lookup(kc, "unix", -1, "system_misc"); - server->_priv->machine.syspages = kstat_lookup(kc, "unix", -1, "system_pages"); - server->_priv->machine.bunyip = kstat_lookup(kc, "bunyip", -1, "mempages"); - - } while(kstat_chain_update(kc) > 0 && - (new_ncpu = sysconf(_SC_NPROCESSORS_CONF))); - - /* We'll ignore -1 from kstat_chain_update here, since it really - shouldn't happen */ -} - -void -glibtop_open_s (glibtop *server, const char *program_name, - const unsigned long features, const unsigned flags) -{ - kstat_ctl_t *kc; - kstat_t *ksp; - kstat_named_t *kn; - int i, page; - void *dl; - - server->name = program_name; - - page = sysconf(_SC_PAGESIZE) >> 10; - for(i = 0; page; ++i, page >>= 1); - server->_priv->machine.pagesize = i - 1; - server->_priv->machine.ticks = sysconf(_SC_CLK_TCK); - server->_priv->machine.kc = kc = kstat_open (); - -#if 0 - for (ksp = server->_priv->machine.kc->kc_chain; ksp != NULL; ksp = ksp->ks_next) { - if (!strcmp (ksp->ks_class, "vm") && !strcmp (ksp->ks_name, "vminfo")) { - server->_priv->machine.vminfo_kstat = ksp; - kstat_read (server->_priv->machine.kc, ksp, &server->_priv->machine.vminfo); - server->_priv->machine.vminfo_snaptime = ksp->ks_snaptime; - continue; - } - - if (!strcmp (ksp->ks_class, "misc") && !strncmp (ksp->ks_name, "cpu_stat", 8)) { - int cpu; - - if ((sscanf (ksp->ks_name+8, "%d", &cpu) != 1) || (cpu > 63)) - continue; - - if (cpu >= server->ncpu) - server->ncpu = cpu+1; - - server->_priv->machine.cpu_stat_kstat [cpu] = ksp; - continue; - } - } - -#endif - - if (!kc) - glibtop_warn_io_r (server, "kstat_open ()"); - - server->ncpu = -1; /* Force processor detection */ - server->_priv->machine.vminfo_snaptime = 0; /* Force snaptime read */ - glibtop_get_kstats(server); - - server->_priv->machine.boot = 0; - if((ksp = server->_priv->machine.system) && kstat_read(kc, ksp, NULL) >= 0) - { - kn = (kstat_named_t *)kstat_data_lookup(ksp, "boot_time"); - if(kn) - switch(kn->data_type) - { -#ifdef KSTAT_DATA_INT32 - case KSTAT_DATA_INT32: server->_priv->machine.boot = kn->value.i32; - break; - case KSTAT_DATA_UINT32: server->_priv->machine.boot = kn->value.ui32; - break; - case KSTAT_DATA_INT64: server->_priv->machine.boot = kn->value.i64; - break; - case KSTAT_DATA_UINT64: server->_priv->machine.boot = kn->value.ui64; - break; -#else - case KSTAT_DATA_LONG: server->_priv->machine.boot = kn->value.l; - break; - case KSTAT_DATA_ULONG: server->_priv->machine.boot = kn->value.ul; - break; - case KSTAT_DATA_LONGLONG: server->_priv->machine.boot = kn->value.ll; - break; - case KSTAT_DATA_ULONGLONG: server->_priv->machine.boot = kn->value.ull; - break; -#endif - } - } - - /* Now let's have a bit of magic dust... */ - -#if GLIBTOP_SOLARIS_RELEASE >= 560 - - dl = dlopen("/usr/lib/libproc.so", RTLD_LAZY); - server->_priv->machine.libproc = dl; - if(dl) - { - void *func; - - func = dlsym(dl, "Pobjname"); /* Solaris 8 */ - if(!func) - func = dlsym(dl, "proc_objname"); /* Solaris 7 */ - server->_priv->machine.objname = (void (*) - (void *, uintptr_t, const char *, size_t))func; - server->_priv->machine.pgrab = (struct ps_prochandle *(*)(pid_t, int, int *)) - dlsym(dl, "Pgrab"); - server->_priv->machine.pfree = (void (*)(void *))dlsym(dl, "Pfree"); - } - else - { - server->_priv->machine.objname = NULL; - server->_priv->machine.pgrab = NULL; - server->_priv->machine.pfree = NULL; - } -#endif - server->_priv->machine.me = getpid(); -} diff --git a/sysdeps/solaris/open_suid.c b/sysdeps/solaris/open_suid.c deleted file mode 100644 index 3107f667..00000000 --- a/sysdeps/solaris/open_suid.c +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/open.h> - -#include <glibtop_suid.h> - -#include <unistd.h> -#include <sys/types.h> - -/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - -void -glibtop_init_p (glibtop *server, const unsigned long features, - const unsigned flags) -{ - glibtop_init_func_t *init_fkt; - - if (server == NULL) - glibtop_error_r (NULL, "glibtop_init_p (server == NULL)"); - - /* Do the initialization, but only if not already initialized. */ - - if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) { - glibtop_open_p (server, "glibtop", features, flags); - - for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++) - (*init_fkt) (server); - - server->flags |= _GLIBTOP_INIT_STATE_INIT; - } -} - -/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - -void -glibtop_open_p (glibtop *server, const char *program_name, - const unsigned long features, const unsigned flags) -{ - /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ - - server->name = program_name; - - server->_priv->machine.uid = getuid (); - server->_priv->machine.euid = geteuid (); - server->_priv->machine.gid = getgid (); - server->_priv->machine.egid = getegid (); - - server->_priv->machine.kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL); - if(!server->_priv->machine.kd) - glibtop_warn_io_r(server, "kvm_open()"); - - /* Drop priviledges; we only become root when necessary. - - setreuid (ruid, euid) - set real and effective user id; - setregid (rgid, egid) - set real and effective group id; - - */ - - if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid)) - _exit (1); - - if (setregid (server->_priv->machine.egid, server->_priv->machine.gid)) - _exit (1); - - /* !!! END OF SUID ROOT PART !!! */ - - /* Our effective uid is now those of the user invoking the server, - so we do no longer have any priviledges. - */ -} diff --git a/sysdeps/solaris/ppp.c b/sysdeps/solaris/ppp.c deleted file mode 100644 index a5cd1e0a..00000000 --- a/sysdeps/solaris/ppp.c +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/ppp.h> - -static const unsigned long _glibtop_sysdeps_ppp = 0; - -/* Init function. */ - -int -glibtop_init_ppp_s (glibtop *server) -{ - server->sysdeps.ppp = _glibtop_sysdeps_ppp; - - return 0; -} - -/* Provides PPP/ISDN information. */ - -int -glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, - unsigned short isdn) -{ - memset (buf, 0, sizeof (glibtop_ppp)); - - return 0; -} diff --git a/sysdeps/solaris/procargs.c b/sysdeps/solaris/procargs.c deleted file mode 100644 index 441d91ce..00000000 --- a/sysdeps/solaris/procargs.c +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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_private.h> - -static const unsigned long _glibtop_sysdeps_proc_args = -(1L << GLIBTOP_ARRAY_SIZE) + (1L << GLIBTOP_ARRAY_NUMBER); - -/* Init function. */ - -int -glibtop_init_proc_args_s (glibtop *server) -{ - server->sysdeps.proc_args = _glibtop_sysdeps_proc_args; - - return 0; -} - -/* Provides detailed information about a process. */ - -char ** -glibtop_get_proc_args_s (glibtop *server, glibtop_array *array, pid_t pid) -{ -#ifdef HAVE_PROCFS_H - struct psinfo pinfo; -#else - struct prpsinfo pinfo; -#endif - int retval, len, i, count; - char *ret, *p, **ptrlist; - - memset (array, 0, sizeof (glibtop_array)); - - retval = glibtop_get_proc_data_psinfo_s(server, &pinfo, pid); - if (retval) { - server->glibtop_errno = retval; - return NULL; - } - - for(len = 0; len < PRARGSZ; ++len) - if(!(pinfo.pr_psargs[len])) - break; - - ret = glibtop_malloc_r (server, len+1); - memcpy(ret, pinfo.pr_psargs, len); - ret[len] = 0; - - count = 0; - for(p = ret; *p; ++p) - if(*p == ' ') { - *p = 0; count++; - } - - ptrlist = glibtop_calloc_r(server, len+1, sizeof (char *)); - - for (i = 0, p = ret; i < count; i++) { - ptrlist [i] = glibtop_strdup_r (server, p); - p += strlen (p) + 1; - } - - ptrlist [count] = NULL; - - glibtop_free_r (server, ret); - - array->number = count; - array->size = sizeof (char *); - array->flags = _glibtop_sysdeps_proc_args; - - return ptrlist; -} diff --git a/sysdeps/solaris/procdata.c b/sysdeps/solaris/procdata.c deleted file mode 100644 index 555c0737..00000000 --- a/sysdeps/solaris/procdata.c +++ /dev/null @@ -1,268 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop_private.h> -#include <glibtop/procuid.h> - -#include <errno.h> - -#include <glibtop_private.h> - -/* - * The differences between old and new procfs API are: - * - old has '/proc/<pid>' file and ioctl() is used to obtain the data. - * - new has '/proc/<pid>/*' files and read() & friends are used to - * obtain the data. - * - names of structures and members are different. It's mostly the - * prefix. Old uses `pr' and new uses `ps'. - * - * Since almost every line would be in #ifdef, I think it would - * be more readable to just copy everything twice. This is not a big - * file, after all. - */ - -#ifdef HAVE_PROCFS_H - -/* Read /proc/<pid>/psinfo. */ - -int -glibtop_get_proc_data_psinfo_s (glibtop *server, struct psinfo *psinfo, pid_t pid) -{ - int fd; - char buffer [BUFSIZ]; - - sprintf (buffer, "/proc/%d/psinfo", (int) pid); - fd = s_open (buffer, O_RDONLY); - if (fd < 0) { - glibtop_warn_io_r (server, "open (%s)", buffer); - return -1; - } - - if (s_pread (fd, psinfo, sizeof (struct psinfo), 0) != - sizeof (struct psinfo)) - { - s_close (fd); - glibtop_warn_io_r (server, "pread (%s)", buffer); - return -1; - } - - s_close (fd); - return 0; -} - -int -glibtop_get_proc_data_usage_s (glibtop *server, struct prusage *prusage, pid_t pid) -{ - int fd; - char buffer [BUFSIZ]; - - sprintf (buffer, "/proc/%d/usage", (int) pid); - fd = s_open (buffer, O_RDONLY); - if (fd < 0) { - glibtop_warn_io_r (server, "open (%s)", buffer); - return -1; - } - - if (s_pread (fd, prusage, sizeof (struct prusage), 0) != - sizeof (struct prusage)) - { - s_close (fd); - glibtop_warn_io_r (server, "pread (%s)", buffer); - return -1; - } - - s_close (fd); - return 0; -} - -int -glibtop_get_proc_credentials_s(glibtop *server, - struct prcred *prcred, - gid_t *groups, - pid_t pid) -{ - int fd; - size_t toread; - char buffer[BUFSIZ]; - - sprintf(buffer, "/proc/%d/cred", (int)pid); - if((fd = s_open(buffer, O_RDONLY)) < 0) - { - if(errno != EPERM && errno != EACCES) - glibtop_warn_io_r(server, "open (%s)", buffer); - return -1; - } - if(s_pread(fd, prcred, sizeof(struct prcred), 0) != - sizeof(struct prcred)) - { - s_close(fd); - glibtop_warn_io_r(server, "pread (%s)", buffer); - return -1; - } - if(prcred->pr_ngroups >= 0) - { - if(prcred->pr_ngroups <= GLIBTOP_MAX_GROUPS) - toread = prcred->pr_ngroups * sizeof(gid_t); - else - toread = GLIBTOP_MAX_GROUPS * sizeof(gid_t); - if(s_pread(fd, groups, toread, - (off_t)&(((struct prcred *)0)->pr_groups[0])) != toread) - prcred->pr_ngroups = 0; - } - s_close(fd); - return 0; -} - -int -glibtop_get_proc_status_s(glibtop *server, struct pstatus *pstatus, pid_t pid) -{ - int fd; - char buffer[BUFSIZ]; - - sprintf(buffer, "/proc/%d/status", (int)pid); - if((fd = s_open(buffer, O_RDONLY)) < 0) - { - if(errno != EPERM && errno != EACCES) - glibtop_warn_io_r(server, "open (%s)", buffer); - return -1; - } - if(s_pread(fd, pstatus, sizeof(struct pstatus), 0) != - sizeof(struct pstatus)) - { - s_close(fd); - glibtop_warn_io_r(server, "pread (%s)", buffer); - return -1; - } - s_close(fd); - return 0; -} - -#else /* old API */ - -int -glibtop_get_proc_data_psinfo_s (glibtop *server, - struct prpsinfo *psinfo, - pid_t pid) -{ - int fd; - char buffer [BUFSIZ]; - - sprintf (buffer, "/proc/%d", (int) pid); - fd = s_open (buffer, O_RDONLY); - if (fd < 0) { - if(errno != EPERM && errno != EACCES) - glibtop_warn_io_r (server, "open (%s)", buffer); - return -1; - } - - if(ioctl(fd, PIOCPSINFO, psinfo) < 0) - { - s_close (fd); - glibtop_warn_io_r (server, "ioctl(%s, PIOCPSINFO)", buffer); - return -1; - } - - s_close (fd); - return 0; -} - -int -glibtop_get_proc_data_usage_s (glibtop *server, - struct prusage *prusage, - pid_t pid) -{ - int fd; - char buffer [BUFSIZ]; - - sprintf (buffer, "/proc/%d", (int) pid); - fd = s_open (buffer, O_RDONLY); - if (fd < 0) { - if(errno != EPERM && errno != EACCES) - glibtop_warn_io_r (server, "open (%s)", buffer); - return -1; - } - - if(ioctl(fd, PIOCUSAGE, prusage) < 0) - { - s_close (fd); - glibtop_warn_io_r (server, "ioctl(%s, PIOCUSAGE)", buffer); - return -1; - } - - s_close (fd); - return 0; -} - -int -glibtop_get_proc_credentials_s(glibtop *server, - struct prcred *prcred, - gid_t *groups, - pid_t pid) -{ - int fd; - size_t toread; - char buffer[BUFSIZ]; - - sprintf(buffer, "/proc/%d", (int)pid); - if((fd = s_open(buffer, O_RDONLY)) < 0) - { - if(errno != EPERM && errno != EACCES) - glibtop_warn_io_r(server, "open (%s)", buffer); - return -1; - } - if(ioctl(fd, PIOCCRED, prcred) < 0) - { - s_close(fd); - glibtop_warn_io_r(server, "ioctl(%s, PIOCCRED)", buffer); - return -1; - } - s_close(fd); - return 0; -} - -int -glibtop_get_proc_status_s(glibtop *server, struct prstatus *pstatus, pid_t pid) -{ - int fd; - char buffer[BUFSIZ]; - - sprintf(buffer, "/proc/%d", (int)pid); - if((fd = s_open(buffer, O_RDONLY)) < 0) - { - if(errno != EPERM && errno != EACCES) - glibtop_warn_io_r(server, "open (%s)", buffer); - return -1; - } - if(ioctl(fd, PIOCSTATUS, pstatus) < 0) - { - s_close(fd); - glibtop_warn_io_r(server, "ioctl(%s, PIOCSTATUS)", buffer); - return -1; - } - s_close(fd); - return 0; -} -#endif diff --git a/sysdeps/solaris/prockernel.c b/sysdeps/solaris/prockernel.c deleted file mode 100644 index c596a532..00000000 --- a/sysdeps/solaris/prockernel.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/prockernel.h> - -static const unsigned long _glibtop_sysdeps_proc_kernel = 0; - -/* Init function. */ - -int -glibtop_init_proc_kernel_s (glibtop *server) -{ - server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, - pid_t pid) -{ - memset (buf, 0, sizeof (glibtop_proc_kernel)); - - return 0; -} diff --git a/sysdeps/solaris/proclist.c b/sysdeps/solaris/proclist.c deleted file mode 100644 index 5c89213e..00000000 --- a/sysdeps/solaris/proclist.c +++ /dev/null @@ -1,259 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/proclist.h> -#include <glibtop/xmalloc.h> - -#include <sys/stat.h> -#include <unistd.h> -#include <dirent.h> -#include <ctype.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proclist = -(1L << GLIBTOP_ARRAY_TOTAL) + (1L << GLIBTOP_ARRAY_NUMBER) + -(1L << GLIBTOP_ARRAY_SIZE); - -/* Init function. */ - -int -glibtop_init_proclist_s (glibtop *server) -{ - server->sysdeps.proclist = _glibtop_sysdeps_proclist; - - return 0; -} - -#define BLOCK_COUNT 256 -#define BLOCK_SIZE (BLOCK_COUNT * sizeof (unsigned)) - -/* Fetch list of currently running processes. - * - * IMPORTANT NOTE: - * On error, this function MUST return NULL and set buf->flags to zero ! - * On success, it returnes a pointer to a list of buf->number elements - * each buf->size big. The total size is stored in buf->total. */ - -unsigned * -glibtop_get_proclist_s (glibtop *server, glibtop_array *array, - int64_t which, int64_t arg) -{ - DIR *proc; - struct dirent *entry; - char buffer [BUFSIZ]; - unsigned count, total, pid, mask; - unsigned pids [BLOCK_COUNT], *pids_chain = NULL; - unsigned pids_size = 0, pids_offset = 0, new_size; - struct stat statb; - int len, ok; - - memset (array, 0, sizeof (glibtop_array)); - mask = which & ~GLIBTOP_KERN_PROC_MASK; - which &= GLIBTOP_KERN_PROC_MASK; - - /* Check if the user wanted only one process */ - - if(which == GLIBTOP_KERN_PROC_PID) { - pid = arg; - - if(mask) { -#ifdef HAVE_PROCFS_H - struct psinfo psinfo; -#else - struct prpsinfo psinfo; -#endif - if(glibtop_get_proc_data_psinfo_s(server, &psinfo, pid)) - return NULL; - if(mask & GLIBTOP_EXCLUDE_IDLE && !psinfo.pr_pctcpu) - return NULL; - if(mask & GLIBTOP_EXCLUDE_SYSTEM && psinfo.pr_flag & SSYS) - return NULL; - if(mask & GLIBTOP_EXCLUDE_NOTTY && psinfo.pr_ttydev == PRNODEV) - return NULL; - } else { - sprintf(buffer, "/proc/%ld", (long)arg); - if(s_stat(buffer, &statb) < 0) - return NULL; - } - if(!(pids_chain = glibtop_calloc_r(server, 1, sizeof(unsigned)))) - return NULL; - *pids_chain = pid; - array->number = 1; - array->size = sizeof(unsigned); - array->total = array->number * array->size; - array->flags = _glibtop_sysdeps_proclist; - return pids_chain; - } - - proc = opendir ("/proc"); - if (!proc) return NULL; - - /* read every every entry in /proc */ - - for (count = total = 0, entry = readdir (proc); - entry; entry = readdir (proc)) { - ok = 1; len = strlen (entry->d_name); - - /* does it consist entirely of digits? */ -#if 0 - /* It does, except for "." and "..". Let's speed up */ - - for (i = 0; i < len; i++) - if (!isdigit (entry->d_name [i])) ok = 0; - if (!ok) continue; -#else - if(entry->d_name[0] == '.') - continue; -#endif - - /* convert it in a number */ -#if 0 - if (sscanf (entry->d_name, "%u", &pid) != 1) continue; -#else - pid = (unsigned)atol(entry->d_name); -#endif - -#ifdef HAVE_PROCFS_H - - /* Can we skip it based on the request? We have - RUID and RGID in struct stat. But we can't do it - like this for LP64 process, because stat() will fail. - XXX Unimplemented for now */ - - if(!mask && which == GLIBTOP_KERN_PROC_RUID) { - sprintf (buffer, "/proc/%d", pid); - if (s_stat (buffer, &statb)) continue; - - if (!S_ISDIR (statb.st_mode)) continue; - - if(statb.st_uid != arg) continue; - } - - if(mask || which != GLIBTOP_KERN_PROC_ALL) { - struct psinfo psinfo; - - if(glibtop_get_proc_data_psinfo_s(server, &psinfo, pid)) - continue; - if(mask) { - if(mask & GLIBTOP_EXCLUDE_IDLE && !psinfo.pr_pctcpu) - continue; - if(mask & GLIBTOP_EXCLUDE_SYSTEM && psinfo.pr_flag & SSYS) - continue; - if(mask & GLIBTOP_EXCLUDE_NOTTY - && psinfo.pr_ttydev == PRNODEV) - continue; - } - switch(which) { - case GLIBTOP_KERN_PROC_PGRP: - if(psinfo.pr_pgid != arg) - continue; - break; - case GLIBTOP_KERN_PROC_SESSION: - if(psinfo.pr_sid != arg) - continue; - break; - case GLIBTOP_KERN_PROC_TTY: - if(psinfo.pr_ttydev != arg) - continue; - break; - case GLIBTOP_KERN_PROC_UID: - if(psinfo.pr_euid != arg) - continue; - break; - case GLIBTOP_KERN_PROC_RUID: - if(psinfo.pr_uid != arg) - continue; - break; - default: - break; - } - } -#endif - /* Fine. Now we first try to store it in pids. If this buffer is - * full, we copy it to the pids_chain. */ - - if (count >= BLOCK_COUNT) { - /* The following call to glibtop_realloc will be - * equivalent to glibtop_malloc () if `pids_chain' is - * NULL. We just calculate the new size and copy `pids' - * to the beginning of the newly allocated block. */ - - new_size = pids_size + BLOCK_SIZE; - - pids_chain = glibtop_realloc_r - (server, pids_chain, new_size); - - memcpy (pids_chain + pids_offset, pids, BLOCK_SIZE); - - pids_size = new_size; - - pids_offset += BLOCK_COUNT; - - count = 0; - } - - /* pids is now big enough to hold at least one single pid. */ - - pids [count++] = pid; - - total++; - } - - s_closedir (proc); - - /* count is only zero if an error occured (one a running Linux system, - * we have at least one single process). */ - - if (!count) return NULL; - - /* The following call to glibtop_realloc will be equivalent to - * glibtop_malloc if pids_chain is NULL. We just calculate the - * new size and copy pids to the beginning of the newly allocated - * block. */ - - new_size = pids_size + count * sizeof (unsigned); - - pids_chain = glibtop_realloc_r (server, pids_chain, new_size); - - memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned)); - - pids_size = new_size; - - pids_offset += BLOCK_COUNT; - - /* Since everything is ok now, we can set array->flags, fill in the - * remaining fields and return the `pids_chain'. */ - - array->flags = _glibtop_sysdeps_proclist; - - array->size = sizeof (unsigned); - array->number = total; - - array->total = array->number * array->size; - - return pids_chain; -} diff --git a/sysdeps/solaris/procmap.c b/sysdeps/solaris/procmap.c deleted file mode 100644 index b77720e1..00000000 --- a/sysdeps/solaris/procmap.c +++ /dev/null @@ -1,199 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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> - -#include <errno.h> -#include <alloca.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_map = -(1L << GLIBTOP_ARRAY_NUMBER) + (1L << GLIBTOP_ARRAY_TOTAL) + -(1L << GLIBTOP_ARRAY_SIZE); - -static const unsigned long _glibtop_sysdeps_map_entry = -(1L << GLIBTOP_MAP_ENTRY_START) + (1L << GLIBTOP_MAP_ENTRY_END) + -(1L << GLIBTOP_MAP_ENTRY_OFFSET) + (1L << GLIBTOP_MAP_ENTRY_PERM); -static const unsigned long _glibtop_sysdeps_map_device = -(1L << GLIBTOP_MAP_ENTRY_DEVICE) + (1L << GLIBTOP_MAP_ENTRY_INODE); - -/* Init function. */ - -int -glibtop_init_proc_map_s (glibtop *server) -{ - server->sysdeps.proc_map = _glibtop_sysdeps_proc_map; - - return 0; -} - -/* Provides detailed information about a process. */ - -glibtop_map_entry * -glibtop_get_proc_map_s (glibtop *server, glibtop_array *array, pid_t pid) -{ - int fd, i, nmaps, pr_err, heap; -#if GLIBTOP_SOLARIS_RELEASE >= 560 - prxmap_t *maps; - struct ps_prochandle *Pr = NULL; -#else - prmap_t *maps; -#endif - - /* A few defines, to make it shorter down there */ - -#ifdef HAVE_PROCFS_H -# define OFFSET pr_offset -#else -# define OFFSET pr_off -#endif - - glibtop_map_entry *entry; - struct stat inode; - char buffer[BUFSIZ]; - - memset (array, 0, sizeof (glibtop_array)); - -#ifdef HAVE_PROCFS_H - sprintf(buffer, "/proc/%d/xmap", (int)pid); -#else - sprintf(buffer, "/proc/%d", (int)pid); -#endif - if((fd = s_open(buffer, O_RDONLY)) < 0) { - if(errno != EPERM && errno != EACCES) - glibtop_warn_io_r(server, "open (%s)", buffer); - return NULL; - } -#ifdef HAVE_PROCFS_H - if(fstat(fd, &inode) < 0) { - if(errno != EOVERFLOW) - glibtop_warn_io_r(server, "fstat (%s)", buffer); - /* else call daemon for 64-bit support */ - s_close(fd); - return NULL; - } - maps = alloca(inode.st_size); - nmaps = inode.st_size / sizeof(prxmap_t); - if(s_pread(fd, maps, inode.st_size, 0) != inode.st_size) { - glibtop_warn_io_r(server, "pread (%s)", buffer); - s_close(fd); - return NULL; - } -#else - if(ioctl(fd, PIOCNMAP, &nmaps) < 0) { - glibtop_warn_io_r(server, "ioctl(%s, PIOCNMAP)", buffer); - s_close(fd); - return NULL; - } - maps = alloca((nmaps + 1) * sizeof(prmap_t)); - if(ioctl(fd, PIOCMAP, maps) < 0) { - glibtop_warn_io_r(server, "ioctl(%s, PIOCMAP)", buffer); - s_close(fd); - return NULL; - } -#endif - if(!(entry = glibtop_malloc_r(server, - nmaps * sizeof(glibtop_map_entry)))) - return NULL; - array->number = nmaps; - array->size = sizeof(glibtop_map_entry); - array->total = nmaps * sizeof(glibtop_map_entry); - - memset(entry, 0, nmaps * sizeof(glibtop_map_entry)); - -#if GLIBTOP_SOLARIS_RELEASE >= 560 - - if(server->_priv->machine.objname && server->_priv->machine.pgrab && - server->_priv->machine.pfree) - Pr = (server->_priv->machine.pgrab)(pid, 1, &pr_err); -#endif - for(heap = 0,i = 0; i < nmaps; ++i) { - int len; - - entry[i].start = maps[i].pr_vaddr; - entry[i].end = maps[i].pr_vaddr + maps[i].pr_size; - -#if GLIBTOP_SOLARIS_RELEASE >= 560 - - if(maps[i].pr_dev != PRNODEV) { - entry[i].device = maps[i].pr_dev; - entry[i].inode = maps[i].pr_ino; - entry[i].flags |= _glibtop_sysdeps_map_device; - } -#endif - entry[i].offset = maps[i].OFFSET; - if(maps[i].pr_mflags & MA_READ) - entry[i].perm |= GLIBTOP_MAP_PERM_READ; - if(maps[i].pr_mflags & MA_WRITE) - entry[i].perm |= GLIBTOP_MAP_PERM_WRITE; - if(maps[i].pr_mflags & MA_EXEC) - entry[i].perm |= GLIBTOP_MAP_PERM_EXECUTE; - if(maps[i].pr_mflags & MA_SHARED) - entry[i].perm |= GLIBTOP_MAP_PERM_SHARED; - else - entry[i].perm |= GLIBTOP_MAP_PERM_PRIVATE; - entry[i].flags = _glibtop_sysdeps_map_entry; - -#if GLIBTOP_SOLARIS_RELEASE >= 560 - - if(maps[i].pr_mflags & MA_ANON) { - if(!heap) { - ++heap; - strcpy(entry[i].filename, "[ heap ]"); - } else { - if(i == nmaps - 1) - strcpy(entry[i].filename, "[ stack ]"); - else - strcpy(entry[i].filename, "[ anon ]"); - } - entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME); - } else { - if(Pr) { - server->_priv->machine.objname(Pr, maps[i].pr_vaddr, buffer, - BUFSIZ); - if((len = resolvepath(buffer, entry[i].filename, - GLIBTOP_MAP_FILENAME_LEN)) > 0) { - entry[i].filename[len] = 0; - entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME); - } - } - } -#endif - } - -#if GLIBTOP_SOLARIS_RELEASE >= 560 - if(Pr) - server->_priv->machine.pfree(Pr); -#endif - - array->flags = _glibtop_sysdeps_proc_map; - s_close(fd); - return entry; -} diff --git a/sysdeps/solaris/procmem.c b/sysdeps/solaris/procmem.c deleted file mode 100644 index eabe3dca..00000000 --- a/sysdeps/solaris/procmem.c +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procmem.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_mem = -(1L << GLIBTOP_PROC_MEM_SIZE) + (1L << GLIBTOP_PROC_MEM_VSIZE) + -(1L << GLIBTOP_PROC_MEM_RESIDENT) + (1L << GLIBTOP_PROC_MEM_RSS); - -/* Init function. */ - -int -glibtop_init_proc_mem_s (glibtop *server) -{ - server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) -{ -#ifdef HAVE_PROCFS_H - struct psinfo psinfo; -#else - struct prpsinfo psinfo; - int pagesize = server->_priv->machine.pagesize; -#endif - int retval; - - memset (buf, 0, sizeof (glibtop_proc_mem)); - - retval = glibtop_get_proc_data_psinfo_s(server, &psinfo, pid); - if (retval) return retval; - -#ifdef HAVE_PROCFS_H - buf->size = buf->vsize = psinfo.pr_size << 10; - buf->resident = buf->rss = psinfo.pr_rssize << 10; -#else - buf->size = buf->vsize = psinfo.pr_size << pagesize << 10; - buf->resident = buf->rss = psinfo.pr_rssize << pagesize << 10; -#endif - buf->flags = _glibtop_sysdeps_proc_mem; - - return 0; -} diff --git a/sysdeps/solaris/procsegment.c b/sysdeps/solaris/procsegment.c deleted file mode 100644 index aab29e9e..00000000 --- a/sysdeps/solaris/procsegment.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procsegment.h> - -static const unsigned long _glibtop_sysdeps_proc_segment = 0; - -/* Init function. */ - -int -glibtop_init_proc_segment_s (glibtop *server) -{ - server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, - pid_t pid) -{ - memset (buf, 0, sizeof (glibtop_proc_segment)); - - return 0; -} diff --git a/sysdeps/solaris/procsignal.c b/sysdeps/solaris/procsignal.c deleted file mode 100644 index 47754261..00000000 --- a/sysdeps/solaris/procsignal.c +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procsignal.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_signal = -(1L << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1L << GLIBTOP_PROC_SIGNAL_BLOCKED); - -/* Init function. */ - -int -glibtop_init_proc_signal_s (glibtop *server) -{ - server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, - pid_t pid) -{ -#ifdef HAVE_PROCFS_H - struct pstatus pstatus; -#else - struct prstatus pstatus; -#endif - int retval, size; - - memset (buf, 0, sizeof (glibtop_proc_signal)); - - retval = glibtop_get_proc_status_s(server, &pstatus, pid); - if (retval) return retval; - - if(sizeof(buf->signal) < sizeof(sigset_t)) - size = sizeof(buf->signal); - else - size = sizeof(sigset_t); - - memcpy(buf->signal, &pstatus.pr_sigpend, size); -#ifdef HAVE_PROCFS_H - memcpy(buf->blocked, &pstatus.pr_lwp.pr_lwphold, size); -#else - memcpy(buf->blocked, &pstatus.pr_lwppend, size); -#endif - - /* Technically, most of this is meaningless on a process level, - but this should be a good enough approximation. */ - - buf->flags = _glibtop_sysdeps_proc_signal; - - return 0; -} diff --git a/sysdeps/solaris/procstate.c b/sysdeps/solaris/procstate.c deleted file mode 100644 index faeae9cd..00000000 --- a/sysdeps/solaris/procstate.c +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procstate.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_state = -#ifdef HAVE_PROCFS_H -(1L << GLIBTOP_PROC_STATE_HAS_CPU) + (1L << GLIBTOP_PROC_STATE_PROCESSOR) + -(1L << GLIBTOP_PROC_STATE_LAST_PROCESSOR) + -#endif -(1L << GLIBTOP_PROC_STATE_CMD) + (1L << GLIBTOP_PROC_STATE_STATE) + -(1L << GLIBTOP_PROC_STATE_UID) + (1L << GLIBTOP_PROC_STATE_GID) + -(1L << GLIBTOP_PROC_STATE_RUID) + (1L << GLIBTOP_PROC_STATE_RGID); - -/* Init function. */ - -int -glibtop_init_proc_state_s (glibtop *server) -{ - server->sysdeps.proc_state = _glibtop_sysdeps_proc_state; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) -{ -#ifdef HAVE_PROCFS_H - struct psinfo psinfo; -#else - struct prpsinfo psinfo; -#endif - unsigned state; - int retval; - - memset (buf, 0, sizeof (glibtop_proc_state)); - - retval = glibtop_get_proc_data_psinfo_s (server, &psinfo, pid); - if (retval) return retval; - - buf->uid = psinfo.pr_euid; - buf->gid = psinfo.pr_egid; - buf->ruid = psinfo.pr_uid; - buf->rgid = psinfo.pr_gid; - -#ifdef HAVE_PROCFS_H - state = psinfo.pr_lwp.pr_state; -#else - state = psinfo.pr_state; -#endif - switch(state) { - case SONPROC: -#ifdef HAVE_PROCFS_H - buf->has_cpu = 1; - buf->processor = psinfo.pr_lwp.pr_onpro; -#endif - break; - case SRUN: - buf->state = GLIBTOP_PROCESS_RUNNING; - break; - case SZOMB: - buf->state = GLIBTOP_PROCESS_ZOMBIE; - break; - case SSLEEP: - buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE; - break; - case SSTOP: - buf->state = GLIBTOP_PROCESS_STOPPED; - break; - case SIDL: - buf->state = GLIBTOP_PROCESS_UNINTERRUPTIBLE; - } -#ifdef HAVE_PROCFS_H - buf->last_processor = psinfo.pr_lwp.pr_onpro; -#endif - strncpy (buf->cmd, psinfo.pr_fname, 39); - - buf->flags = _glibtop_sysdeps_proc_state; - - return 0; -} diff --git a/sysdeps/solaris/proctime.c b/sysdeps/solaris/proctime.c deleted file mode 100644 index acbbb96e..00000000 --- a/sysdeps/solaris/proctime.c +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/proctime.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_time = -(1L << GLIBTOP_PROC_TIME_START_TIME) + (1L << GLIBTOP_PROC_TIME_RTIME) + -(1L << GLIBTOP_PROC_TIME_UTIME) + (1L << GLIBTOP_PROC_TIME_STIME); - -/* Init function. */ - -int -glibtop_init_proc_time_s (glibtop *server) -{ - server->sysdeps.proc_time = _glibtop_sysdeps_proc_time; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, - pid_t pid) -{ - struct prusage prusage; - int retval; - - memset (buf, 0, sizeof (glibtop_proc_time)); - - /* Don't do it for scheduler, we don't want to frighten our users */ - - if (!pid) - return -GLIBTOP_ERROR_INVALID_ARGUMENT; - - retval = glibtop_get_proc_data_usage_s (server, &prusage, pid); - if (retval) return retval; - - buf->start_time = prusage.pr_create.tv_sec; - - buf->rtime = prusage.pr_rtime.tv_sec * 1E+6 + - prusage.pr_rtime.tv_nsec / 1E+3; - buf->utime = prusage.pr_utime.tv_sec * 1E+6 + - prusage.pr_utime.tv_nsec / 1E+3; - buf->stime = prusage.pr_stime.tv_sec * 1E+6 + - prusage.pr_stime.tv_nsec / 1E+3; - - buf->flags = _glibtop_sysdeps_proc_time; - - return 0; -} diff --git a/sysdeps/solaris/procuid.c b/sysdeps/solaris/procuid.c deleted file mode 100644 index 7ae444cf..00000000 --- a/sysdeps/solaris/procuid.c +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procuid.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_proc_uid_psinfo = -(1L << GLIBTOP_PROC_UID_EUID) + (1L << GLIBTOP_PROC_UID_UID) + -(1L << GLIBTOP_PROC_UID_EGID) + (1L << GLIBTOP_PROC_UID_GID) + -(1L << GLIBTOP_PROC_UID_PID) + (1L << GLIBTOP_PROC_UID_PPID) + -(1L << GLIBTOP_PROC_UID_PGRP) + (1L << GLIBTOP_PROC_UID_SESSION) + -(1L << GLIBTOP_PROC_UID_TTY) + (1L << GLIBTOP_PROC_UID_PRIORITY) + -(1L << GLIBTOP_PROC_UID_NICE); -static const unsigned long _glibtop_sysdeps_proc_uid_prcred = -#ifdef HAVE_PROCFS_H -(1L << GLIBTOP_PROC_UID_GROUPS) + -#endif -(1L << GLIBTOP_PROC_UID_SUID) + (1L << GLIBTOP_PROC_UID_SGID) + -(1L << GLIBTOP_PROC_UID_NGROUPS); -/* Init function. */ - -int -glibtop_init_proc_uid_s (glibtop *server) -{ - server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid_psinfo + - _glibtop_sysdeps_proc_uid_prcred; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) -{ - struct prcred prcred; -#ifdef HAVE_PROCFS_H - struct psinfo psinfo; - gid_t groups[GLIBTOP_MAX_GROUPS]; -#else - struct prpsinfo psinfo; - gid_t groups[1]; /* dummy for consistent function prototype */ -#endif - int retval; - - memset (buf, 0, sizeof (glibtop_proc_uid)); - - retval = glibtop_get_proc_data_psinfo_s (server, &psinfo, pid); - if (retval) return retval; - - buf->euid = psinfo.pr_euid; - buf->uid = psinfo.pr_uid; - buf->egid = psinfo.pr_egid; - buf->gid = psinfo.pr_gid; - - buf->pid = psinfo.pr_pid; - buf->ppid = psinfo.pr_ppid; -#ifdef HAVE_PROCFS_H - buf->pgrp = psinfo.pr_pgid; -#else - buf->pgrp = psinfo.pr_pgrp; -#endif - - buf->session = psinfo.pr_sid; - buf->tty = psinfo.pr_ttydev; - -#ifdef HAVE_PROCFS_H - buf->priority = psinfo.pr_lwp.pr_pri; - buf->nice = psinfo.pr_lwp.pr_nice - NZERO; -#else - buf->priority = psinfo.pr_pri; - buf->nice = psinfo.pr_nice - NZERO; -#endif - - buf->flags = _glibtop_sysdeps_proc_uid_psinfo; - - retval = glibtop_get_proc_credentials_s(server, &prcred, groups, pid); - if (retval) return retval; - - buf->suid = prcred.pr_suid; - buf->sgid = prcred.pr_sgid; - buf->ngroups = (prcred.pr_ngroups <= GLIBTOP_MAX_GROUPS) ? - prcred.pr_ngroups : GLIBTOP_MAX_GROUPS; - -#ifdef HAVE_PROCFS_H - if(sizeof(int) == sizeof(gid_t)) - memcpy(buf->groups, &groups, buf->ngroups * sizeof(gid_t)); - else { - int i; - - for(i = 0; i < buf->ngroups; ++i) - buf->groups[i] = groups[i]; - } -#endif - - buf->flags |= _glibtop_sysdeps_proc_uid_prcred; - - return 0; -} diff --git a/sysdeps/solaris/safeio.c b/sysdeps/solaris/safeio.c deleted file mode 100644 index 6085f09c..00000000 --- a/sysdeps/solaris/safeio.c +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* Copyright (C) 1999 Drazen Kacar - This file is part of LibGTop 1.0. - - Contributed by Drazen Kacar <dave@srce.hr>, May 1999. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <unistd.h> -#include <fcntl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <dirent.h> -#include <errno.h> - -#include <glibtop_private.h> - -int -s_open(const char *file, int mode) -{ - int fd; - - do { - fd = open(file, mode); - } while(fd < 0 && errno == EINTR); - return fd; -} - -int -s_stat(const char *path, struct stat *buf) -{ - int status; - - do { - status = stat(path, buf); - } while(status < 0 && errno == EINTR); - return status; -} - -int -s_close(int fd) -{ - int status; - - do { - status = close(fd); - } while(status < 0 && errno == EINTR); - return status; -} - -ssize_t -s_pread(int fd, void *buf, size_t nbytes, off_t offset) -{ - ssize_t len; - - /* Now, why doesn't the pread(2) man page say anything about pread() - return values? Can it read less bytes than requested? */ - - do { - len = pread(fd, buf, nbytes, offset); - } while(len < 0 && errno == EINTR); - return len; -} - -int s_closedir(DIR *dirp) -{ - int status; - - do { - status = closedir(dirp); - } while(status < 0 && errno == EINTR); - return status; -} diff --git a/sysdeps/solaris/sem_limits.c b/sysdeps/solaris/sem_limits.c deleted file mode 100644 index 1d747bc6..00000000 --- a/sysdeps/solaris/sem_limits.c +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/sem_limits.h> - -#include <kvm.h> -#include <sys/sem.h> - -static struct nlist nlst[] = { {"seminfo"}, {NULL} }; -static const unsigned long _glibtop_sysdeps_sem_limits = -(1L << GLIBTOP_SEM_LIMITS_SEMMAP) + (1L << GLIBTOP_SEM_LIMITS_SEMMNI) + -(1L << GLIBTOP_SEM_LIMITS_SEMMNS) + (1L << GLIBTOP_SEM_LIMITS_SEMMNU) + -(1L << GLIBTOP_SEM_LIMITS_SEMMSL) + (1L << GLIBTOP_SEM_LIMITS_SEMOPM) + -(1L << GLIBTOP_SEM_LIMITS_SEMUME) + (1L << GLIBTOP_SEM_LIMITS_SEMUSZ) + -(1L << GLIBTOP_SEM_LIMITS_SEMVMX) + (1L << GLIBTOP_SEM_LIMITS_SEMAEM); - -/* Init function. */ - -int -glibtop_init_sem_limits_p (glibtop *server) -{ - kvm_t *kd = server->_priv->machine.kd; - - if(kd && !kvm_nlist(kd, nlst)) - server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits; - else - server->sysdeps.sem_limits = 0; - - return 0; -} - -/* Provides information about sysv sem limits. */ - -int -glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf) -{ - kvm_t *kd = server->_priv->machine.kd; - struct seminfo sinfo; - - memset (buf, 0, sizeof (glibtop_sem_limits)); - - if(!(server->sysdeps.sem_limits)) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - if(kvm_read(kd, nlst[0].n_value, (void *)&sinfo, - sizeof(struct seminfo)) != sizeof(struct seminfo)) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - buf->semmap = sinfo.semmap; - buf->semmni = sinfo.semmni; - buf->semmns = sinfo.semmns; - buf->semmnu = sinfo.semmnu; - buf->semmsl = sinfo.semmsl; - buf->semopm = sinfo.semopm; - buf->semume = sinfo.semume; - buf->semusz = sinfo.semusz; - buf->semvmx = sinfo.semvmx; - buf->semaem = sinfo.semaem; - buf->flags = _glibtop_sysdeps_sem_limits; - - return 0; -} diff --git a/sysdeps/solaris/shm_limits.c b/sysdeps/solaris/shm_limits.c deleted file mode 100644 index b0792712..00000000 --- a/sysdeps/solaris/shm_limits.c +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/shm_limits.h> - -#include <kvm.h> -#include <sys/shm.h> - -static struct nlist nlst[] = { {"shminfo"}, {NULL} }; -static const unsigned long _glibtop_sysdeps_shm_limits = -(1L << GLIBTOP_SHM_LIMITS_SHMMAX) + (1L << GLIBTOP_SHM_LIMITS_SHMMIN) + -(1L << GLIBTOP_SHM_LIMITS_SHMMNI) + (1L << GLIBTOP_SHM_LIMITS_SHMSEG); - -/* Init function. */ - -int -glibtop_init_shm_limits_p (glibtop *server) -{ - kvm_t *kd = server->_priv->machine.kd; - - if(kd && !kvm_nlist(kd, nlst)) - server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits; - else - server->sysdeps.shm_limits = 0; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf) -{ - kvm_t *kd = server->_priv->machine.kd; - struct shminfo sinfo; - - memset (buf, 0, sizeof (glibtop_shm_limits)); - - if(!(server->sysdeps.shm_limits)) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - if(kvm_read(kd, nlst[0].n_value, (void *)&sinfo, - sizeof(struct shminfo)) != sizeof(struct shminfo)) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - buf->shmmax = sinfo.shmmax; - buf->shmmin = sinfo.shmmin; - buf->shmmni = sinfo.shmmni; - buf->shmseg = sinfo.shmseg; - buf->flags = _glibtop_sysdeps_shm_limits; - - return 0; -} diff --git a/sysdeps/solaris/swap.c b/sysdeps/solaris/swap.c deleted file mode 100644 index a8adf311..00000000 --- a/sysdeps/solaris/swap.c +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/swap.h> - -#include <assert.h> -#include <sys/sysinfo.h> - -#include <glibtop_private.h> - -static const unsigned long _glibtop_sysdeps_swap = -(1L << GLIBTOP_SWAP_TOTAL) + (1L << GLIBTOP_SWAP_USED) + -(1L << GLIBTOP_SWAP_FREE); - -/* Init function. */ - -int -glibtop_init_swap_s (glibtop *server) -{ - server->sysdeps.swap = _glibtop_sysdeps_swap; - - return 0; -} - -/* Provides information about swap usage. */ - -int -glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) -{ - kstat_ctl_t *kc = server->_priv->machine.kc; - kstat_t *ksp = server->_priv->machine.vminfo_kstat; - u_int64_t swap_resv, swap_alloc, swap_avail, swap_free; - vminfo_t vminfo; - double rate; - kid_t ret; - - memset (buf, 0, sizeof (glibtop_swap)); - - if (!ksp) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - - switch(kstat_chain_update(kc)) - { - case -1: assert(0); /* Debugging, shouldn't happen */ - case 0: break; - default: glibtop_get_kstats(server); - } - ret = kstat_read (kc, ksp, &vminfo); - - if (ret == -1) { - glibtop_warn_io_r (server, "kstat_read (vminfo)"); - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - } - - rate = (ksp->ks_snaptime - server->_priv->machine.vminfo_snaptime) / 1E+9; - - swap_resv = (vminfo.swap_resv - server->_priv->machine.vminfo.swap_resv) / rate; - swap_alloc = (vminfo.swap_alloc - server->_priv->machine.vminfo.swap_alloc) / rate; - swap_avail = (vminfo.swap_avail - server->_priv->machine.vminfo.swap_avail) / rate; - swap_free = (vminfo.swap_free - server->_priv->machine.vminfo.swap_free) / rate; - - memcpy (&server->_priv->machine.vminfo, &vminfo, sizeof (vminfo_t)); - server->_priv->machine.vminfo_snaptime = ksp->ks_snaptime; - - buf->total = swap_resv + swap_avail; - buf->used = swap_alloc; - buf->free = buf->total - buf->used; - - buf->flags = _glibtop_sysdeps_swap; - - return 0; -} diff --git a/sysdeps/solaris/uptime.c b/sysdeps/solaris/uptime.c deleted file mode 100644 index 79246ed2..00000000 --- a/sysdeps/solaris/uptime.c +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/uptime.h> - -#include <time.h> - -static const unsigned long _glibtop_sysdeps_uptime = -(1L << GLIBTOP_UPTIME_UPTIME) + (1L <<GLIBTOP_UPTIME_BOOT_TIME); - -/* Init function. */ - -int -glibtop_init_uptime_s (glibtop *server) -{ - server->sysdeps.uptime = _glibtop_sysdeps_uptime; - - return 0; -} - -/* Provides uptime and idle time. */ - -int -glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) -{ - memset (buf, 0, sizeof (glibtop_uptime)); - - if(!(server->_priv->machine.boot)) - return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; - buf->boot_time = server->_priv->machine.boot; - buf->uptime = time(NULL) - server->_priv->machine.boot; - - buf->flags = _glibtop_sysdeps_uptime; - - return 0; -} diff --git a/sysdeps/stub/.cvsignore b/sysdeps/stub/.cvsignore deleted file mode 100644 index e71d5287..00000000 --- a/sysdeps/stub/.cvsignore +++ /dev/null @@ -1,27 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -close.lo -cpu.lo -init.lo -libgtop_sysdeps.la -loadavg.lo -mem.lo -msg_limits.lo -open.lo -prockernel.lo -proclist.lo -procmem.lo -procsegment.lo -procsignal.lo -procstate.lo -proctime.lo -procuid.lo -sem_limits.lo -shm_limits.lo -swap.lo -sysdeps.lo -uptime.lo -*.lo -so_locations diff --git a/sysdeps/stub/ChangeLog b/sysdeps/stub/ChangeLog deleted file mode 100644 index 064ebd08..00000000 --- a/sysdeps/stub/ChangeLog +++ /dev/null @@ -1,26 +0,0 @@ -2000-11-22 Martin Baulig <martin@home-of-linux.org> - - * Makefile.am: Don't install libgtop_sysdeps.la. - - * *.c: Don't call glibtop_init_s(), this is deprecated. - - * netinfo.c: New file. - -1998-10-26 Martin Baulig <martin@home-of-linux.org> - - * netload.c: New file. - -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. - -1998-08-24 Martin Baulig <martin@home-of-linux.org> - - * *.c: Added initialization functions `glibtop_init_<feature>_s'. - - * ChangeLog: New file. - diff --git a/sysdeps/stub/Makefile.am b/sysdeps/stub/Makefile.am deleted file mode 100644 index 1cf5f715..00000000 --- a/sysdeps/stub/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ - -INCLUDES = @INCLUDES@ -D_IN_LIBGTOP_SERVER - -noinst_LTLIBRARIES = libgtop_sysdeps.la - -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 proccwd.c procargs.c procmap.c \ - netload.c netinfo.c interfaces.c ppp.c - -noinst_HEADERS = glibtop_server_private.h - diff --git a/sysdeps/stub/close.c b/sysdeps/stub/close.c deleted file mode 100644 index defd8fd4..00000000 --- a/sysdeps/stub/close.c +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop/close.h> - -/* Closes pipe to gtop server. */ - -void -glibtop_close_s (glibtop_server *server) -{ } diff --git a/sysdeps/stub/cpu.c b/sysdeps/stub/cpu.c deleted file mode 100644 index faa64702..00000000 --- a/sysdeps/stub/cpu.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/cpu.h> - -static const unsigned long _glibtop_sysdeps_cpu = 0; - -/* Init function. */ - -int -glibtop_init_cpu_s (glibtop_server *server) -{ - server->info->sysdeps.cpu = _glibtop_sysdeps_cpu; - - return 0; -} - -/* Provides information about cpu usage. */ - -int -glibtop_get_cpu_s (glibtop_server *server, glibtop_cpu *buf) -{ - memset (buf, 0, sizeof (glibtop_cpu)); - - return 0; -} diff --git a/sysdeps/stub/glibtop_server_private.h b/sysdeps/stub/glibtop_server_private.h deleted file mode 100644 index 3ca3737c..00000000 --- a/sysdeps/stub/glibtop_server_private.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_SERVER_PRIVATE_H__ -#define __GLIBTOP_SERVER_PRIVATE_H__ - -BEGIN_LIBGTOP_DECLS - -#define GLIBTOP_SUID_CPU 0 -#define GLIBTOP_SUID_MEM 0 -#define GLIBTOP_SUID_SWAP 0 -#define GLIBTOP_SUID_UPTIME 0 -#define GLIBTOP_SUID_LOADAVG 0 -#define GLIBTOP_SUID_SHM_LIMITS 0 -#define GLIBTOP_SUID_MSG_LIMITS 0 -#define GLIBTOP_SUID_SEM_LIMITS 0 -#define GLIBTOP_SUID_PROCLIST 0 -#define GLIBTOP_SUID_PROC_STATE 0 -#define GLIBTOP_SUID_PROC_UID 0 -#define GLIBTOP_SUID_PROC_MEM 0 -#define GLIBTOP_SUID_PROC_TIME 0 -#define GLIBTOP_SUID_PROC_SIGNAL 0 -#define GLIBTOP_SUID_PROC_KERNEL 0 -#define GLIBTOP_SUID_PROC_SEGMENT 0 -#define GLIBTOP_SUID_PROC_ARGS 0 -#define GLIBTOP_SUID_PROC_MAP 0 -#define GLIBTOP_SUID_NETLOAD 0 -#define GLIBTOP_SUID_PPP 0 - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/stub/interfaces.c b/sysdeps/stub/interfaces.c deleted file mode 100644 index 0ddb9f24..00000000 --- a/sysdeps/stub/interfaces.c +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/interfaces.h> - -static const unsigned long _glibtop_sysdeps_interface_names = -(1L << GLIBTOP_INTERFACE_NAMES_NUMBER) + -(1L << GLIBTOP_INTERFACE_NAMES_SIZE); - -/* Init function. */ - -int -glibtop_init_interface_names_s (glibtop_server *server) -{ - server->info->sysdeps.interface_names = _glibtop_sysdeps_interface_names; - - return 0; -} - -/* Provides network statistics. */ - - -glibtop_interface * -glibtop_get_interface_names_s (glibtop_server *server, glibtop_array *array, - u_int64_t interface, u_int64_t number, - u_int64_t instance, u_int64_t strategy) -{ - memset (array, 0, sizeof (glibtop_array)); - - return NULL; -} diff --git a/sysdeps/stub/loadavg.c b/sysdeps/stub/loadavg.c deleted file mode 100644 index 71e83b17..00000000 --- a/sysdeps/stub/loadavg.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/loadavg.h> - -static const unsigned long _glibtop_sysdeps_loadavg = 0; - -/* Init function. */ - -int -glibtop_init_loadavg_s (glibtop_server *server) -{ - server->info->sysdeps.loadavg = _glibtop_sysdeps_loadavg; - - return 0; -} - -/* Provides load averange. */ - -int -glibtop_get_loadavg_s (glibtop_server *server, glibtop_loadavg *buf) -{ - memset (buf, 0, sizeof (glibtop_loadavg)); - - return 0; -} diff --git a/sysdeps/stub/mem.c b/sysdeps/stub/mem.c deleted file mode 100644 index 6abd288e..00000000 --- a/sysdeps/stub/mem.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/mem.h> - -static const unsigned long _glibtop_sysdeps_mem = 0; - -/* Init function. */ - -int -glibtop_init_mem_s (glibtop_server *server) -{ - server->info->sysdeps.mem = _glibtop_sysdeps_mem; - - return 0; -} - -/* Provides information about memory usage. */ - -int -glibtop_get_mem_s (glibtop_server *server, glibtop_mem *buf) -{ - memset (buf, 0, sizeof (glibtop_mem)); - - return 0; -} diff --git a/sysdeps/stub/msg_limits.c b/sysdeps/stub/msg_limits.c deleted file mode 100644 index b6200f1b..00000000 --- a/sysdeps/stub/msg_limits.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/msg_limits.h> - -static const unsigned long _glibtop_sysdeps_msg_limits = 0; - -/* Init function. */ - -int -glibtop_init_msg_limits_s (glibtop_server *server) -{ - server->info->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_msg_limits_s (glibtop_server *server, glibtop_msg_limits *buf) -{ - memset (buf, 0, sizeof (glibtop_msg_limits)); - - return 0; -} diff --git a/sysdeps/stub/netinfo.c b/sysdeps/stub/netinfo.c deleted file mode 100644 index fd7079b2..00000000 --- a/sysdeps/stub/netinfo.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/netinfo.h> - -static const unsigned long _glibtop_sysdeps_netinfo = 0; - -/* Init function. */ - -int -glibtop_init_netinfo_s (glibtop_server *server) -{ - server->info->sysdeps.netinfo = _glibtop_sysdeps_netinfo; - - return 0; -} - -/* Provides network statistics. */ - -glibtop_ifaddr * -glibtop_get_netinfo_s (glibtop_server *server, glibtop_array *array, - glibtop_netinfo *buf, const char *interface, - u_int64_t transport) -{ - memset (buf, 0, sizeof (glibtop_netinfo)); - - return NULL; -} diff --git a/sysdeps/stub/netload.c b/sysdeps/stub/netload.c deleted file mode 100644 index 317a27d5..00000000 --- a/sysdeps/stub/netload.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/netload.h> - -static const unsigned long _glibtop_sysdeps_netload = 0; - -/* Init function. */ - -int -glibtop_init_netload_s (glibtop_server *server) -{ - server->info->sysdeps.netload = _glibtop_sysdeps_netload; - - return 0; -} - -/* Provides network statistics. */ - -int -glibtop_get_netload_s (glibtop_server *server, glibtop_netload *buf, - const char *interface, unsigned transport, - unsigned protocol) -{ - memset (buf, 0, sizeof (glibtop_netload)); - - return 0; -} diff --git a/sysdeps/stub/open.c b/sysdeps/stub/open.c deleted file mode 100644 index 27cf36bb..00000000 --- a/sysdeps/stub/open.c +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/open.h> - -/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ - -void -glibtop_open_s (glibtop_server *server, const char *program_name, - const unsigned long features, const unsigned flags) -{ - server->name = program_name; -} diff --git a/sysdeps/stub/ppp.c b/sysdeps/stub/ppp.c deleted file mode 100644 index baa17294..00000000 --- a/sysdeps/stub/ppp.c +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/ppp.h> - -static const unsigned long _glibtop_sysdeps_ppp = 0; - -/* Init function. */ - -int -glibtop_init_ppp_s (glibtop_server *server) -{ - server->info->sysdeps.ppp = _glibtop_sysdeps_ppp; - - return 0; -} - -/* Provides PPP/ISDN information. */ - -int -glibtop_get_ppp_s (glibtop_server *server, glibtop_ppp *buf, - unsigned short device, unsigned short isdn) -{ - memset (buf, 0, sizeof (glibtop_ppp)); - - return 0; -} diff --git a/sysdeps/stub/procargs.c b/sysdeps/stub/procargs.c deleted file mode 100644 index 3ac7a0f9..00000000 --- a/sysdeps/stub/procargs.c +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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. */ - -int -glibtop_init_proc_args_s (glibtop_server *server) -{ - server->info->sysdeps.proc_args = _glibtop_sysdeps_proc_args; - - return 0; -} - -/* Provides detailed information about a process. */ - -char ** -glibtop_get_proc_args_s (glibtop_server *server, glibtop_array *array, pid_t pid) -{ - memset (array, 0, sizeof (glibtop_array)); - - return NULL; -} diff --git a/sysdeps/stub/proccwd.c b/sysdeps/stub/proccwd.c deleted file mode 100644 index 56e1d83d..00000000 --- a/sysdeps/stub/proccwd.c +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/proccwd.h> - -static const unsigned long _glibtop_sysdeps_proc_cwd = 0; - -/* Init function. */ - -int -glibtop_init_proc_cwd_s (glibtop_server *server) -{ - server->info->sysdeps.proc_cwd = _glibtop_sysdeps_proc_cwd; - - return 0; -} - -/* Provides detailed information about a process. */ - -char * -glibtop_get_proc_cwd_s (glibtop_server *server, glibtop_proc_cwd *buf, pid_t pid) -{ - memset (buf, 0, sizeof (glibtop_proc_cwd)); - - return NULL; -} diff --git a/sysdeps/stub/prockernel.c b/sysdeps/stub/prockernel.c deleted file mode 100644 index 092b8ca0..00000000 --- a/sysdeps/stub/prockernel.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/prockernel.h> - -static const unsigned long _glibtop_sysdeps_proc_kernel = 0; - -/* Init function. */ - -int -glibtop_init_proc_kernel_s (glibtop_server *server) -{ - server->info->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_kernel_s (glibtop_server *server, glibtop_proc_kernel *buf, - pid_t pid) -{ - memset (buf, 0, sizeof (glibtop_proc_kernel)); - - return 0; -} diff --git a/sysdeps/stub/proclist.c b/sysdeps/stub/proclist.c deleted file mode 100644 index 7a51ced4..00000000 --- a/sysdeps/stub/proclist.c +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/proclist.h> - -#define GLIBTOP_PROCLIST_FLAGS 3 - -static const unsigned long _glibtop_sysdeps_proclist = 0; - -/* Init function. */ - -int -glibtop_init_proclist_s (glibtop_server *server) -{ - server->info->sysdeps.proclist = _glibtop_sysdeps_proclist; - - return 0; -} - -/* Fetch list of currently running processes. - * - * IMPORTANT NOTE: - * On error, this function MUST return NULL and set buf->flags to zero ! - * On success, it returnes a pointer to a list of buf->number elements - * each buf->size big. The total size is stored in buf->total. */ - -unsigned * -glibtop_get_proclist_s (glibtop_server *server, glibtop_proclist *buf, - int64_t which, int64_t arg) -{ - memset (buf, 0, sizeof (glibtop_proclist)); - - return NULL; -} diff --git a/sysdeps/stub/procmap.c b/sysdeps/stub/procmap.c deleted file mode 100644 index da44e047..00000000 --- a/sysdeps/stub/procmap.c +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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. */ - -int -glibtop_init_proc_map_s (glibtop_server *server) -{ - server->info->sysdeps.proc_map = _glibtop_sysdeps_proc_map; - - return 0; -} - -/* Provides detailed information about a process. */ - -glibtop_map_entry * -glibtop_get_proc_map_s (glibtop_server *server, glibtop_proc_map *buf, - pid_t pid) -{ - memset (buf, 0, sizeof (glibtop_proc_map)); - - return NULL; -} diff --git a/sysdeps/stub/procmem.c b/sysdeps/stub/procmem.c deleted file mode 100644 index b448bf2d..00000000 --- a/sysdeps/stub/procmem.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procmem.h> - -static const unsigned long _glibtop_sysdeps_proc_mem = 0; - -/* Init function. */ - -int -glibtop_init_proc_mem_s (glibtop_server *server) -{ - server->info->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_mem_s (glibtop_server *server, glibtop_proc_mem *buf, - pid_t pid) -{ - memset (buf, 0, sizeof (glibtop_proc_mem)); - - return 0; -} diff --git a/sysdeps/stub/procsegment.c b/sysdeps/stub/procsegment.c deleted file mode 100644 index 916b5a69..00000000 --- a/sysdeps/stub/procsegment.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procsegment.h> - -static const unsigned long _glibtop_sysdeps_proc_segment = 0; - -/* Init function. */ - -int -glibtop_init_proc_segment_s (glibtop_server *server) -{ - server->info->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_segment_s (glibtop_server *server, glibtop_proc_segment *buf, - pid_t pid) -{ - memset (buf, 0, sizeof (glibtop_proc_segment)); - - return 0; -} diff --git a/sysdeps/stub/procsignal.c b/sysdeps/stub/procsignal.c deleted file mode 100644 index 4bba74f9..00000000 --- a/sysdeps/stub/procsignal.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procsignal.h> - -static const unsigned long _glibtop_sysdeps_proc_signal = 0; - -/* Init function. */ - -int -glibtop_init_proc_signal_s (glibtop_server *server) -{ - server->info->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_signal_s (glibtop_server *server, glibtop_proc_signal *buf, - pid_t pid) -{ - memset (buf, 0, sizeof (glibtop_proc_signal)); - - return 0; -} diff --git a/sysdeps/stub/procstate.c b/sysdeps/stub/procstate.c deleted file mode 100644 index 22ba36b5..00000000 --- a/sysdeps/stub/procstate.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procstate.h> - -static const unsigned long _glibtop_sysdeps_proc_state = 0; - -/* Init function. */ - -int -glibtop_init_proc_state_s (glibtop_server *server) -{ - server->info->sysdeps.proc_state = _glibtop_sysdeps_proc_state; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_state_s (glibtop_server *server, glibtop_proc_state *buf, - pid_t pid) -{ - memset (buf, 0, sizeof (glibtop_proc_state)); - - return 0; -} diff --git a/sysdeps/stub/proctime.c b/sysdeps/stub/proctime.c deleted file mode 100644 index 0b3f99b9..00000000 --- a/sysdeps/stub/proctime.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/proctime.h> - -static const unsigned long _glibtop_sysdeps_proc_time = 0; - -/* Init function. */ - -int -glibtop_init_proc_time_s (glibtop_server *server) -{ - server->info->sysdeps.proc_time = _glibtop_sysdeps_proc_time; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_time_s (glibtop_server *server, glibtop_proc_time *buf, - pid_t pid) -{ - memset (buf, 0, sizeof (glibtop_proc_time)); - - return 0; -} diff --git a/sysdeps/stub/procuid.c b/sysdeps/stub/procuid.c deleted file mode 100644 index b9560731..00000000 --- a/sysdeps/stub/procuid.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procuid.h> - -static const unsigned long _glibtop_sysdeps_proc_uid = 0; - -/* Init function. */ - -int -glibtop_init_proc_uid_s (glibtop_server *server) -{ - server->info->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_uid_s (glibtop_server *server, glibtop_proc_uid *buf, - pid_t pid) -{ - memset (buf, 0, sizeof (glibtop_proc_uid)); - - return 0; -} diff --git a/sysdeps/stub/sem_limits.c b/sysdeps/stub/sem_limits.c deleted file mode 100644 index 8f26cbd1..00000000 --- a/sysdeps/stub/sem_limits.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/sem_limits.h> - -static const unsigned long _glibtop_sysdeps_sem_limits = 0; - -/* Init function. */ - -int -glibtop_init_sem_limits_s (glibtop_server *server) -{ - server->info->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits; - - return 0; -} - -/* Provides information about sysv sem limits. */ - -int -glibtop_get_sem_limits_s (glibtop_server *server, glibtop_sem_limits *buf) -{ - memset (buf, 0, sizeof (glibtop_sem_limits)); - - return 0; -} diff --git a/sysdeps/stub/shm_limits.c b/sysdeps/stub/shm_limits.c deleted file mode 100644 index 6abeeaf3..00000000 --- a/sysdeps/stub/shm_limits.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/shm_limits.h> - -static const unsigned long _glibtop_sysdeps_shm_limits = 0; - -/* Init function. */ - -int -glibtop_init_shm_limits_s (glibtop_server *server) -{ - server->info->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_shm_limits_s (glibtop_server *server, glibtop_shm_limits *buf) -{ - memset (buf, 0, sizeof (glibtop_shm_limits)); - - return 0; -} diff --git a/sysdeps/stub/swap.c b/sysdeps/stub/swap.c deleted file mode 100644 index f88353f4..00000000 --- a/sysdeps/stub/swap.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/swap.h> - -static const unsigned long _glibtop_sysdeps_swap = 0; - -/* Init function. */ - -int -glibtop_init_swap_s (glibtop_server *server) -{ - server->info->sysdeps.swap = _glibtop_sysdeps_swap; - - return 0; -} - -/* Provides information about swap usage. */ - -int -glibtop_get_swap_s (glibtop_server *server, glibtop_swap *buf) -{ - memset (buf, 0, sizeof (glibtop_swap)); - - return 0; -} diff --git a/sysdeps/stub/uptime.c b/sysdeps/stub/uptime.c deleted file mode 100644 index b26aab82..00000000 --- a/sysdeps/stub/uptime.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/uptime.h> - -static const unsigned long _glibtop_sysdeps_uptime = 0; - -/* Init function. */ - -int -glibtop_init_uptime_s (glibtop_server *server) -{ - server->info->sysdeps.uptime = _glibtop_sysdeps_uptime; - - return 0; -} - -/* Provides uptime and idle time. */ - -int -glibtop_get_uptime_s (glibtop_server *server, glibtop_uptime *buf) -{ - memset (buf, 0, sizeof (glibtop_uptime)); - - return 0; -} diff --git a/sysdeps/stub_suid/.cvsignore b/sysdeps/stub_suid/.cvsignore deleted file mode 100644 index d15c76bc..00000000 --- a/sysdeps/stub_suid/.cvsignore +++ /dev/null @@ -1,28 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -close.lo -cpu.lo -init.lo -libgtop_sysdeps.la -loadavg.lo -mem.lo -msg_limits.lo -open.lo -prockernel.lo -proclist.lo -procmem.lo -procsegment.lo -procsignal.lo -procstate.lo -proctime.lo -procuid.lo -sem_limits.lo -shm_limits.lo -swap.lo -sysdeps.lo -uptime.lo -*.lo -*.la -so_locations diff --git a/sysdeps/stub_suid/ChangeLog b/sysdeps/stub_suid/ChangeLog deleted file mode 100644 index f28dba14..00000000 --- a/sysdeps/stub_suid/ChangeLog +++ /dev/null @@ -1,23 +0,0 @@ -2000-02-06 Martin Baulig <martin@home-of-linux.org> - - * Makefile.am: Removed the non-suid `libgtop-sysdeps.la'. - * nosuid.c: Removed. - -1999-12-26 Martin Baulig <martin@home-of-linux.org> - - * netinfo.c: New file. - -1998-10-26 Martin Baulig <martin@home-of-linux.org> - - * netload.c: New file. - -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. - * ppp.c: New file. - diff --git a/sysdeps/stub_suid/Makefile.am b/sysdeps/stub_suid/Makefile.am deleted file mode 100644 index c7605cb2..00000000 --- a/sysdeps/stub_suid/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ - -INCLUDES = @INCLUDES@ - -lib_LTLIBRARIES = libgtop_sysdeps_suid.la - -libgtop_sysdeps_suid_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 procargs.c procmap.c netload.c \ - netinfo.c interfaces.c ppp.c - -libgtop_sysdeps_suid_la_LDFLAGS = $(LT_VERSION_INFO) - -include_HEADERS = glibtop_server.h glibtop_machine.h - -noinst_HEADERS = glibtop_suid.h diff --git a/sysdeps/stub_suid/close.c b/sysdeps/stub_suid/close.c deleted file mode 100644 index 3378b817..00000000 --- a/sysdeps/stub_suid/close.c +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop/close.h> - -/* Closes pipe to gtop server. */ - -void -glibtop_close_s (glibtop *server) -{ } diff --git a/sysdeps/stub_suid/cpu.c b/sysdeps/stub_suid/cpu.c deleted file mode 100644 index 6ec05b68..00000000 --- a/sysdeps/stub_suid/cpu.c +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/cpu.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_cpu = 0; - -/* Init function. */ - -int -glibtop_init_cpu_p (glibtop *server) -{ - server->sysdeps.cpu = _glibtop_sysdeps_cpu; - - return 0; -} - -/* Provides information about cpu usage. */ - -int -glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_CPU, 0); - - memset (buf, 0, sizeof (glibtop_cpu)); - - return 0; -} diff --git a/sysdeps/stub_suid/glibtop_machine.h b/sysdeps/stub_suid/glibtop_machine.h deleted file mode 100644 index a0faf8b8..00000000 --- a/sysdeps/stub_suid/glibtop_machine.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_MACHINE_H__ -#define __GLIBTOP_MACHINE_H__ - -BEGIN_LIBGTOP_DECLS - -typedef struct _glibtop_machine glibtop_machine; - -struct _glibtop_machine -{ - uid_t uid, euid; /* Real and effective user id */ - gid_t gid, egid; /* Real and effective group id */ -}; - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/stub_suid/glibtop_server.h b/sysdeps/stub_suid/glibtop_server.h deleted file mode 100644 index d7e032d9..00000000 --- a/sysdeps/stub_suid/glibtop_server.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_SERVER_H__ -#define __GLIBTOP_SERVER_H__ - -BEGIN_LIBGTOP_DECLS - -#define GLIBTOP_SUID_CPU (1 << GLIBTOP_SYSDEPS_CPU) -#define GLIBTOP_SUID_MEM (1 << GLIBTOP_SYSDEPS_MEM) -#define GLIBTOP_SUID_SWAP (1 << GLIBTOP_SYSDEPS_SWAP) -#define GLIBTOP_SUID_UPTIME (1 << GLIBTOP_SYSDEPS_UPTIME) -#define GLIBTOP_SUID_LOADAVG (1 << GLIBTOP_SYSDEPS_LOADAVG) -#define GLIBTOP_SUID_SHM_LIMITS (1 << GLIBTOP_SYSDEPS_SHM_LIMITS) -#define GLIBTOP_SUID_MSG_LIMITS (1 << GLIBTOP_SYSDEPS_MSG_LIMITS) -#define GLIBTOP_SUID_SEM_LIMITS (1 << GLIBTOP_SYSDEPS_SEM_LIMITS) -#define GLIBTOP_SUID_PROCLIST (1 << GLIBTOP_SYSDEPS_PROCLIST) -#define GLIBTOP_SUID_PROC_STATE (1 << GLIBTOP_SYSDEPS_PROC_STATE) -#define GLIBTOP_SUID_PROC_UID (1 << GLIBTOP_SYSDEPS_PROC_UID) -#define GLIBTOP_SUID_PROC_MEM (1 << GLIBTOP_SYSDEPS_PROC_MEM) -#define GLIBTOP_SUID_PROC_TIME (1 << GLIBTOP_SYSDEPS_PROC_TIME) -#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_NETLOAD (1 << GLIBTOP_SYSDEPS_NETLOAD) -#define GLIBTOP_SUID_NETINFO (1 << GLIBTOP_SYSDEPS_NETINFO) -#define GLIBTOP_SUID_INTERFACE_NAMES (1 << GLIBTOP_SYSDEPS_INTERFACE_NAMES) -#define GLIBTOP_SUID_PPP (1 << GLIBTOP_SYSDEPS_PPP) - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/stub_suid/glibtop_suid.h b/sysdeps/stub_suid/glibtop_suid.h deleted file mode 100644 index 3923f034..00000000 --- a/sysdeps/stub_suid/glibtop_suid.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_SUID_H__ -#define __GLIBTOP_SUID_H__ - -BEGIN_LIBGTOP_DECLS - -static inline void glibtop_suid_enter (glibtop *server) { - setreuid (server->_priv->machine.uid, server->_priv->machine.euid); -}; - -static inline void glibtop_suid_leave (glibtop *server) { - if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid)) - _exit (1); -}; - -void -glibtop_init_p (glibtop *server, const unsigned long features, - const unsigned flags); -void -glibtop_open_p (glibtop *server, const char *program_name, - const unsigned long features, - const unsigned flags); - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/stub_suid/init.c b/sysdeps/stub_suid/init.c deleted file mode 100644 index 53e2453a..00000000 --- a/sysdeps/stub_suid/init.c +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/open.h> - -static glibtop _glibtop_global_server; -glibtop *glibtop_global_server = NULL; - -glibtop * -glibtop_init_r (glibtop **server, - const unsigned long features, - const unsigned flags) -{ - if (*server != NULL) - return *server; - - if (glibtop_global_server == NULL) { - glibtop_global_server = &_glibtop_global_server; - glibtop_open (glibtop_global_server, "glibtop", - features, flags); - } - - return *server = glibtop_global_server; -} diff --git a/sysdeps/stub_suid/interfaces.c b/sysdeps/stub_suid/interfaces.c deleted file mode 100644 index b9dd54a0..00000000 --- a/sysdeps/stub_suid/interfaces.c +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/interfaces.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_interface_names = -(1L << GLIBTOP_INTERFACE_NAMES_NUMBER) + -(1L << GLIBTOP_INTERFACE_NAMES_SIZE); - -/* Init function. */ - -int -glibtop_init_interface_names_p (glibtop *server) -{ - server->sysdeps.interface_names = _glibtop_sysdeps_interface_names; - - return 0; -} - -/* Provides network statistics. */ - -glibtop_interface * -glibtop_get_interface_names_p (glibtop *server, glibtop_array *array, - u_int64_t interface, u_int64_t number, - u_int64_t instance, u_int64_t strategy) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_INTERFACE_NAMES, 0); - - memset (array, 0, sizeof (glibtop_array)); - - return NULL; -} diff --git a/sysdeps/stub_suid/loadavg.c b/sysdeps/stub_suid/loadavg.c deleted file mode 100644 index f713d5db..00000000 --- a/sysdeps/stub_suid/loadavg.c +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/loadavg.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_loadavg = 0; - -/* Init function. */ - -int -glibtop_init_loadavg_p (glibtop *server) -{ - server->sysdeps.loadavg = _glibtop_sysdeps_loadavg; - - return 0; -} - -/* Provides load averange. */ - -int -glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_LOADAVG, 0); - - memset (buf, 0, sizeof (glibtop_loadavg)); - - return 0; -} diff --git a/sysdeps/stub_suid/mem.c b/sysdeps/stub_suid/mem.c deleted file mode 100644 index 430e5062..00000000 --- a/sysdeps/stub_suid/mem.c +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/mem.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_mem = 0; - -/* Init function. */ - -int -glibtop_init_mem_p (glibtop *server) -{ - server->sysdeps.mem = _glibtop_sysdeps_mem; - - return 0; -} - -/* Provides information about memory usage. */ - -int -glibtop_get_mem_p (glibtop *server, glibtop_mem *buf) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_MEM, 0); - - memset (buf, 0, sizeof (glibtop_mem)); - - return 0; -} diff --git a/sysdeps/stub_suid/msg_limits.c b/sysdeps/stub_suid/msg_limits.c deleted file mode 100644 index efb0f958..00000000 --- a/sysdeps/stub_suid/msg_limits.c +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/msg_limits.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_msg_limits = 0; - -/* Init function. */ - -int -glibtop_init_msg_limits_p (glibtop *server) -{ - server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0); - - memset (buf, 0, sizeof (glibtop_msg_limits)); - - return 0; -} diff --git a/sysdeps/stub_suid/netinfo.c b/sysdeps/stub_suid/netinfo.c deleted file mode 100644 index ffb19d67..00000000 --- a/sysdeps/stub_suid/netinfo.c +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/netinfo.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_netinfo = 0; - -/* Init function. */ - -int -glibtop_init_netinfo_p (glibtop *server) -{ - server->sysdeps.netinfo = _glibtop_sysdeps_netinfo; - - return 0; -} - -/* Provides Network statistics. */ - -int -glibtop_get_netinfo_p (glibtop *server, glibtop_netinfo *buf, - const char *interface, unsigned transport) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_NETINFO, 0); - - memset (buf, 0, sizeof (glibtop_netinfo)); - - return 0; -} diff --git a/sysdeps/stub_suid/netload.c b/sysdeps/stub_suid/netload.c deleted file mode 100644 index adfb1d16..00000000 --- a/sysdeps/stub_suid/netload.c +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/netload.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_netload = 0; - -/* Init function. */ - -int -glibtop_init_netload_p (glibtop *server) -{ - server->sysdeps.netload = _glibtop_sysdeps_netload; - - return 0; -} - -/* Provides Network statistics. */ - -int -glibtop_get_netload_p (glibtop *server, glibtop_netload *buf, - const char *interface, unsigned transport, - unsigned protocol) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_NETLOAD, 0); - - memset (buf, 0, sizeof (glibtop_netload)); - - return 0; -} diff --git a/sysdeps/stub_suid/open.c b/sysdeps/stub_suid/open.c deleted file mode 100644 index 2d20b2bd..00000000 --- a/sysdeps/stub_suid/open.c +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/open.h> -#include <glibtop/xmalloc.h> - -/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - -void -glibtop_init_p (glibtop *server, const unsigned long features, - const unsigned flags) -{ - glibtop_init_func_t *init_fkt; - - if (server == NULL) - glibtop_error_r (NULL, "glibtop_init_p (server == NULL)"); - - /* Do the initialization, but only if not already initialized. */ - - if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) { - glibtop_open_p (server, "glibtop", features, flags); - - for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++) - (*init_fkt) (server); - - server->flags |= _GLIBTOP_INIT_STATE_INIT; - } -} - -void -glibtop_open_p (glibtop *server, const char *program_name, - const unsigned long features, const unsigned flags) -{ - /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ - - server->name = program_name; - - server->_priv->machine.uid = getuid (); - server->_priv->machine.euid = geteuid (); - server->_priv->machine.gid = getgid (); - server->_priv->machine.egid = getegid (); - - /* Drop priviledges. */ - - if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid)) - _exit (1); - - if (setregid (server->_priv->machine.egid, server->_priv->machine.gid)) - _exit (1); - - /* !!! END OF SUID ROOT PART !!! */ - - /* Our effective uid is now those of the user invoking the server, - * so we do no longer have any priviledges. */ -} - diff --git a/sysdeps/stub_suid/ppp.c b/sysdeps/stub_suid/ppp.c deleted file mode 100644 index cfbcddec..00000000 --- a/sysdeps/stub_suid/ppp.c +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/ppp.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_ppp = 0; - -/* Init function. */ - -int -glibtop_init_ppp_p (glibtop *server) -{ - server->sysdeps.ppp = _glibtop_sysdeps_ppp; - - return 0; -} - -/* Provides PPP/ISDN information. */ - -int -glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device, - unsigned short isdn) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_PPP, 0); - - memset (buf, 0, sizeof (glibtop_ppp)); - - return 0; -} diff --git a/sysdeps/stub_suid/procargs.c b/sysdeps/stub_suid/procargs.c deleted file mode 100644 index 980b0ba3..00000000 --- a/sysdeps/stub_suid/procargs.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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. */ - -int -glibtop_init_proc_args_p (glibtop *server) -{ - server->sysdeps.proc_args = _glibtop_sysdeps_proc_args; - - return 0; -} - -/* Provides detailed information about a process. */ - -char ** -glibtop_get_proc_args_p (glibtop *server, glibtop_array *array, pid_t pid) -{ - memset (array, 0, sizeof (glibtop_array)); - return NULL; -} diff --git a/sysdeps/stub_suid/procdata.c b/sysdeps/stub_suid/procdata.c deleted file mode 100644 index 1d22e8ee..00000000 --- a/sysdeps/stub_suid/procdata.c +++ /dev/null @@ -1,182 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/procdata.h> - -#include <sys/stat.h> - -#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z) - -#define BIT_SHIFT(x) (1L << (x % 32)) - -static const unsigned long _glibtop_sysdeps_procdata_0 = -BIT_SHIFT(GLIBTOP_PROCDATA_CMD) + -BIT_SHIFT(GLIBTOP_PROCDATA_STATE) + -BIT_SHIFT(GLIBTOP_PROCDATA_UID) + -BIT_SHIFT(GLIBTOP_PROCDATA_PID) + -BIT_SHIFT(GLIBTOP_PROCDATA_PPID) + -BIT_SHIFT(GLIBTOP_PROCDATA_PGRP) + -BIT_SHIFT(GLIBTOP_PROCDATA_SESSION) + -BIT_SHIFT(GLIBTOP_PROCDATA_TTY) + -BIT_SHIFT(GLIBTOP_PROCDATA_TPGID) + -BIT_SHIFT(GLIBTOP_PROCDATA_PRIORITY) + -BIT_SHIFT(GLIBTOP_PROCDATA_NICE) + -BIT_SHIFT(GLIBTOP_PROCDATA_SIGNAL) + -BIT_SHIFT(GLIBTOP_PROCDATA_BLOCKED) + -BIT_SHIFT(GLIBTOP_PROCDATA_SIGIGNORE) + -BIT_SHIFT(GLIBTOP_PROCDATA_SIGCATCH) + -BIT_SHIFT(GLIBTOP_PROCDATA_START_TIME) + -BIT_SHIFT(GLIBTOP_PROCDATA_UTIME) + -BIT_SHIFT(GLIBTOP_PROCDATA_STIME) + -BIT_SHIFT(GLIBTOP_PROCDATA_CUTIME) + -BIT_SHIFT(GLIBTOP_PROCDATA_CSTIME) + -BIT_SHIFT(GLIBTOP_PROCDATA_SIZE) + -BIT_SHIFT(GLIBTOP_PROCDATA_RESIDENT) + -BIT_SHIFT(GLIBTOP_PROCDATA_SHARE) + -BIT_SHIFT(GLIBTOP_PROCDATA_TRS) + -BIT_SHIFT(GLIBTOP_PROCDATA_LRS) + -BIT_SHIFT(GLIBTOP_PROCDATA_DRS) + -BIT_SHIFT(GLIBTOP_PROCDATA_DT) + -BIT_SHIFT(GLIBTOP_PROCDATA_VSIZE) + -BIT_SHIFT(GLIBTOP_PROCDATA_RSS) + -BIT_SHIFT(GLIBTOP_PROCDATA_RSS_RLIM) + -BIT_SHIFT(GLIBTOP_PROCDATA_TIMEOUT) + -BIT_SHIFT(GLIBTOP_PROCDATA_IT_REAL_VALUE); - -static const unsigned long _glibtop_sysdeps_procdata_1 = -BIT_SHIFT(GLIBTOP_PROCDATA_K_FLAGS) + -BIT_SHIFT(GLIBTOP_PROCDATA_MIN_FLT) + -BIT_SHIFT(GLIBTOP_PROCDATA_MAJ_FLT) + -BIT_SHIFT(GLIBTOP_PROCDATA_CMIN_FLT) + -BIT_SHIFT(GLIBTOP_PROCDATA_CMAJ_FLT) + -BIT_SHIFT(GLIBTOP_PROCDATA_START_CODE) + -BIT_SHIFT(GLIBTOP_PROCDATA_END_CODE) + -BIT_SHIFT(GLIBTOP_PROCDATA_START_STACK) + -BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_ESP) + -BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_EIP) + -BIT_SHIFT(GLIBTOP_PROCDATA_WCHAN); - -/* Provides detailed information about a process. */ - -void -glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid) -{ - char input [BUFSIZ], *tmp; - struct stat statb; - int nread; - FILE *f; - - glibtop_init_r (&server, 0, 0); - - memset (buf, 0, sizeof (glibtop_procdata)); - - if (pid == 0) { - /* Client is only interested in the flags. */ - buf->flags [0] = _glibtop_sysdeps_procdata_0; - buf->flags [1] = _glibtop_sysdeps_procdata_1; - return; - } - - - sprintf (input, "/proc/%d/stat", pid); - - if (stat (input, &statb)) return; - - buf->uid = statb.st_uid; - - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; - } - - input [nread] = 0; - - /* This is from guile-utils/gtop/proc/readproc.c */ - - /* split into "PID (cmd" and "<rest>" */ - tmp = strrchr (input, ')'); - *tmp = '\0'; /* replace trailing ')' with NUL */ - /* parse these two strings separately, skipping the leading "(". */ - memset (buf->cmd, 0, sizeof (buf->cmd)); - sscanf (input, "%d (%39c", &buf->pid, buf->cmd); - sscanf(tmp + 2, /* skip space after ')' too */ - "%c %d %d %d %d %d %lu %lu %lu %lu %lu " - "%ld %ld %ld %ld %d %d %lu %lu %ld %lu " - "%lu %lu %lu %lu %lu %lu %lu %d %d %d %d %lu", - &buf->state, &buf->ppid, &buf->pgrp, &buf->session, - &buf->tty, &buf->tpgid, &buf->k_flags, &buf->min_flt, - &buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt, - &buf->utime, &buf->stime, &buf->cutime, &buf->cstime, - &buf->priority, &buf->nice, &buf->timeout, - &buf->it_real_value, &buf->start_time, &buf->vsize, - &buf->rss, &buf->rss_rlim, &buf->start_code, - &buf->end_code, &buf->start_stack, &buf->kstk_esp, - &buf->kstk_eip, &buf->signal, &buf->blocked, - &buf->sigignore, &buf->sigcatch, &buf->wchan); - - if (buf->tty == 0) - /* the old notty val, update elsewhere bef. moving to 0 */ - buf->tty = -1; - - if (server->os_version_code < LINUX_VERSION(1,3,39)) { - /* map old meanings to new */ - buf->priority = 2*15 - buf->priority; - buf->nice = 15 - buf->nice; - } - if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1) - /* when tty wasn't full devno */ - buf->tty = 4*0x100 + buf->tty; - - fclose (f); - - sprintf (input, "/proc/%d/statm", pid); - - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; - } - - input [nread] = 0; - - sscanf (input, "%ld %ld %ld %ld %ld %ld %ld", - &buf->size, &buf->resident, &buf->share, - &buf->trs, &buf->lrs, &buf->drs, &buf->dt); - - fclose (f); - - buf->flags [0] = _glibtop_sysdeps_procdata_0; - buf->flags [1] = _glibtop_sysdeps_procdata_1; -} diff --git a/sysdeps/stub_suid/prockernel.c b/sysdeps/stub_suid/prockernel.c deleted file mode 100644 index 135dbad0..00000000 --- a/sysdeps/stub_suid/prockernel.c +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/prockernel.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_kernel = 0; - -/* Init function. */ - -int -glibtop_init_proc_kernel_p (glibtop *server) -{ - server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf, - pid_t pid) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0); - - memset (buf, 0, sizeof (glibtop_proc_kernel)); - - return 0; -} diff --git a/sysdeps/stub_suid/proclist.c b/sysdeps/stub_suid/proclist.c deleted file mode 100644 index cb025248..00000000 --- a/sysdeps/stub_suid/proclist.c +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/proclist.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proclist = 0; - -/* Init function. */ - -int -glibtop_init_proclist_p (glibtop *server) -{ - server->sysdeps.proclist = _glibtop_sysdeps_proclist; - - return 0; -} - -unsigned * -glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf, - int64_t which, int64_t arg) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROCLIST, 0); - - memset (buf, 0, sizeof (glibtop_proclist)); - - return NULL; -} diff --git a/sysdeps/stub_suid/procmap.c b/sysdeps/stub_suid/procmap.c deleted file mode 100644 index 34aafda3..00000000 --- a/sysdeps/stub_suid/procmap.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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. */ - -int -glibtop_init_proc_map_p (glibtop *server) -{ - server->sysdeps.proc_map = _glibtop_sysdeps_proc_map; - - return 0; -} - -/* 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; -} diff --git a/sysdeps/stub_suid/procmem.c b/sysdeps/stub_suid/procmem.c deleted file mode 100644 index ad99456e..00000000 --- a/sysdeps/stub_suid/procmem.c +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procmem.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_mem = 0; - -/* Init function. */ - -int -glibtop_init_proc_mem_p (glibtop *server) -{ - server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf, - pid_t pid) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_MEM, 0); - - memset (buf, 0, sizeof (glibtop_proc_mem)); - - return 0; -} diff --git a/sysdeps/stub_suid/procsegment.c b/sysdeps/stub_suid/procsegment.c deleted file mode 100644 index 7ef6cf94..00000000 --- a/sysdeps/stub_suid/procsegment.c +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procsegment.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_segment = 0; - -/* Init function. */ - -int -glibtop_init_proc_segment_p (glibtop *server) -{ - server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf, - pid_t pid) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0); - - memset (buf, 0, sizeof (glibtop_proc_segment)); - - return 0; -} diff --git a/sysdeps/stub_suid/procsignal.c b/sysdeps/stub_suid/procsignal.c deleted file mode 100644 index 4cf8722a..00000000 --- a/sysdeps/stub_suid/procsignal.c +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procsignal.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_signal = 0; - -/* Init function. */ - -int -glibtop_init_proc_signal_p (glibtop *server) -{ - server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf, - pid_t pid) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0); - - memset (buf, 0, sizeof (glibtop_proc_signal)); - - return 0; -} diff --git a/sysdeps/stub_suid/procstate.c b/sysdeps/stub_suid/procstate.c deleted file mode 100644 index 6fb412f1..00000000 --- a/sysdeps/stub_suid/procstate.c +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procstate.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_state = 0; - -/* Init function. */ - -int -glibtop_init_proc_state_p (glibtop *server) -{ - server->sysdeps.proc_state = _glibtop_sysdeps_proc_state; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf, - pid_t pid) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_STATE, 0); - - memset (buf, 0, sizeof (glibtop_proc_state)); - - return 0; -} diff --git a/sysdeps/stub_suid/proctime.c b/sysdeps/stub_suid/proctime.c deleted file mode 100644 index 39151d21..00000000 --- a/sysdeps/stub_suid/proctime.c +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/proctime.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_time = 0; - -/* Init function. */ - -int -glibtop_init_proc_time_p (glibtop *server) -{ - server->sysdeps.proc_time = _glibtop_sysdeps_proc_time; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf, - pid_t pid) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_TIME, 0); - - memset (buf, 0, sizeof (glibtop_proc_time)); - - return 0; -} diff --git a/sysdeps/stub_suid/procuid.c b/sysdeps/stub_suid/procuid.c deleted file mode 100644 index 38f36afc..00000000 --- a/sysdeps/stub_suid/procuid.c +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/procuid.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_uid = 0; - -/* Init function. */ - -int -glibtop_init_proc_uid_p (glibtop *server) -{ - server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid; - - return 0; -} - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf, - pid_t pid) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_UID, 0); - - memset (buf, 0, sizeof (glibtop_proc_uid)); - - return 0; -} diff --git a/sysdeps/stub_suid/sem_limits.c b/sysdeps/stub_suid/sem_limits.c deleted file mode 100644 index d574052b..00000000 --- a/sysdeps/stub_suid/sem_limits.c +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/sem_limits.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_sem_limits = 0; - -/* Init function. */ - -int -glibtop_init_sem_limits_p (glibtop *server) -{ - server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits; - - return 0; -} - -/* Provides information about sysv sem limits. */ - -int -glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0); - - memset (buf, 0, sizeof (glibtop_sem_limits)); - - return 0; -} diff --git a/sysdeps/stub_suid/shm_limits.c b/sysdeps/stub_suid/shm_limits.c deleted file mode 100644 index 7246a592..00000000 --- a/sysdeps/stub_suid/shm_limits.c +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/shm_limits.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_shm_limits = 0; - -/* Init function. */ - -int -glibtop_init_shm_limits_p (glibtop *server) -{ - server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0); - - memset (buf, 0, sizeof (glibtop_shm_limits)); - - return 0; -} diff --git a/sysdeps/stub_suid/swap.c b/sysdeps/stub_suid/swap.c deleted file mode 100644 index e5fe5d0d..00000000 --- a/sysdeps/stub_suid/swap.c +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/swap.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_swap = 0; - -/* Init function. */ - -int -glibtop_init_swap_p (glibtop *server) -{ - server->sysdeps.swap = _glibtop_sysdeps_swap; - - return 0; -} - -/* Provides information about swap usage. */ - -int -glibtop_get_swap_p (glibtop *server, glibtop_swap *buf) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_SWAP, 0); - - memset (buf, 0, sizeof (glibtop_swap)); - - return 0; -} diff --git a/sysdeps/stub_suid/uptime.c b/sysdeps/stub_suid/uptime.c deleted file mode 100644 index b627ccdd..00000000 --- a/sysdeps/stub_suid/uptime.c +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/uptime.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_uptime = 0; - -/* Init function. */ - -int -glibtop_init_uptime_p (glibtop *server) -{ - server->sysdeps.uptime = _glibtop_sysdeps_uptime; - - return 0; -} - -/* Provides uptime and idle time. */ - -int -glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf) -{ - glibtop_init_p (server, GLIBTOP_SYSDEPS_UPTIME, 0); - - memset (buf, 0, sizeof (glibtop_uptime)); - - return 0; -} diff --git a/sysdeps/sun4/.cvsignore b/sysdeps/sun4/.cvsignore deleted file mode 100644 index dd420e7f..00000000 --- a/sysdeps/sun4/.cvsignore +++ /dev/null @@ -1,17 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -close.lo -cpu.lo -libgtop_sysdeps.la -loadavg.lo -mem.lo -msg_limits.lo -open.lo -proclist.lo -sem_limits.lo -shm_limits.lo -swap.lo -sysdeps.lo -uptime.lo diff --git a/sysdeps/sun4/ChangeLog b/sysdeps/sun4/ChangeLog deleted file mode 100644 index 48a1688a..00000000 --- a/sysdeps/sun4/ChangeLog +++ /dev/null @@ -1,13 +0,0 @@ -1998-10-25 Martin Baulig <martin@home-of-linux.org> - - * ppp.c: New file. - -1998-08-25 Martin Baulig <martin@home-of-linux.org> - - * *.c (glibtop_init_p): Using correct `(1 << GLIBTOP_SYSDPES_*)'. - (<glibtop_suid.h>): Include. - - * glibtop_suid.h: New file. - - * ChangeLog: New file. - diff --git a/sysdeps/sun4/Makefile.am b/sysdeps/sun4/Makefile.am deleted file mode 100644 index 56e8a078..00000000 --- a/sysdeps/sun4/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ - -INCLUDES = @INCLUDES@ - -lib_LTLIBRARIES = libgtop_sysdeps.la libgtop_sysdeps_suid.la - -libgtop_sysdeps_la_SOURCES = nosuid.c -libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) -libgtop_sysdeps_la_LIBADD = -lkvm - -libgtop_sysdeps_suid_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 ppp.c -libgtop_sysdeps_suid_la_LDFLAGS = $(LT_VERSION_INFO) -libgtop_sysdeps_suid_la_LIBADD = -lkvm - -include_HEADERS = glibtop_server.h glibtop_machine.h - -noinst_HEADERS = glibtop_suid.h diff --git a/sysdeps/sun4/close.c b/sysdeps/sun4/close.c deleted file mode 100644 index 95bffec1..00000000 --- a/sysdeps/sun4/close.c +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop/close.h> - -/* Closes pipe to gtop server. */ - -void -glibtop_close_p (glibtop *server) -{ } diff --git a/sysdeps/sun4/cpu.c b/sysdeps/sun4/cpu.c deleted file mode 100644 index fbf599cb..00000000 --- a/sysdeps/sun4/cpu.c +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/cpu.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_cpu = -(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) + -(1L << GLIBTOP_CPU_NICE) + (1L << GLIBTOP_CPU_SYS) + -(1L << GLIBTOP_CPU_IDLE) + (1L << GLIBTOP_CPU_FREQUENCY); - -/* Provides information about cpu usage. */ - -int -glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf) -{ - long cp_time [CPUSTATES], mp_time [NCPU][CPUSTATES]; - int i; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_CPU), 0); - - memset (buf, 0, sizeof (glibtop_cpu)); - - /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ - - glibtop_suid_enter (server); - - /* get the cp_time array */ - - (void) _glibtop_getkval (server, _glibtop_nlist [X_CP_TIME].n_value, - (int *) cp_time, sizeof (cp_time), - _glibtop_nlist [X_CP_TIME].n_name); - -#ifdef MULTIPROCESSOR - /* get the mp_time array as well */ - - if (server->machine.ncpu > 1) { - (void) _glibtop_getkval (server, _glibtop_nlist [X_MP_TIME].n_value, - (int *) mp_time, sizeof (mp_time), - _glibtop_nlist [X_MP_TIME].n_name); - } -#endif - - glibtop_suid_leave (server); - - /* !!! END OF SUID ROOT PART !!! */ - -#ifdef MULTIPROCESSOR - /* If we have multiple processors, we add the times for each of them - * and set frequency to 100 times the number of the processors. */ - - /* [FIXME]: I had no machine with more than one processor to test - * this code !!! */ - - if (server->machine.ncpu > 1) { - for (i = 0; i < server->machine.ncpu; i++) { - buf->user += mp_time [i][CP_USER]; - buf->nice += mp_time [i][CP_NICE]; - buf->sys += mp_time [i][CP_SYS]; - buf->idle += mp_time [i][CP_IDLE]; - buf->frequency += 100; - } - } else { - buf->user = cp_time [CP_USER]; - buf->nice = cp_time [CP_NICE]; - buf->sys = cp_time [CP_SYS]; - buf->idle = cp_time [CP_IDLE]; - buf->frequency = 100; - } -#else - buf->user = cp_time [CP_USER]; - buf->nice = cp_time [CP_NICE]; - buf->sys = cp_time [CP_SYS]; - buf->idle = cp_time [CP_IDLE]; - buf->frequency = 100; -#endif - - /* Calculate total time. */ - - buf->total = buf->user + buf->nice + buf->sys + buf->idle; - - /* Now we can set the flags. */ - - buf->flags = _glibtop_sysdeps_cpu; -} diff --git a/sysdeps/sun4/glibtop_machine.h b/sysdeps/sun4/glibtop_machine.h deleted file mode 100644 index 8a1f645b..00000000 --- a/sysdeps/sun4/glibtop_machine.h +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_MACHINE_H__ -#define __GLIBTOP_MACHINE_H__ - -/* make sure param.h gets loaded with KERNEL defined to get PZERO & NZERO */ -#define KERNEL -#include <sys/param.h> -#undef KERNEL - -#include <stdio.h> -#include <kvm.h> -#include <nlist.h> -#include <math.h> -#include <sys/dir.h> -#include <sys/user.h> -#include <sys/proc.h> -#include <sys/dk.h> -#include <sys/vm.h> -#include <sys/file.h> -#include <sys/time.h> -#include <vm/page.h> - -#ifdef solbourne -#include <sys/syscall.h> -#endif - -#include "loadavg.h" - -BEGIN_LIBGTOP_DECLS - -/* Older versions of SunOS don't have a typedef for pid_t. - Hopefully this will catch all those cases without causing other problems. - */ -#ifndef __sys_stdtypes_h -typedef int pid_t; -#endif - -/* definitions for indices in the nlist array */ -#define X_AVENRUN 0 -#define X_CCPU 1 -#define X_MPID 2 -#define X_NPROC 3 -#define X_PROC 4 -#define X_TOTAL 5 -#define X_CP_TIME 6 -#define X_PAGES 7 -#define X_EPAGES 8 -#define X_SHMINFO 9 -#define X_MSGINFO 10 -#define X_SEMINFO 11 - -#ifdef MULTIPROCESSOR -#define X_NCPU 12 -#define X_MP_TIME 13 -#endif - -/* Log base 2 of 1024 is 10 (2^10 == 1024) */ -#define LOG1024 10 - -typedef struct _glibtop_machine glibtop_machine; - -struct _glibtop_machine -{ - uid_t uid, euid; /* Real and effective user id */ - gid_t gid, egid; /* Real and effective group id */ - int nlist_count; /* Number of symbols in the nlist */ - int ncpu; /* Number of CPUs we have */ - int nproc; /* Number of entries in the process array */ - size_t ptable_size; /* Size of process array. */ - unsigned long ptable_offset; /* Offset of process array in kernel. */ - struct proc *proc_table; /* Process array. */ - unsigned long pages, epages; - struct page *physpage; - int bytesize, count; - int pageshift; /* log base 2 of the pagesize */ - kvm_t *kd; -}; - -/* Those functions are used internally in libgtop */ - -#ifdef _IN_LIBGTOP - -extern struct nlist _glibtop_nlist[]; - -int _glibtop_check_nlist (void *server, register struct nlist *nlst); -int _glibtop_getkval (void *void_server, unsigned long offset, int *ptr, - int size, char *refstr); -void _glibtop_read_proc_table (void *void_server); -struct proc *_glibtop_find_pid (void *void_server, pid_t pid); - -#endif - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/sun4/glibtop_server.h b/sysdeps/sun4/glibtop_server.h deleted file mode 100644 index e98bf898..00000000 --- a/sysdeps/sun4/glibtop_server.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_SERVER_H__ -#define __GLIBTOP_SERVER_H__ - -BEGIN_LIBGTOP_DECLS - -#define GLIBTOP_SUID_CPU (1 << GLIBTOP_SYSDEPS_CPU) -#define GLIBTOP_SUID_MEM (1 << GLIBTOP_SYSDEPS_MEM) -#define GLIBTOP_SUID_SWAP (1 << GLIBTOP_SYSDEPS_SWAP) -#define GLIBTOP_SUID_UPTIME (1 << GLIBTOP_SYSDEPS_UPTIME) -#define GLIBTOP_SUID_LOADAVG (1 << GLIBTOP_SYSDEPS_LOADAVG) -#define GLIBTOP_SUID_SHM_LIMITS (1 << GLIBTOP_SYSDEPS_SHM_LIMITS) -#define GLIBTOP_SUID_MSG_LIMITS (1 << GLIBTOP_SYSDEPS_MSG_LIMITS) -#define GLIBTOP_SUID_SEM_LIMITS (1 << GLIBTOP_SYSDEPS_SEM_LIMITS) -#define GLIBTOP_SUID_PROCLIST (1 << GLIBTOP_SYSDEPS_PROCLIST) -#define GLIBTOP_SUID_PROC_STATE (1 << GLIBTOP_SYSDEPS_PROC_STATE) -#define GLIBTOP_SUID_PROC_UID (1 << GLIBTOP_SYSDEPS_PROC_UID) -#define GLIBTOP_SUID_PROC_MEM (1 << GLIBTOP_SYSDEPS_PROC_MEM) -#define GLIBTOP_SUID_PROC_TIME (1 << GLIBTOP_SYSDEPS_PROC_TIME) -#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_MAP (1 << GLIBTOP_SYSDEPS_PROC_MAP) - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/sun4/glibtop_suid.h b/sysdeps/sun4/glibtop_suid.h deleted file mode 100644 index a11e5ea6..00000000 --- a/sysdeps/sun4/glibtop_suid.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __GLIBTOP_SUID_H__ -#define __GLIBTOP_SUID_H__ - -BEGIN_LIBGTOP_DECLS - -static inline void glibtop_suid_enter (glibtop *server) { - setregid (server->machine.gid, server->machine.egid); -}; - -static inline void glibtop_suid_leave (glibtop *server) { - if (setregid (server->machine.egid, server->machine.gid)) - _exit (1); -}; - -void -glibtop_init_p (glibtop *server, const unsigned long features, - const unsigned flags); -void -glibtop_open_p (glibtop *server, const char *program_name, - const unsigned long features, - const unsigned flags); - -END_LIBGTOP_DECLS - -#endif diff --git a/sysdeps/sun4/loadavg.c b/sysdeps/sun4/loadavg.c deleted file mode 100644 index 66a88d3a..00000000 --- a/sysdeps/sun4/loadavg.c +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/loadavg.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_loadavg = -(1L << GLIBTOP_LOADAVG_LOADAVG); - -/* Provides load averange. */ - -int -glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf) -{ - load_avg avenrun [3]; - int i; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_LOADAVG), 0); - - memset (buf, 0, sizeof (glibtop_loadavg)); - - /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ - - setregid (server->machine.gid, server->machine.egid); - - /* get the load average array */ - - (void) _glibtop_getkval (server, _glibtop_nlist [X_AVENRUN].n_value, - (int *) avenrun, sizeof (avenrun), - _glibtop_nlist [X_AVENRUN].n_name); - - if (setregid (server->machine.egid, server->machine.gid)) - _exit (1); - - /* !!! END OF SGID KMEM PART !!! */ - - for (i = 0; i < 3; i++) { - /* Calculate loadavg values from avenrun. */ - buf->loadavg [i] = loaddouble (avenrun [i]); - } - - /* Now we can set the flags. */ - - buf->flags = _glibtop_sysdeps_loadavg; -} diff --git a/sysdeps/sun4/loadavg.h b/sysdeps/sun4/loadavg.h deleted file mode 100644 index f2c20d81..00000000 --- a/sysdeps/sun4/loadavg.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* - * Top - a top users display for Berkeley Unix - * - * Defines required to access load average figures. - * - * This include file sets up everything we need to access the load average - * values in the kernel in a machine independent way. First, it sets the - * typedef "load_avg" to be either double or long (depending on what is - * needed), then it defines these macros appropriately: - * - * loaddouble(la) - convert load_avg to double. - * intload(i) - convert integer to load_avg. - */ - -/* - * We assume that if FSCALE is defined, then avenrun and ccpu are type long. - * If your machine is an exception (mips, perhaps?) then make adjustments - * here. - * - * Defined types: load_avg for load averages, pctcpu for cpu percentages. - */ -#if defined(mips) && !defined(NetBSD) -# include <sys/fixpoint.h> -# if defined(FBITS) && !defined(FSCALE) -# define FSCALE (1 << FBITS) /* mips */ -# endif -#endif - -#ifdef FSCALE -# define FIXED_LOADAVG FSCALE -# define FIXED_PCTCPU FSCALE -#endif - -#ifdef ibm032 -# undef FIXED_LOADAVG -# undef FIXED_PCTCPU -# define FIXED_PCTCPU PCT_SCALE -#endif - - -#ifdef FIXED_PCTCPU -typedef long pctcpu; -# define pctdouble(p) ((double)(p) / FIXED_PCTCPU) -#else -typedef double pctcpu; -# define pctdouble(p) (p) -#endif - -#ifdef FIXED_LOADAVG -typedef long load_avg; -# define loaddouble(la) ((double)(la) / FIXED_LOADAVG) -# define intload(i) ((int)((i) * FIXED_LOADAVG)) -#else -typedef double load_avg; -# define loaddouble(la) (la) -# define intload(i) ((double)(i)) -#endif diff --git a/sysdeps/sun4/mem.c b/sysdeps/sun4/mem.c deleted file mode 100644 index 6bc327e2..00000000 --- a/sysdeps/sun4/mem.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/mem.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_mem = -(1L << GLIBTOP_MEM_TOTAL) + (1L << GLIBTOP_MEM_USED) + -(1L << GLIBTOP_MEM_FREE) + (1L << GLIBTOP_MEM_LOCKED); - -/* define pagetok in terms of pageshift */ - -#define pagetok(size) ((size) << server->machine.pageshift) - -/* Provides information about memory usage. */ - -int -glibtop_get_mem_p (glibtop *server, glibtop_mem *buf) -{ - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MEM), 0); - - memset (buf, 0, sizeof (glibtop_mem)); - - /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ - - glibtop_suid_enter (server); - - /* get the array of physpage descriptors */ - - (void) _glibtop_getkval (server, server->machine.pages, - (int *) server->machine.physpage, - server->machine.bytesize, - "array _page"); - - glibtop_suid_leave (server); - - /* !!! END OF SGID KMEM PART !!! */ - - - { /* sum memory statistics */ - register struct page *pp; - register int cnt; - register int inuse; - register int free; - register int locked; - - /* bop thru the array counting page types */ - - pp = server->machine.physpage; - inuse = free = locked = 0; - for (cnt = server->machine.count; --cnt >= 0; pp++) { - if (pp->p_free) - free++; - else if (pp->p_lock || pp->p_keepcnt > 0) - locked++; - else - inuse++; - } - - /* convert memory stats to Kbytes */ - - buf->total = pagetok (inuse + free); - buf->used = pagetok (inuse); - buf->free = pagetok (free); - buf->locked = pagetok (locked); - - buf->flags = _glibtop_sysdeps_mem; - } -} diff --git a/sysdeps/sun4/msg_limits.c b/sysdeps/sun4/msg_limits.c deleted file mode 100644 index 7b997f5c..00000000 --- a/sysdeps/sun4/msg_limits.c +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/msg_limits.h> - -#include <glibtop_suid.h> - -/* #define KERNEL to get declaration of `struct msginfo'. */ - -#define KERNEL - -#include <sys/ipc.h> -#include <sys/msg.h> - -static const unsigned long _glibtop_sysdeps_msg_limits = -(1L << GLIBTOP_MSG_LIMITS_MSGMAP) + (1L << GLIBTOP_MSG_LIMITS_MSGMAX) + -(1L << GLIBTOP_MSG_LIMITS_MSGMNB) + (1L << GLIBTOP_MSG_LIMITS_MSGMNI) + -(1L << GLIBTOP_MSG_LIMITS_MSGSSZ) + (1L << GLIBTOP_MSG_LIMITS_MSGTQL); - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf) -{ - struct msginfo msginfo; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0); - - memset (buf, 0, sizeof (glibtop_msg_limits)); - - /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ - - setregid (server->machine.gid, server->machine.egid); - - /* get the load average array */ - - (void) _glibtop_getkval (server, _glibtop_nlist [X_MSGINFO].n_value, - (int *) &msginfo, sizeof (msginfo), - _glibtop_nlist [X_MSGINFO].n_name); - - if (setregid (server->machine.egid, server->machine.gid)) - _exit (1); - - /* !!! END OF SGID KMEM PART !!! */ - - buf->msgmap = msginfo.msgmap; - buf->msgmax = msginfo.msgmax; - buf->msgmnb = msginfo.msgmnb; - buf->msgmni = msginfo.msgmni; - buf->msgssz = msginfo.msgssz; - buf->msgtql = msginfo.msgtql; - - buf->flags = _glibtop_sysdeps_msg_limits; -} diff --git a/sysdeps/sun4/nosuid.c b/sysdeps/sun4/nosuid.c deleted file mode 100644 index 0ee13dc4..00000000 --- a/sysdeps/sun4/nosuid.c +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/open.h> -#include <glibtop/close.h> - -void -glibtop_open_s (glibtop *server, const char *program_name, - const unsigned long features, const unsigned flags) -{ } - -void -glibtop_close_s (glibtop *server) -{ } diff --git a/sysdeps/sun4/open.c b/sysdeps/sun4/open.c deleted file mode 100644 index e5f4d315..00000000 --- a/sysdeps/sun4/open.c +++ /dev/null @@ -1,310 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/open.h> -#include <glibtop/xmalloc.h> - -struct nlist _glibtop_nlist[] = { -#ifdef i386 - { "avenrun" }, /* 0 */ - { "ccpu" }, /* 1 */ - { "mpid" }, /* 2 */ - { "nproc" }, /* 3 */ - { "proc" }, /* 4 */ - { "total" }, /* 5 */ - { "cp_time" }, /* 6 */ - { "pages" }, /* 7 */ - { "epages" }, /* 8 */ - { "shminfo" }, /* 9 */ - { "msginfo" }, /* 10 */ - { "seminfo" }, /* 11 */ -#else - { "_avenrun" }, /* 0 */ - { "_ccpu" }, /* 1 */ - { "_mpid" }, /* 2 */ - { "_nproc" }, /* 3 */ - { "_proc" }, /* 4 */ - { "_total" }, /* 5 */ - { "_cp_time" }, /* 6 */ - { "_pages" }, /* 7 */ - { "_epages" }, /* 8 */ - { "_shminfo" }, /* 9 */ - { "_msginfo" }, /* 10 */ - { "_seminfo" }, /* 11 */ -#ifdef MULTIPROCESSOR - { "_ncpu" }, - { "_mp_time" }, -#endif -#endif - { 0 } -}; - -/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ - -/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ - -void -glibtop_init_p (glibtop *server, const unsigned long features, - const unsigned flags) -{ - if (server == NULL) - glibtop_error_r (NULL, "glibtop_init_p (server == NULL)"); - - glibtop_open_p (server, "glibtop", features, flags); -} - -void -glibtop_open_p (glibtop *server, const char *program_name, - const unsigned long features, const unsigned flags) -{ - register int pagesize; - - /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ - - server->name = program_name; - - server->machine.uid = getuid (); - server->machine.euid = geteuid (); - server->machine.gid = getgid (); - server->machine.egid = getegid (); - - /* initialize the kernel interface */ - - server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "libgtop"); - - if (server->machine.kd == NULL) - glibtop_error_io_r (server, "kvm_open"); - - /* get the list of symbols we want to access in the kernel */ - - server->machine.nlist_count = kvm_nlist - (server->machine.kd, _glibtop_nlist); - - if (server->machine.nlist_count < 0) - glibtop_error_io_r (server, "nlist"); - -#ifdef MULTIPROCESSOR - /* were ncpu and xp_time not found in the nlist? */ - - if ((server->machine.nlist_count > 0) && - (_glibtop_nlist[X_NCPU].n_type == 0) && - (_glibtop_nlist[X_MP_TIME].n_type == 0)) { - /* we were compiled on an MP system but we are not running - * on one, so we will pretend this didn't happen and set - * ncpu = 1 */ - server->machine.nlist_count -= 2; - server->machine.ncpu = 1; - } -#endif - -#ifdef solbourne - { - unsigned int status, type; - - /* Get the number of CPUs on this system. */ - syscall(SYS_getcpustatus, &status, - &server->machine.ncpu, &type); - } -#endif - - /* Make sure all of the symbols were found. */ - - if ((server->machine.nlist_count > 0) && - (_glibtop_check_nlist (server, _glibtop_nlist) > 0)) - _exit (1); - - /* Get process array stuff. */ - - (void) _glibtop_getkval (server, _glibtop_nlist[X_NPROC].n_value, - (int *)(&server->machine.nproc), - sizeof (server->machine.nproc), - _glibtop_nlist[X_NPROC].n_name); - - (void) _glibtop_getkval (server, _glibtop_nlist[X_PROC].n_value, - (int *)(&server->machine.ptable_offset), - sizeof (server->machine.ptable_offset), - _glibtop_nlist[X_PROC].n_name); - - server->machine.ptable_size = (unsigned long) server->machine.nproc * - (unsigned long) sizeof (struct proc); - - server->machine.proc_table = glibtop_malloc_r - (server, server->machine.ptable_size); - - /* This are for the memory statistics. */ - - (void) _glibtop_getkval (server, _glibtop_nlist[X_PAGES].n_value, - (int *)(&server->machine.pages), - sizeof (server->machine.pages), - _glibtop_nlist[X_PAGES].n_name); - - (void) _glibtop_getkval (server, _glibtop_nlist[X_EPAGES].n_value, - (int *)(&server->machine.epages), - sizeof (server->machine.epages), - _glibtop_nlist[X_EPAGES].n_name); - - server->machine.bytesize = server->machine.epages - - server->machine.pages; - server->machine.count = server->machine.bytesize / - sizeof (struct page); - - server->machine.physpage = (struct page *) - glibtop_malloc_r (server, server->machine.bytesize); - - /* get the page size with "getpagesize" and - * calculate pageshift from it */ - - pagesize = getpagesize(); - - server->machine.pageshift = 0; - - while (pagesize > 1) { - server->machine.pageshift++; - pagesize >>= 1; - } - - /* we only need the amount of log(2)1024 for our conversion */ - - server->machine.pageshift -= LOG1024; - - /* Drop priviledges. */ - - if (setreuid (server->machine.euid, server->machine.uid)) - _exit (1); - - if (setregid (server->machine.egid, server->machine.gid)) - _exit (1); - - /* !!! END OF SUID ROOT PART !!! */ - - /* Our effective uid is now those of the user invoking the server, - * so we do no longer have any priviledges. */ - - /* NOTE: On SunOS, we do not need to be suid root, we just need to - * be sgid kmem. - * - * The server will only use setegid() to get back it's priviledges, - * so it will fail if it is suid root and not sgid kmem. */ -} - -/* Used internally. Returns number of symbols that cannot be found in - * the nlist. */ - -int -_glibtop_check_nlist (void *server, register struct nlist *nlst) -{ - register int not_found; - - /* check to see if we got ALL the symbols we requested */ - /* this will write one line to stderr for every symbol not found */ - - not_found = 0; - - while (nlst->n_name != NULL) { - -#ifdef i386 - if (nlst->n_value == 0) { - glibtop_error_r (server, - "kernel: no symbol named `%s'", - nlst->n_name); - not_found++; - } -#else - if (nlst->n_type == 0) { - glibtop_error_r (server, - "kernel: no symbol named `%s'", - nlst->n_name); - not_found++; - } -#endif - - nlst++; - } - - return not_found; -} - -/* Used internally. Fetches value from kernel. */ - -int -_glibtop_getkval (void *void_server, unsigned long offset, int *ptr, - int size, char *refstr) -{ - glibtop *server = (glibtop *) void_server; - - if (kvm_read (server->machine.kd, offset, ptr, size) != size) - { - if (*refstr == '!') return 0; - - glibtop_error_r (server, "kvm_read(%s): %s", - refstr, strerror (errno)); - } - - return 1; -} - -/* Used internally. Reads process table from kernel. */ - -void -_glibtop_read_proc_table (void *void_server) -{ - glibtop *server = (glibtop *) void_server; - - /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ - - setregid (server->machine.gid, server->machine.egid); - - /* Read process table from kernel. */ - - (void) _glibtop_getkval (server, server->machine.ptable_offset, - (int *) server->machine.proc_table, - (size_t) server->machine.ptable_size, - _glibtop_nlist[X_PROC].n_name); - - if (setregid (server->machine.egid, server->machine.gid)) - _exit (1); - - /* !!! END OF SGID KMEM PART !!! */ -} - -/* Used internally. Finds pid in process table. */ - -struct proc * -_glibtop_find_pid (void *void_server, pid_t pid) -{ - register struct proc *pp; - register int i; - - glibtop *server = (glibtop *) void_server; - - for (pp = server->machine.proc_table, i = 0; - i < server->machine.nproc; pp++, i++) { - if ((pp->p_stat != 0) && (pp->p_pid == pid)) - return pp; - } - - return NULL; -} diff --git a/sysdeps/sun4/ppp.c b/sysdeps/sun4/ppp.c deleted file mode 100644 index 4f738ff2..00000000 --- a/sysdeps/sun4/ppp.c +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. 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/ppp.h> - -static const unsigned long _glibtop_sysdeps_ppp = 0; - -/* Init function. */ - -int -glibtop_init_ppp_s (glibtop *server) -{ - server->sysdeps.ppp = _glibtop_sysdeps_ppp; -} - -/* Provides PPP/ISDN information. */ - -int -glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device) -{ - memset (buf, 0, sizeof (glibtop_ppp)); -} diff --git a/sysdeps/sun4/procdata.c b/sysdeps/sun4/procdata.c deleted file mode 100644 index fdeb4db5..00000000 --- a/sysdeps/sun4/procdata.c +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/procdata.h> - -/* Provides detailed information about a process. */ - -void -glibtop_get_procdata_p (glibtop *server, glibtop_procdata *buf, pid_t pid) -{ - memset (buf, 0, sizeof (glibtop_procdata)); -} diff --git a/sysdeps/sun4/prockernel.c b/sysdeps/sun4/prockernel.c deleted file mode 100644 index 8011469c..00000000 --- a/sysdeps/sun4/prockernel.c +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/prockernel.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_kernel = -(1L << GLIBTOP_PROC_KERNEL_K_FLAGS) + (1L << GLIBTOP_PROC_KERNEL_WCHAN); - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf, - pid_t pid) -{ - struct proc *pp; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0); - - memset (buf, 0, sizeof (glibtop_proc_kernel)); - - /* Read process table from kernel. */ - - _glibtop_read_proc_table (server); - - /* Find the pid in the process table. */ - - pp = _glibtop_find_pid (server, pid); - - if (pp == NULL) return; - - /* Fill in data fields. */ - - buf->k_flags = pp->p_flag; - buf->nwchan = (unsigned long) pp->p_wchan; - - buf->flags = _glibtop_sysdeps_proc_kernel; -} diff --git a/sysdeps/sun4/proclist.c b/sysdeps/sun4/proclist.c deleted file mode 100644 index 1239c57a..00000000 --- a/sysdeps/sun4/proclist.c +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/xmalloc.h> -#include <glibtop/proclist.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proclist = -(1L << GLIBTOP_PROCLIST_TOTAL) + (1L << GLIBTOP_PROCLIST_NUMBER) + -(1L << GLIBTOP_PROCLIST_SIZE); - -/* Fetch list of currently running processes. - * - * IMPORTANT NOTE: - * On error, this function MUST return NULL and set buf->flags to zero ! - * On success, it returnes a pointer to a list of buf->number elements - * each buf->size big. The total size is stored in buf->total. */ - -unsigned * -glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf, - int64_t which, int64_t arg) -{ - register struct proc *pp; - register int i, nproc = 0; - unsigned *proc_list = NULL; - size_t proc_size; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0); - - memset (buf, 0, sizeof (glibtop_proclist)); - - /* Read process table from kernel. */ - - _glibtop_read_proc_table (server); - - /* Count number of processes. */ - - for (pp = server->machine.proc_table, i = 0; - i < server->machine.nproc; pp++, i++) { - if (pp->p_stat == 0) - continue; - else - nproc++; - } - - if (nproc == 0) /* Should never happen. */ - return NULL; - - /* Allocate space for process list. */ - - proc_size = nproc * sizeof (unsigned); - - proc_list = glibtop_malloc_r (server, proc_size); - - /* Write process list. */ - - for (pp = server->machine.proc_table, i = 0, nproc = 0; - i < server->machine.nproc; pp++, i++) { - if (pp->p_stat == 0) - continue; - proc_list [nproc++] = pp->p_pid; - } - - /* Since everything is ok now, we can set buf->flags, fill in the remaining fields - and return proc_list. */ - - buf->flags = _glibtop_sysdeps_proclist; - - buf->size = sizeof (unsigned); - buf->number = nproc; - - buf->total = nproc * sizeof (unsigned); - - return proc_list; -} diff --git a/sysdeps/sun4/procmem.c b/sysdeps/sun4/procmem.c deleted file mode 100644 index 5bbf8852..00000000 --- a/sysdeps/sun4/procmem.c +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <config.h> -#include <glibtop/procmem.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_mem = -(1L << GLIBTOP_PROC_MEM_SIZE) + (1L << GLIBTOP_PROC_MEM_RSS) + -(1L << GLIBTOP_PROC_MEM_RSS_RLIM); - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf, - pid_t pid) -{ - struct proc *pp; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MEM), 0); - - memset (buf, 0, sizeof (glibtop_proc_mem)); - - /* Read process table from kernel. */ - - _glibtop_read_proc_table (server); - - /* Find the pid in the process table. */ - - pp = _glibtop_find_pid (server, pid); - - if (pp == NULL) return; - - /* Fill in data fields. */ - - buf->size = (pp)->p_tsize + (pp)->p_dsize + (pp)->p_ssize; - - buf->rss = pp->p_rssize; - buf->rss_rlim = pp->p_maxrss; - - buf->flags = _glibtop_sysdeps_proc_mem; -} diff --git a/sysdeps/sun4/procsegment.c b/sysdeps/sun4/procsegment.c deleted file mode 100644 index 7c09ee6b..00000000 --- a/sysdeps/sun4/procsegment.c +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procsegment.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_segment = -(1L << GLIBTOP_PROC_SEGMENT_TEXT_RSS) + -(1L << GLIBTOP_PROC_SEGMENT_DATA_RSS); - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf, - pid_t pid) -{ - struct proc *pp; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0); - - memset (buf, 0, sizeof (glibtop_proc_segment)); - - /* Read process table from kernel. */ - - _glibtop_read_proc_table (server); - - /* Find the pid in the process table. */ - - pp = _glibtop_find_pid (server, pid); - - if (pp == NULL) return; - - /* Fill in data fields. */ - - buf->text_rss = pp->p_tsize; - buf->data_rss = pp->p_dsize; - - buf->flags = _glibtop_sysdeps_proc_segment; -} diff --git a/sysdeps/sun4/procsignal.c b/sysdeps/sun4/procsignal.c deleted file mode 100644 index 216c420d..00000000 --- a/sysdeps/sun4/procsignal.c +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procsignal.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_signal = -(1L << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1L << GLIBTOP_PROC_SIGNAL_BLOCKED) + -(1L << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1L << GLIBTOP_PROC_SIGNAL_SIGCATCH); - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf, - pid_t pid) -{ - struct proc *pp; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0); - - memset (buf, 0, sizeof (glibtop_proc_signal)); - - /* Read process table from kernel. */ - - _glibtop_read_proc_table (server); - - /* Find the pid in the process table. */ - - pp = _glibtop_find_pid (server, pid); - - if (pp == NULL) return; - - /* Fill in data fields. */ - - buf->signal [0] = pp->p_sig; - buf->blocked [0] = pp->p_sigmask; - buf->sigignore [0] = pp->p_sigignore; - buf->sigcatch [0] = pp->p_sigcatch; - - buf->flags = _glibtop_sysdeps_proc_signal; -} diff --git a/sysdeps/sun4/procstate.c b/sysdeps/sun4/procstate.c deleted file mode 100644 index 4fffd8bd..00000000 --- a/sysdeps/sun4/procstate.c +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procstate.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_state = -(1L << GLIBTOP_PROC_STATE_STATE) + (1L << GLIBTOP_PROC_STATE_UID); - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf, - pid_t pid) -{ - struct proc *pp; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_STATE), 0); - - memset (buf, 0, sizeof (glibtop_proc_state)); - - /* Read process table from kernel. */ - - _glibtop_read_proc_table (server); - - /* Find the pid in the process table. */ - - pp = _glibtop_find_pid (server, pid); - - if (pp == NULL) return; - - /* Fill in data fields. */ - - buf->state = pp->p_stat; - buf->uid = pp->p_uid; - - buf->flags = _glibtop_sysdeps_proc_state; -} diff --git a/sysdeps/sun4/proctime.c b/sysdeps/sun4/proctime.c deleted file mode 100644 index c18376c2..00000000 --- a/sysdeps/sun4/proctime.c +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/proctime.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_time = -(1L << GLIBTOP_PROC_TIME_START_TIME) + (1L << GLIBTOP_PROC_TIME_UTIME); - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf, - pid_t pid) -{ - struct proc *pp; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0); - - memset (buf, 0, sizeof (glibtop_proc_time)); - - /* Read process table from kernel. */ - - _glibtop_read_proc_table (server); - - /* Find the pid in the process table. */ - - pp = _glibtop_find_pid (server, pid); - - if (pp == NULL) return; - - /* Fill in data fields. */ - - buf->start_time = pp->p_time; - buf->utime = pp->p_cpticks; - - buf->flags = _glibtop_sysdeps_proc_time; -} diff --git a/sysdeps/sun4/procuid.c b/sysdeps/sun4/procuid.c deleted file mode 100644 index c1b52ebc..00000000 --- a/sysdeps/sun4/procuid.c +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/procuid.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_proc_uid = -(1L << GLIBTOP_PROC_UID_UID) + (1L << GLIBTOP_PROC_UID_EUID) + -(1L << GLIBTOP_PROC_UID_EGID) + (1L << GLIBTOP_PROC_UID_PID) + -(1L << GLIBTOP_PROC_UID_PPID) + (1L << GLIBTOP_PROC_UID_PGRP) + -(1L << GLIBTOP_PROC_UID_TPGID) + (1L << GLIBTOP_PROC_UID_PRIORITY) + -(1L << GLIBTOP_PROC_UID_NICE); - -/* Provides detailed information about a process. */ - -int -glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf, - pid_t pid) -{ - struct proc *pp; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_UID), 0); - - memset (buf, 0, sizeof (glibtop_proc_uid)); - - /* Read process table from kernel. */ - - _glibtop_read_proc_table (server); - - /* Find the pid in the process table. */ - - pp = _glibtop_find_pid (server, pid); - - if (pp == NULL) return; - - /* Fill in data fields. */ - - buf->uid = pp->p_uid; - buf->euid = pp->p_suid; - buf->egid = pp->p_sgid; - buf->pid = pp->p_pid; - buf->ppid = pp->p_ppid; - buf->pgrp = pp->p_pgrp; - buf->tpgid = pp->p_pgrp; - buf->priority = pp->p_pri; - buf->nice = pp->p_nice; - - buf->flags = _glibtop_sysdeps_proc_uid; -} diff --git a/sysdeps/sun4/sem_limits.c b/sysdeps/sun4/sem_limits.c deleted file mode 100644 index df29ba5f..00000000 --- a/sysdeps/sun4/sem_limits.c +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/sem_limits.h> - -#include <glibtop_suid.h> - -/* #define KERNEL to get declaration of `struct seminfo'. */ - -#define KERNEL - -#include <sys/ipc.h> -#include <sys/sem.h> - -static unsigned long _glibtop_sysdeps_sem_limits = -(1L << GLIBTOP_SEM_LIMITS_SEMMAP) + (1L << GLIBTOP_SEM_LIMITS_SEMMNI) + -(1L << GLIBTOP_SEM_LIMITS_SEMMNS) + (1L << GLIBTOP_SEM_LIMITS_SEMMNU) + -(1L << GLIBTOP_SEM_LIMITS_SEMMSL) + (1L << GLIBTOP_SEM_LIMITS_SEMOPM) + -(1L << GLIBTOP_SEM_LIMITS_SEMUME) + (1L << GLIBTOP_SEM_LIMITS_SEMUSZ) + -(1L << GLIBTOP_SEM_LIMITS_SEMVMX) + (1L << GLIBTOP_SEM_LIMITS_SEMAEM); - -/* Provides information about sysv sem limits. */ - -int -glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf) -{ - struct seminfo seminfo; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0); - - memset (buf, 0, sizeof (glibtop_sem_limits)); - - /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ - - setregid (server->machine.gid, server->machine.egid); - - /* get the load average array */ - - (void) _glibtop_getkval (server, _glibtop_nlist [X_SEMINFO].n_value, - (int *) &seminfo, sizeof (seminfo), - _glibtop_nlist [X_SEMINFO].n_name); - - if (setregid (server->machine.egid, server->machine.gid)) - _exit (1); - - /* !!! END OF SGID KMEM PART !!! */ - - buf->semmap = seminfo.semmap; - buf->semmni = seminfo.semmni; - buf->semmns = seminfo.semmns; - buf->semmnu = seminfo.semmnu; - buf->semmsl = seminfo.semmsl; - buf->semopm = seminfo.semopm; - buf->semume = seminfo.semume; - buf->semusz = seminfo.semusz; - buf->semvmx = seminfo.semvmx; - buf->semaem = seminfo.semaem; - - buf->flags = _glibtop_sysdeps_sem_limits; -} diff --git a/sysdeps/sun4/shm_limits.c b/sysdeps/sun4/shm_limits.c deleted file mode 100644 index 842d843e..00000000 --- a/sysdeps/sun4/shm_limits.c +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/shm_limits.h> - -#include <glibtop_suid.h> - -/* #define KERNEL to get declaration of `struct shminfo'. */ - -#define KERNEL - -#include <sys/ipc.h> -#include <sys/shm.h> - -static unsigned long _glibtop_sysdeps_shm_limits = -(1L << GLIBTOP_SHM_LIMITS_SHMMAX) + (1L << GLIBTOP_SHM_LIMITS_SHMMIN) + -(1L << GLIBTOP_SHM_LIMITS_SHMMNI) + (1L << GLIBTOP_SHM_LIMITS_SHMSEG) + -(1L << GLIBTOP_SHM_LIMITS_SHMALL); - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf) -{ - struct shminfo shminfo; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0); - - memset (buf, 0, sizeof (glibtop_shm_limits)); - - /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ - - setregid (server->machine.gid, server->machine.egid); - - /* get the load average array */ - - (void) _glibtop_getkval (server, _glibtop_nlist [X_SHMINFO].n_value, - (int *) &shminfo, sizeof (shminfo), - _glibtop_nlist [X_SHMINFO].n_name); - - if (setregid (server->machine.egid, server->machine.gid)) - _exit (1); - - /* !!! END OF SGID KMEM PART !!! */ - - buf->shmmax = shminfo.shmmax; - buf->shmmin = shminfo.shmmin; - buf->shmmni = shminfo.shmmni; - buf->shmseg = shminfo.shmseg; - buf->shmall = shminfo.shmall; - - buf->flags = _glibtop_sysdeps_shm_limits; -} diff --git a/sysdeps/sun4/swap.c b/sysdeps/sun4/swap.c deleted file mode 100644 index ac6bfa39..00000000 --- a/sysdeps/sun4/swap.c +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/swap.h> - -#include <glibtop_suid.h> - -/* Provides information about swap usage. */ - -int -glibtop_get_swap_p (glibtop *server, glibtop_swap *buf) -{ - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SWAP), 0); - - memset (buf, 0, sizeof (glibtop_swap)); -} diff --git a/sysdeps/sun4/uptime.c b/sysdeps/sun4/uptime.c deleted file mode 100644 index 35db26f1..00000000 --- a/sysdeps/sun4/uptime.c +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. - - LibGTop is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - LibGTop 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with LibGTop; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include <glibtop.h> -#include <glibtop/cpu.h> -#include <glibtop/uptime.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_uptime = -(1L << GLIBTOP_UPTIME_UPTIME) + (1L << GLIBTOP_UPTIME_IDLETIME); - -/* Provides uptime and idle time. */ - -int -glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf) -{ - glibtop_cpu cpu; - - glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0); - - /* Get currect cpu usage. */ - - glibtop_get_cpu_p (server, &cpu); - - /* Make sure all required fields are present. */ - - if (((cpu.flags & (1L << GLIBTOP_CPU_TOTAL)) == 0) || - ((cpu.flags & (1L << GLIBTOP_CPU_IDLE)) == 0) || - ((cpu.flags & (1L << GLIBTOP_CPU_FREQUENCY)) == 0) || - (cpu.frequency == 0)) - return; - - /* Simply calculate uptime and idle time from - * cpu usage. */ - - buf->uptime = (double) cpu.total / (double) cpu.frequency; - buf->idletime = (double) cpu.idle / (double) cpu.frequency; - - buf->flags = _glibtop_sysdeps_uptime; -} |