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/solaris | |
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/solaris')
36 files changed, 0 insertions, 3399 deletions
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; -} |