From 3455d025a22f08389c2135f7757c166e64c6643c Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 22 Jan 2000 23:32:49 +0000 Subject: [PATCH] This is now a LibGTop backend which can be loaded additionally to the 2000-01-23 Martin Baulig This is now a LibGTop backend which can be loaded additionally to the normal Linux sysdeps code. * open.c, close.c: Removed. * shm_limits.c, msg_limits.c, sem_limits.c, ppp.c: Removed. * siglist.c, sysinfo.c: Removed. * backend-kernel.c: New file. * glibtop-backend-private.h: New file. * libgtop-kernel.backend: New file. * backend-kernel.pl: New file. Automatically creates `backend-kernel.h'. * marshal.pl: New file. Automatically creates `marshal.c'. * glibtop_server.h: Replaced all `GLIBTOP_SUID_' constants with `GLIBTOP_IMPL_' ones; they're used in marshal.c to find out which features this backend implements. * *.c: Renamed all `glibtop_get__s' functions to `glibtop_get__k' and all `glibtop_init__s' ones to `glibtop_init__k'. --- sysdeps/kernel/.cvsignore | 4 +- sysdeps/kernel/ChangeLog | 26 +++ sysdeps/kernel/Makefile.am | 54 ++++- sysdeps/kernel/backend-kernel.c | 88 ++++++++ sysdeps/kernel/backend-kernel.pl | 152 +++++++++++++ sysdeps/kernel/cpu.c | 6 +- .../{close.c => glibtop-backend-private.h} | 12 +- sysdeps/kernel/glibtop_private.h | 28 +-- sysdeps/kernel/glibtop_server.h | 42 ++-- sysdeps/kernel/interfaces.c | 6 +- sysdeps/kernel/libgtop-kernel.backend | 12 + sysdeps/kernel/loadavg.c | 6 +- sysdeps/kernel/marshal.pl | 201 +++++++++++++++++ sysdeps/kernel/mem.c | 6 +- sysdeps/kernel/msg_limits.c | 72 ------ sysdeps/kernel/netinfo.c | 4 +- sysdeps/kernel/netload.c | 6 +- sysdeps/kernel/open.c | 35 --- sysdeps/kernel/ppp.c | 208 ------------------ sysdeps/kernel/procargs.c | 6 +- sysdeps/kernel/procdata.c | 22 +- sysdeps/kernel/prockernel.c | 8 +- sysdeps/kernel/proclist.c | 6 +- sysdeps/kernel/procmap.c | 8 +- sysdeps/kernel/procmem.c | 6 +- sysdeps/kernel/procsegment.c | 8 +- sysdeps/kernel/procsignal.c | 6 +- sysdeps/kernel/procstate.c | 6 +- sysdeps/kernel/proctime.c | 6 +- sysdeps/kernel/procuid.c | 6 +- sysdeps/kernel/sem_limits.c | 93 -------- sysdeps/kernel/shm_limits.c | 69 ------ sysdeps/kernel/siglist.c | 62 ------ sysdeps/kernel/swap.c | 8 +- sysdeps/kernel/sysinfo.c | 98 --------- sysdeps/kernel/uptime.c | 6 +- 36 files changed, 637 insertions(+), 755 deletions(-) create mode 100644 sysdeps/kernel/backend-kernel.c create mode 100644 sysdeps/kernel/backend-kernel.pl rename sysdeps/kernel/{close.c => glibtop-backend-private.h} (87%) create mode 100644 sysdeps/kernel/libgtop-kernel.backend create mode 100644 sysdeps/kernel/marshal.pl delete mode 100644 sysdeps/kernel/msg_limits.c delete mode 100644 sysdeps/kernel/open.c delete mode 100644 sysdeps/kernel/ppp.c delete mode 100644 sysdeps/kernel/sem_limits.c delete mode 100644 sysdeps/kernel/shm_limits.c delete mode 100644 sysdeps/kernel/siglist.c delete mode 100644 sysdeps/kernel/sysinfo.c diff --git a/sysdeps/kernel/.cvsignore b/sysdeps/kernel/.cvsignore index 635816db..1eb1cdc4 100644 --- a/sysdeps/kernel/.cvsignore +++ b/sysdeps/kernel/.cvsignore @@ -2,5 +2,7 @@ .libs Makefile Makefile.in -libgtop_sysdeps.la *.lo +*.la +marshal.c +backend-kernel.h diff --git a/sysdeps/kernel/ChangeLog b/sysdeps/kernel/ChangeLog index fff6f250..04fdd990 100644 --- a/sysdeps/kernel/ChangeLog +++ b/sysdeps/kernel/ChangeLog @@ -1,3 +1,29 @@ +2000-01-23 Martin Baulig + + This is now a LibGTop backend which can be loaded additionally + to the normal Linux sysdeps code. + + * open.c, close.c: Removed. + * shm_limits.c, msg_limits.c, sem_limits.c, ppp.c: Removed. + * siglist.c, sysinfo.c: Removed. + + * backend-kernel.c: New file. + * glibtop-backend-private.h: New file. + * libgtop-kernel.backend: New file. + + * backend-kernel.pl: New file. Automatically creates + `backend-kernel.h'. + + * marshal.pl: New file. Automatically creates `marshal.c'. + + * glibtop_server.h: Replaced all `GLIBTOP_SUID_' constants + with `GLIBTOP_IMPL_' ones; they're used in marshal.c to + find out which features this backend implements. + + * *.c: Renamed all `glibtop_get__s' functions to + `glibtop_get__k' and all `glibtop_init__s' ones + to `glibtop_init__k'. + 1999-12-22 Martin Baulig * procdata.c: Distinguish between GLIBTOP_ERROR_NO_KERNEL_SUPPORT diff --git a/sysdeps/kernel/Makefile.am b/sysdeps/kernel/Makefile.am index 597ce2ee..216f342b 100644 --- a/sysdeps/kernel/Makefile.am +++ b/sysdeps/kernel/Makefile.am @@ -1,18 +1,48 @@ -LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +LINK = \ + $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @INCLUDES@ +INCLUDES = \ + @INCLUDES@ -lib_LTLIBRARIES = libgtop_sysdeps.la +backenddir = \ + @LIBGTOP_BACKEND_DIR@ -libgtop_sysdeps_la_SOURCES = open.c close.c siglist.c cpu.c mem.c swap.c \ - uptime.c loadavg.c shm_limits.c msg_limits.c \ - sem_limits.c proclist.c procstate.c procuid.c \ - proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c procargs.c procmap.c netload.c \ - netinfo.c interfaces.c ppp.c procdata.c \ - sysinfo.c +backend_LTLIBRARIES = \ + libgtop_backend_kernel.la -libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) +backend_DATA = \ + libgtop-kernel.backend -include_HEADERS = glibtop_server.h glibtop_private.h +libgtop_backend_kernel_la_SOURCES = \ + cpu.c mem.c swap.c uptime.c loadavg.c \ + proclist.c procstate.c procuid.c \ + proctime.c procmem.c procsignal.c prockernel.c \ + procsegment.c procargs.c procmap.c netload.c \ + netinfo.c interfaces.c procdata.c \ + backend-kernel.c marshal.c + +libgtop_backend_kernel_la_LDFLAGS = \ + $(LT_VERSION_INFO) + +noinst_HEADERS = \ + glibtop_server.h glibtop_private.h + +BUILT_SOURCES = \ + marshal.c \ + backend-kernel.h + +EXTRA_DIST = \ + marshal.pl \ + backend-kernel.pl \ + libgtop-sysdeps.backend + +CLEANFILES = $(BUILT_SOURCES) + +marshal.c: marshal.pl $(top_builddir)/config.h $(top_srcdir)/features.def $(top_srcdir)/scripts/c_types.pl + $(PERL) -I $(top_srcdir)/scripts $(srcdir)/marshal.pl < $(top_srcdir)/features.def > tmp-t + mv tmp-t marshal.c + +backend-kernel.h: backend-kernel.pl $(top_builddir)/config.h $(top_srcdir)/features.def $(top_srcdir)/scripts/c_types.pl + $(PERL) -I $(top_srcdir)/scripts $(srcdir)/backend-kernel.pl < $(top_srcdir)/features.def > tmp-t + mv tmp-t backend-kernel.h diff --git a/sysdeps/kernel/backend-kernel.c b/sysdeps/kernel/backend-kernel.c new file mode 100644 index 00000000..e60f5950 --- /dev/null +++ b/sysdeps/kernel/backend-kernel.c @@ -0,0 +1,88 @@ +/* -*- 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 , 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 +#include +#include + +#include +#include +#include + +#include + +static int +_open_kernel (glibtop *, glibtop_backend *, u_int64_t, const char **); + +static int +_close_kernel (glibtop *, glibtop_backend *); + +extern glibtop_call_vector glibtop_backend_kernel_call_vector; +extern glibtop_init_func_t _glibtop_init_hook_k []; + +glibtop_backend_info LibGTopBackendInfo = { + "glibtop-backend-kernel", _open_kernel, _close_kernel, + &glibtop_backend_kernel_call_vector +}; + +static int +_open_kernel (glibtop *server, glibtop_backend *backend, + u_int64_t features, const char **backend_args) +{ + glibtop_init_func_t *init_fkt; + int version, name [2] = { CTL_LIBGTOP, LIBGTOP_VERSION }; + size_t size = sizeof (int); + + if (sysctl (name, 2, &version, &size, NULL, 0)) { + if (errno == ENOTDIR) + return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT; + else + glibtop_warn_io_r (server, "sysctl (libgtop/stat)"); + return -1; + } + + backend->_priv = glibtop_calloc_r + (server, 1, sizeof (glibtop_backend_private)); + + /* Do the initialization, but only if not already initialized. */ + + if ((server->flags & _GLIBTOP_INIT_STATE_SYSDEPS) == 0) { + for (init_fkt = _glibtop_init_hook_k; *init_fkt; init_fkt++) + (*init_fkt) (server); + + server->sysdeps.pointer_size = sizeof (void*)*8; + + server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS; + } + + return 0; +} + +static int +_close_kernel (glibtop *server, glibtop_backend *backend) +{ + return -1; +} + diff --git a/sysdeps/kernel/backend-kernel.pl b/sysdeps/kernel/backend-kernel.pl new file mode 100644 index 00000000..a3ffa45b --- /dev/null +++ b/sysdeps/kernel/backend-kernel.pl @@ -0,0 +1,152 @@ +#!/usr/bin/perl + +require 'c_types.pl'; + +$[ = 1; # set array base to 1 +$, = ' '; # set output field separator +$\ = "\n"; # set output record separator + +$always_use_temp_storage = 1; + +sub toupper { + local($_) = @_; + tr/a-z/A-Z/; + return $_; +} + +sub tolower { + local($_) = @_; + tr/A-Z/a-z/; + return $_; +} + +print '/* backend-kernel.h */'; +print "/* This is a generated file. Please modify `backend-kernel.pl' */"; +print ''; + +print '#ifndef __GLIBTOP_BACKEND_KERNEL_H__'; +print '#define __GLIBTOP_BACKEND_KERNEL_H__'; +print ''; +print '#include '; +print '#include '; +print ''; +print 'BEGIN_LIBGTOP_DECLS'; +print ''; + +$feature_count = 0; + +while (<>) { + chop; # strip record separator + + if (/^[^#]/) { + &output($_); + } +} + +sub output { + local($line) = @_; + @line_fields = split(/\|/, $line, 9999); + $retval = $line_fields[1]; + $feature = $line_fields[2]; + $param_def = $line_fields[4]; + + $orig = $feature; + $feature =~ s/^@//; + $space = $feature; + $space =~ s/./ /g; + + $features{++$feature_count} = $orig; + + return if $orig =~ /^@/; + + if ($retval eq 'retval') { + $retval_param = '&retval'; + $call_prefix = ''; + $call_prefix_space = ''; + $prefix = 'retval = '; + $prefix_space = ' '; + $retval = 'int'; + } + elsif ($retval !~ /^void$/) { + $retval_param = 'NULL'; + $prefix = 'retval = '; + $prefix_space = ' '; + $call_prefix = 'retval = '; + $call_prefix_space = ' '; + } + else { + $retval_param = 'NULL'; + $call_prefix = ''; + $call_prefix_space = ''; + $prefix = ''; + $prefix_space = ''; + } + + if ($retval =~ /^(array|pointer)\((.*)\)$/) { + $retval = ($2 eq 'string') ? 'char **' : "$2 *"; + } + + $need_temp_storage = $always_use_temp_storage; + $first_param_name = ''; + + $call_param = ''; + $param_decl = ''; + $need_temp_len = 0; + $nr_params = (@params = split(/:/, $param_def, 9999)); + for ($param = 1; $param <= $nr_params; $param++) { + $list = $params[$param]; + $type = $params[$param]; + $type =~ s/\(.*//; + $list =~ s/^.*\(//; + $list =~ s/\)$//; + $count = (@fields = split(/,/, $list, 9999)); + for ($field = 1; $field <= $count; $field++) { + my $c_type = $typeinfo->{$type}->[1]; + + if ($first_param_name eq '') { + $first_param_name = $fields[$field]; + } + + if ($typeinfo->{$type}->[2]) { + $need_temp_storage = 1; + } + + if ($param_decl eq '') { + $param_decl = ",\n " . $space . ' '; + } + else { + $param_decl = $param_decl . ', '; + } + $param_decl = $param_decl . $c_type . ' ' . $fields[$field]; + $call_param = $call_param . ', ' . $fields[$field]; + } + } + + $func_decl = sprintf ("int\nglibtop_init_%s_k (glibtop *server);\n\n", + $feature); + + $func_decl .= $retval."\n"; + if ($line_fields[3] eq '') { + $func_decl .= sprintf ("glibtop_get_%s_k (glibtop *server%s);\n", + $feature, $param_decl); + } elsif ($line_fields[3] eq 'array') { + $func_decl .= sprintf ("glibtop_get_%s_k (glibtop *server, glibtop_array *array%s);\n", + $feature, $param_decl); + } elsif ($line_fields[3] =~ /^array/) { + $func_decl .= sprintf ("glibtop_get_%s_k (glibtop *server, glibtop_array *array, %s *buf%s);\n", + $feature, 'glibtop_'.$feature, $param_decl); + } else { + $func_decl .= sprintf ("glibtop_get_%s_k (glibtop *server, %s *buf%s);\n", + $feature, 'glibtop_'.$feature, $param_decl); + } + + $total_code = $func_decl; + + print $total_code; +} + +print ''; +print 'END_LIBGTOP_DECLS'; +print ''; +print '#endif'; +print ''; diff --git a/sysdeps/kernel/cpu.c b/sysdeps/kernel/cpu.c index 1019a2a4..8df5fef3 100644 --- a/sysdeps/kernel/cpu.c +++ b/sysdeps/kernel/cpu.c @@ -41,7 +41,7 @@ static const unsigned long _glibtop_sysdeps_cpu_smp = /* Init function. */ int -glibtop_init_cpu_s (glibtop *server) +glibtop_init_cpu_k (glibtop *server) { server->sysdeps.cpu = _glibtop_sysdeps_cpu; @@ -54,14 +54,14 @@ glibtop_init_cpu_s (glibtop *server) /* Provides information about cpu usage. */ int -glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) +glibtop_get_cpu_k (glibtop *server, glibtop_cpu *buf) { libgtop_stat_t stat; int retval, i; memset (buf, 0, sizeof (glibtop_cpu)); - retval = glibtop_get_proc_data_stat_s (server, &stat); + retval = glibtop_get_proc_data_stat_k (server, &stat); if (retval) return retval; diff --git a/sysdeps/kernel/close.c b/sysdeps/kernel/glibtop-backend-private.h similarity index 87% rename from sysdeps/kernel/close.c rename to sysdeps/kernel/glibtop-backend-private.h index 3378b817..81d485b6 100644 --- a/sysdeps/kernel/close.c +++ b/sysdeps/kernel/glibtop-backend-private.h @@ -23,10 +23,12 @@ Boston, MA 02111-1307, USA. */ -#include +#ifndef __GLIBTOP_BACKEND_PRIVATE_H__ +#define __GLIBTOP_BACKEND_PRIVATE_H__ -/* Closes pipe to gtop server. */ +struct _glibtop_backend_private +{ + u_int64_t flags; +}; -void -glibtop_close_s (glibtop *server) -{ } +#endif diff --git a/sysdeps/kernel/glibtop_private.h b/sysdeps/kernel/glibtop_private.h index d007f781..73485d7e 100644 --- a/sysdeps/kernel/glibtop_private.h +++ b/sysdeps/kernel/glibtop_private.h @@ -38,54 +38,56 @@ BEGIN_LIBGTOP_DECLS -int -glibtop_get_proc_data_stat_s (glibtop *server, libgtop_stat_t *stat); +#include "backend-kernel.h" int -glibtop_get_proc_data_mem_s (glibtop *server, libgtop_mem_t *mem); +glibtop_get_proc_data_stat_k (glibtop *server, libgtop_stat_t *stat); int -glibtop_get_proc_data_swap_s (glibtop *server, libgtop_swap_t *swap); +glibtop_get_proc_data_mem_k (glibtop *server, libgtop_mem_t *mem); int -glibtop_get_proc_data_proclist_s (glibtop *server, +glibtop_get_proc_data_swap_k (glibtop *server, libgtop_swap_t *swap); + +int +glibtop_get_proc_data_proclist_k (glibtop *server, libgtop_proclist_t *proclist, u_int64_t which, u_int64_t arg); int -glibtop_get_proc_data_proc_state_s (glibtop *server, +glibtop_get_proc_data_proc_state_k (glibtop *server, libgtop_proc_state_t *proc_state, pid_t pid); int -glibtop_get_proc_data_proc_mem_s (glibtop *server, +glibtop_get_proc_data_proc_mem_k (glibtop *server, libgtop_proc_mem_t *proc_mem, pid_t pid); int -glibtop_get_proc_data_proc_signal_s (glibtop *server, +glibtop_get_proc_data_proc_signal_k (glibtop *server, libgtop_proc_signal_t *proc_signal, pid_t pid); int -glibtop_get_proc_data_proc_kernel_s (glibtop *server, +glibtop_get_proc_data_proc_kernel_k (glibtop *server, libgtop_proc_kernel_t *proc_kernel, pid_t pid); int -glibtop_get_proc_data_proc_args_s (glibtop *server, pid_t pid, +glibtop_get_proc_data_proc_args_k (glibtop *server, pid_t pid, char *result, size_t max_len); int -glibtop_get_proc_data_proc_maps_s (glibtop *server, pid_t pid, +glibtop_get_proc_data_proc_maps_k (glibtop *server, pid_t pid, libgtop_proc_maps_t *result, size_t max_len); int -glibtop_get_proc_data_netload_s (glibtop *server, +glibtop_get_proc_data_netload_k (glibtop *server, libgtop_netload_t *netload, const char *device); END_LIBGTOP_DECLS -#endif __GLIBTOP_PRIVATE_H__ +#endif /* __GLIBTOP_PRIVATE_H__ */ diff --git a/sysdeps/kernel/glibtop_server.h b/sysdeps/kernel/glibtop_server.h index ce0acf4f..6165e63a 100644 --- a/sysdeps/kernel/glibtop_server.h +++ b/sysdeps/kernel/glibtop_server.h @@ -28,26 +28,28 @@ BEGIN_LIBGTOP_DECLS -#define GLIBTOP_SUID_CPU 0 -#define GLIBTOP_SUID_MEM 0 -#define GLIBTOP_SUID_SWAP 0 -#define GLIBTOP_SUID_UPTIME 0 -#define GLIBTOP_SUID_LOADAVG 0 -#define GLIBTOP_SUID_SHM_LIMITS 0 -#define GLIBTOP_SUID_MSG_LIMITS 0 -#define GLIBTOP_SUID_SEM_LIMITS 0 -#define GLIBTOP_SUID_PROCLIST 0 -#define GLIBTOP_SUID_PROC_STATE 0 -#define GLIBTOP_SUID_PROC_UID 0 -#define GLIBTOP_SUID_PROC_MEM 0 -#define GLIBTOP_SUID_PROC_TIME 0 -#define GLIBTOP_SUID_PROC_SIGNAL 0 -#define GLIBTOP_SUID_PROC_KERNEL 0 -#define GLIBTOP_SUID_PROC_SEGMENT 0 -#define GLIBTOP_SUID_PROC_ARGS 0 -#define GLIBTOP_SUID_PROC_MAP 0 -#define GLIBTOP_SUID_NETLOAD 0 -#define GLIBTOP_SUID_PPP 0 +#define GLIBTOP_IMPL_CPU (1 << GLIBTOP_SYSDEPS_CPU) +#define GLIBTOP_IMPL_MEM (1 << GLIBTOP_SYSDEPS_MEM) +#define GLIBTOP_IMPL_SWAP (1 << GLIBTOP_SYSDEPS_SWAP) +#define GLIBTOP_IMPL_UPTIME (1 << GLIBTOP_SYSDEPS_UPTIME) +#define GLIBTOP_IMPL_LOADAVG (1 << GLIBTOP_SYSDEPS_LOADAVG) +#define GLIBTOP_IMPL_SHM_LIMITS 0 +#define GLIBTOP_IMPL_MSG_LIMITS 0 +#define GLIBTOP_IMPL_SEM_LIMITS 0 +#define GLIBTOP_IMPL_PROCLIST (1 << GLIBTOP_SYSDEPS_PROCLIST) +#define GLIBTOP_IMPL_PROC_STATE (1 << GLIBTOP_SYSDEPS_PROC_STATE) +#define GLIBTOP_IMPL_PROC_UID (1 << GLIBTOP_SYSDEPS_PROC_UID) +#define GLIBTOP_IMPL_PROC_MEM (1 << GLIBTOP_SYSDEPS_PROC_MEM) +#define GLIBTOP_IMPL_PROC_TIME (1 << GLIBTOP_SYSDEPS_PROC_TIME) +#define GLIBTOP_IMPL_PROC_SIGNAL (1 << GLIBTOP_SYSDEPS_PROC_SIGNAL) +#define GLIBTOP_IMPL_PROC_KERNEL (1 << GLIBTOP_SYSDEPS_PROC_KERNEL) +#define GLIBTOP_IMPL_PROC_SEGMENT (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT) +#define GLIBTOP_IMPL_PROC_ARGS (1 << GLIBTOP_SYSDEPS_PROC_ARGS) +#define GLIBTOP_IMPL_PROC_MAP (1 << GLIBTOP_SYSDEPS_PROC_MAP) +#define GLIBTOP_IMPL_NETLOAD (1 << GLIBTOP_SYSDEPS_NETLOAD) +#define GLIBTOP_IMPL_NETINFO (1 << GLIBTOP_SYSDEPS_NETINFO) +#define GLIBTOP_IMPL_INTERFACE_NAMES (1 << GLIBTOP_SYSDEPS_INTERFACE_NAMES) +#define GLIBTOP_IMPL_PPP 0 END_LIBGTOP_DECLS diff --git a/sysdeps/kernel/interfaces.c b/sysdeps/kernel/interfaces.c index ea4aa0e8..b29a502e 100644 --- a/sysdeps/kernel/interfaces.c +++ b/sysdeps/kernel/interfaces.c @@ -27,6 +27,8 @@ #include #include +#include + static const unsigned long _glibtop_sysdeps_interface_names = (1L << GLIBTOP_INTERFACE_NAMES_NUMBER) + (1L << GLIBTOP_INTERFACE_NAMES_SIZE); @@ -34,7 +36,7 @@ static const unsigned long _glibtop_sysdeps_interface_names = /* Init function. */ int -glibtop_init_interface_names_s (glibtop *server) +glibtop_init_interface_names_k (glibtop *server) { server->sysdeps.interface_names = _glibtop_sysdeps_interface_names; @@ -44,7 +46,7 @@ glibtop_init_interface_names_s (glibtop *server) /* Provides network statistics. */ glibtop_interface * -glibtop_get_interface_names_s (glibtop *server, glibtop_interface_names *buf, +glibtop_get_interface_names_k (glibtop *server, glibtop_interface_names *buf, u_int64_t interface, u_int64_t number, u_int64_t instance, u_int64_t strategy) { diff --git a/sysdeps/kernel/libgtop-kernel.backend b/sysdeps/kernel/libgtop-kernel.backend new file mode 100644 index 00000000..89c6411d --- /dev/null +++ b/sysdeps/kernel/libgtop-kernel.backend @@ -0,0 +1,12 @@ + + + + + glibtop-backend-kernel + + libgtop_backend_kernel.la + libgtop_backend_kernel.so + + + + diff --git a/sysdeps/kernel/loadavg.c b/sysdeps/kernel/loadavg.c index dfacd050..588cb53a 100644 --- a/sysdeps/kernel/loadavg.c +++ b/sysdeps/kernel/loadavg.c @@ -34,7 +34,7 @@ static const unsigned long _glibtop_sysdeps_loadavg = /* Init function. */ int -glibtop_init_loadavg_s (glibtop *server) +glibtop_init_loadavg_k (glibtop *server) { server->sysdeps.loadavg = _glibtop_sysdeps_loadavg; @@ -44,14 +44,14 @@ glibtop_init_loadavg_s (glibtop *server) /* Provides load averange. */ int -glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) +glibtop_get_loadavg_k (glibtop *server, glibtop_loadavg *buf) { libgtop_stat_t stat; int retval; memset (buf, 0, sizeof (glibtop_loadavg)); - retval = glibtop_get_proc_data_stat_s (server, &stat); + retval = glibtop_get_proc_data_stat_k (server, &stat); if (retval) return retval; diff --git a/sysdeps/kernel/marshal.pl b/sysdeps/kernel/marshal.pl new file mode 100644 index 00000000..3541dd17 --- /dev/null +++ b/sysdeps/kernel/marshal.pl @@ -0,0 +1,201 @@ +#!/usr/bin/perl + +require 'c_types.pl'; + +$[ = 1; # set array base to 1 +$, = ' '; # set output field separator +$\ = "\n"; # set output record separator + +$always_use_temp_storage = 1; + +sub toupper { + local($_) = @_; + tr/a-z/A-Z/; + return $_; +} + +sub tolower { + local($_) = @_; + tr/A-Z/a-z/; + return $_; +} + +print '/* marshal.c */'; +print "/* This is a generated file. Please modify `marshal.pl' */"; +print ''; + +print '#include '; +print '#include '; +print '#include '; +print ''; +print '#include '; +print '#include '; +print ''; +print '#include '; +print ''; +print '#include '; +print '#include '; +print '#include '; +print ''; + +$feature_count = 0; + +while (<>) { + chop; # strip record separator + + if (/^[^#]/) { + &output($_); + } +} + +sub output { + local($line) = @_; + @line_fields = split(/\|/, $line, 9999); + $retval = $line_fields[1]; + $feature = $line_fields[2]; + $param_def = $line_fields[4]; + + $orig = $feature; + $feature =~ s/^@//; + $space = $feature; + $space =~ s/./ /g; + + $features{++$feature_count} = $orig; + + return if $orig =~ /^@/; + + if ($retval eq 'retval') { + $retval_param = '&retval'; + $call_prefix = ''; + $call_prefix_space = ''; + $prefix = 'retval = '; + $prefix_space = ' '; + $retval = 'int'; + } + elsif ($retval !~ /^void$/) { + $retval_param = 'NULL'; + $prefix = 'retval = '; + $prefix_space = ' '; + $call_prefix = 'retval = '; + $call_prefix_space = ' '; + } + else { + $retval_param = 'NULL'; + $call_prefix = ''; + $call_prefix_space = ''; + $prefix = ''; + $prefix_space = ''; + } + + if ($retval =~ /^(array|pointer)\((.*)\)$/) { + $retval = ($2 eq 'string') ? 'char **' : "$2 *"; + } + + $need_temp_storage = $always_use_temp_storage; + $first_param_name = ''; + + $call_param = ''; + $param_decl = ''; + $need_temp_len = 0; + $nr_params = (@params = split(/:/, $param_def, 9999)); + for ($param = 1; $param <= $nr_params; $param++) { + $list = $params[$param]; + $type = $params[$param]; + $type =~ s/\(.*//; + $list =~ s/^.*\(//; + $list =~ s/\)$//; + $count = (@fields = split(/,/, $list, 9999)); + for ($field = 1; $field <= $count; $field++) { + my $c_type = $typeinfo->{$type}->[1]; + + if ($first_param_name eq '') { + $first_param_name = $fields[$field]; + } + + if ($typeinfo->{$type}->[2]) { + $need_temp_storage = 1; + } + + if ($param_decl eq '') { + $param_decl = ",\n " . $space . ' '; + } + else { + $param_decl = $param_decl . ', '; + } + $param_decl = $param_decl . $c_type . ' ' . $fields[$field]; + $call_param = $call_param . ', ' . $fields[$field]; + } + } + + if ($line_fields[3] eq '') { + $total_code = sprintf + ("\treturn glibtop_get_%s_k (server%s);\n", $feature, $call_param); + } elsif ($line_fields[3] eq 'array') { + $total_code = sprintf + ("\treturn glibtop_get_%s_k (server, array%s);\n", $feature, $call_param); + } elsif ($line_fields[3] =~ /^array/) { + $total_code = sprintf + ("\treturn glibtop_get_%s_k (server, array, buf%s);\n", $feature, $call_param); + } else { + $total_code = sprintf + ("\treturn glibtop_get_%s_k (server, buf%s);\n", $feature, $call_param); + } + + $func_decl = 'static '.$retval."\n"; + if ($line_fields[3] eq '') { + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend%s)\n", + $feature, $param_decl); + } elsif ($line_fields[3] eq 'array') { + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, glibtop_array *array%s)\n", + $feature, $param_decl); + } elsif ($line_fields[3] =~ /^array/) { + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, glibtop_array *array, %s *buf%s)\n", + $feature, 'glibtop_'.$feature, $param_decl); + } else { + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, %s *buf%s)\n", + $feature, 'glibtop_'.$feature, $param_decl); + } + + $total_code = sprintf ("%s{\n%s\n%s}\n", $func_decl, $total_code); + + $total_code = sprintf ("#if (GLIBTOP_IMPL_%s)\n\n%s\n#endif /* GLIBTOP_IMPL_%s */\n\n", + &toupper($feature), $total_code, + &toupper($feature)); + + print $total_code; +} + +$init_hook_code = ''; +$call_vector_code = ''; +for ($nr = 1; $nr <= $feature_count; $nr++) { + $feature = $features{$nr}; + + if ($feature =~ /^@/) { + $call_vector_code .= sprintf (qq[\tNULL,\n]); + } else { + $call_vector_code .= sprintf + (qq[\#if GLIBTOP_IMPL_%s\n\t_glibtop_get_%s_c,\n\#else\n\tNULL,\n\#endif\n], + &toupper($feature), $feature); + } + + if (!($feature =~ /^@/)) { + $init_hook_code .= sprintf + (qq[\#if GLIBTOP_IMPL_%s\n\tglibtop_init_%s_k,\n\#endif\n], + &toupper($feature), $feature); + } +} +$init_hook_code .= sprintf (qq[\tNULL\n]); + +chop $init_hook_code; +chop $call_vector_code; + +print 'glibtop_call_vector glibtop_backend_kernel_call_vector = {'; +print $call_vector_code; +print '};'; +print ''; + +print 'glibtop_init_func_t _glibtop_init_hook_k [] = {'; +print $init_hook_code; +print '};'; +print ''; + diff --git a/sysdeps/kernel/mem.c b/sysdeps/kernel/mem.c index 5cba6976..3e212018 100644 --- a/sysdeps/kernel/mem.c +++ b/sysdeps/kernel/mem.c @@ -36,7 +36,7 @@ static const unsigned long _glibtop_sysdeps_mem = /* Init function. */ int -glibtop_init_mem_s (glibtop *server) +glibtop_init_mem_k (glibtop *server) { server->sysdeps.mem = _glibtop_sysdeps_mem; @@ -46,14 +46,14 @@ glibtop_init_mem_s (glibtop *server) /* Provides information about memory usage. */ int -glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) +glibtop_get_mem_k (glibtop *server, glibtop_mem *buf) { libgtop_mem_t mem; int retval; memset (buf, 0, sizeof (glibtop_mem)); - retval = glibtop_get_proc_data_mem_s (server, &mem); + retval = glibtop_get_proc_data_mem_k (server, &mem); if (retval) return retval; diff --git a/sysdeps/kernel/msg_limits.c b/sysdeps/kernel/msg_limits.c deleted file mode 100644 index 0b5ec6ca..00000000 --- a/sysdeps/kernel/msg_limits.c +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig , 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 - -#include -#include - -static const unsigned long _glibtop_sysdeps_msg_limits = -(1L << GLIBTOP_MSG_LIMITS_MSGPOOL) + (1L << GLIBTOP_MSG_LIMITS_MSGMAP) + -(1L << GLIBTOP_MSG_LIMITS_MSGMAX) + (1L << GLIBTOP_MSG_LIMITS_MSGMNB) + -(1L << GLIBTOP_MSG_LIMITS_MSGMNI) + (1L << GLIBTOP_MSG_LIMITS_MSGSSZ) + -(1L << GLIBTOP_MSG_LIMITS_MSGTQL); - -/* Init function. */ - -int -glibtop_init_msg_limits_s (glibtop *server) -{ - server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf) -{ - struct msginfo msginfo; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0); - - memset (buf, 0, sizeof (glibtop_msg_limits)); - - buf->flags = _glibtop_sysdeps_msg_limits; - - if (msgctl (0, IPC_INFO, (struct msqid_ds *) &msginfo)) - return -1; - - buf->msgpool = msginfo.msgpool; - buf->msgmap = msginfo.msgmap; - buf->msgmax = msginfo.msgmax; - buf->msgmnb = msginfo.msgmnb; - buf->msgmni = msginfo.msgmni; - buf->msgssz = msginfo.msgssz; - buf->msgtql = msginfo.msgtql; - - return 0; -} diff --git a/sysdeps/kernel/netinfo.c b/sysdeps/kernel/netinfo.c index 223ab192..353d6063 100644 --- a/sysdeps/kernel/netinfo.c +++ b/sysdeps/kernel/netinfo.c @@ -63,7 +63,7 @@ static const unsigned long _glibtop_sysdeps_netinfo = /* Init function. */ int -glibtop_init_netinfo_s (glibtop *server) +glibtop_init_netinfo_k (glibtop *server) { server->sysdeps.netinfo = _glibtop_sysdeps_netinfo; @@ -73,7 +73,7 @@ glibtop_init_netinfo_s (glibtop *server) /* Provides network statistics. */ int -glibtop_get_netinfo_s (glibtop *server, glibtop_netinfo *buf, +glibtop_get_netinfo_k (glibtop *server, glibtop_netinfo *buf, const char *interface, unsigned transport) { int skfd; diff --git a/sysdeps/kernel/netload.c b/sysdeps/kernel/netload.c index 47f2a8b3..a0fc4a15 100644 --- a/sysdeps/kernel/netload.c +++ b/sysdeps/kernel/netload.c @@ -70,7 +70,7 @@ static const unsigned long _glibtop_sysdeps_netload = /* Init function. */ int -glibtop_init_netload_s (glibtop *server) +glibtop_init_netload_k (glibtop *server) { server->sysdeps.netload = _glibtop_sysdeps_netload; @@ -80,7 +80,7 @@ glibtop_init_netload_s (glibtop *server) /* Provides network statistics. */ int -glibtop_get_netload_s (glibtop *server, glibtop_netload *buf, +glibtop_get_netload_k (glibtop *server, glibtop_netload *buf, const char *interface, unsigned transport, unsigned protocol) { @@ -89,7 +89,7 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf, memset (buf, 0, sizeof (glibtop_netload)); - retval = glibtop_get_proc_data_netload_s (server, &netload, interface); + retval = glibtop_get_proc_data_netload_k (server, &netload, interface); if (retval) return retval; diff --git a/sysdeps/kernel/open.c b/sysdeps/kernel/open.c deleted file mode 100644 index 6e4dc655..00000000 --- a/sysdeps/kernel/open.c +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig , 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 - -/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ - -void -glibtop_open_s (glibtop *server, const char *program_name, - const unsigned long features, const unsigned flags) -{ - server->name = program_name; -} diff --git a/sysdeps/kernel/ppp.c b/sysdeps/kernel/ppp.c deleted file mode 100644 index 2fcb1ed1..00000000 --- a/sysdeps/kernel/ppp.c +++ /dev/null @@ -1,208 +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 , 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 -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -static const unsigned long _glibtop_sysdeps_ppp = -(1L << GLIBTOP_PPP_STATE) + (1L << GLIBTOP_PPP_BYTES_IN) + -(1L << GLIBTOP_PPP_BYTES_OUT); - -/* Init function. */ - -int -glibtop_init_ppp_s (glibtop *server) -{ - server->sysdeps.ppp = _glibtop_sysdeps_ppp; - - return 0; -} - -static int -get_ISDN_stats (glibtop *server, int *in, int *out) -{ - unsigned long *isdn_stats, *ptr; - int fd, i; - - *in = *out = 0; - - isdn_stats = glibtop_calloc_r (server, ISDN_MAX_CHANNELS * 2, - sizeof (unsigned long)); - - fd = open ("/dev/isdninfo", O_RDONLY); - if (fd < 0) { - glibtop_free_r (server, isdn_stats); - return FALSE; - } - - if ((ioctl (fd, IIOCGETCPS, isdn_stats) < 0) && (errno != 0)) { - glibtop_free_r (server, isdn_stats); - close (fd); - - return FALSE; - } - - for (i = 0, ptr = isdn_stats; i < ISDN_MAX_CHANNELS; i++) { - *in += *ptr++; *out += *ptr++; - } - - glibtop_free_r (server, isdn_stats); - close (fd); - - return TRUE; -} - -static int is_ISDN_on (glibtop *server, int *online) -{ - FILE *f = 0; - char buffer [BUFSIZ], *p; - int i; - - /* Perhaps I should try to explain this code a little bit. - * - * ------------------------------------------------------------ - * This is from the manpage of isdninfo(4): - * - * DESCRIPTION - * /dev/isdninfo is a character device with major number 45 - * and minor number 255. It delivers status information from - * the Linux ISDN subsystem to user level. - * - * DATA FORMAT - * When reading from this device, the current status of the - * Linux ISDN subsystem is delivered in 6 lines of text. Each - * line starts with a tag string followed by a colon and - * whitespace. After that the status values are appended sep- - * arated by whitespace. - * - * flags is the tag of line 5. In this line for every driver - * slot, it's B-Channel status is shown. If no driver - * is registered in a slot, a ? is shown. For every - * established B-Channel of the driver, a bit is set - * in the shown value. The driver's first channel is - * mapped to bit 0, the second channel to bit 1 and so - * on. - * ------------------------------------------------------------ - * - * So we open /dev/isdninfo, discard the first four lines of text - * and then check whether we have something that is not `0' or `?' - * in one of the flags fields. - * - * Sounds complicated, but I don't see any other way to check whether - * we are connected. Also, this is the method some other ISDN tools - * for Linux use. - * - * Martin - */ - - f = fopen ("/dev/isdninfo", "r"); - - if (!f) return FALSE; - - for (i = 0; i < 5; i++) { - if (fgets (buffer, BUFSIZ, f) == NULL) { - fclose (f); - return FALSE; - } - } - - if (strncmp (buffer, "flags:", 6)) { - fclose (f); - return FALSE; - } - - p = buffer+6; - - while (*p) { - char *end = p; - - if (isspace (*p)) { - p++; - continue; - } - - for (end = p; *end && !isspace (*end); end++) - ; - - if (*end == 0) - break; - else - *end = 0; - - if (!strcmp (p, "?") || !strcmp (p, "0")) { - p = end+1; - continue; - } - - fclose (f); - - *online = TRUE; - return TRUE; - } - - fclose (f); - - *online = FALSE; - return TRUE; -} - -/* Provides PPP/ISDN information. */ - -int -glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, - unsigned short isdn, const char *lockfile) -{ - int in, out, online; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PPP, 0); - - memset (buf, 0, sizeof (glibtop_ppp)); - - if (is_ISDN_on (server, &online)) { - buf->state = online ? GLIBTOP_PPP_STATE_ONLINE : - GLIBTOP_PPP_STATE_HANGUP; - buf->flags |= (1L << GLIBTOP_PPP_STATE); - } - - if (get_ISDN_stats (server, &in, &out)) { - buf->bytes_in = in; - buf->bytes_out = out; - buf->flags |= (1L << GLIBTOP_PPP_BYTES_IN) | - (1L << GLIBTOP_PPP_BYTES_OUT); - } - - return 0; -} diff --git a/sysdeps/kernel/procargs.c b/sysdeps/kernel/procargs.c index 657d8565..9d3440b7 100644 --- a/sysdeps/kernel/procargs.c +++ b/sysdeps/kernel/procargs.c @@ -36,7 +36,7 @@ static const unsigned long _glibtop_sysdeps_proc_args = /* Init function. */ int -glibtop_init_proc_args_s (glibtop *server) +glibtop_init_proc_args_k (glibtop *server) { server->sysdeps.proc_args = _glibtop_sysdeps_proc_args; @@ -46,7 +46,7 @@ glibtop_init_proc_args_s (glibtop *server) /* Provides detailed information about a process. */ char ** -glibtop_get_proc_args_s (glibtop *server, glibtop_array *array, pid_t pid) +glibtop_get_proc_args_k (glibtop *server, glibtop_array *array, pid_t pid) { char *ptr = NULL, *pos, **ptrlist; size_t count = 0, max_len, total; @@ -57,7 +57,7 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_array *array, pid_t pid) max_len = PAGE_SIZE; ptr = glibtop_malloc_r (server, max_len + 1); - ret = glibtop_get_proc_data_proc_args_s (server, pid, ptr, max_len); + ret = glibtop_get_proc_data_proc_args_k (server, pid, ptr, max_len); if (ret < 0) { glibtop_free_r (server, ptr); return NULL; diff --git a/sysdeps/kernel/procdata.c b/sysdeps/kernel/procdata.c index 27d822e8..56273556 100644 --- a/sysdeps/kernel/procdata.c +++ b/sysdeps/kernel/procdata.c @@ -27,7 +27,7 @@ #include int -glibtop_get_proc_data_stat_s (glibtop *server, libgtop_stat_t *stat) +glibtop_get_proc_data_stat_k (glibtop *server, libgtop_stat_t *stat) { int name [2] = { CTL_LIBGTOP, LIBGTOP_STAT }; size_t size = sizeof (libgtop_stat_t); @@ -44,7 +44,7 @@ glibtop_get_proc_data_stat_s (glibtop *server, libgtop_stat_t *stat) } int -glibtop_get_proc_data_mem_s (glibtop *server, libgtop_mem_t *mem) +glibtop_get_proc_data_mem_k (glibtop *server, libgtop_mem_t *mem) { int name [2] = { CTL_LIBGTOP, LIBGTOP_MEM }; size_t size = sizeof (libgtop_mem_t); @@ -61,7 +61,7 @@ glibtop_get_proc_data_mem_s (glibtop *server, libgtop_mem_t *mem) } int -glibtop_get_proc_data_swap_s (glibtop *server, libgtop_swap_t *swap) +glibtop_get_proc_data_swap_k (glibtop *server, libgtop_swap_t *swap) { int name [2] = { CTL_LIBGTOP, LIBGTOP_SWAP }; size_t size = sizeof (libgtop_swap_t); @@ -78,7 +78,7 @@ glibtop_get_proc_data_swap_s (glibtop *server, libgtop_swap_t *swap) } int -glibtop_get_proc_data_proclist_s (glibtop *server, +glibtop_get_proc_data_proclist_k (glibtop *server, libgtop_proclist_t *proclist, u_int64_t which, u_int64_t arg) { @@ -98,7 +98,7 @@ glibtop_get_proc_data_proclist_s (glibtop *server, } int -glibtop_get_proc_data_proc_state_s (glibtop *server, +glibtop_get_proc_data_proc_state_k (glibtop *server, libgtop_proc_state_t *proc_state, pid_t pid) { @@ -119,7 +119,7 @@ glibtop_get_proc_data_proc_state_s (glibtop *server, } int -glibtop_get_proc_data_proc_mem_s (glibtop *server, +glibtop_get_proc_data_proc_mem_k (glibtop *server, libgtop_proc_mem_t *proc_mem, pid_t pid) { @@ -140,7 +140,7 @@ glibtop_get_proc_data_proc_mem_s (glibtop *server, } int -glibtop_get_proc_data_proc_signal_s (glibtop *server, +glibtop_get_proc_data_proc_signal_k (glibtop *server, libgtop_proc_signal_t *proc_signal, pid_t pid) { @@ -161,7 +161,7 @@ glibtop_get_proc_data_proc_signal_s (glibtop *server, } int -glibtop_get_proc_data_proc_kernel_s (glibtop *server, +glibtop_get_proc_data_proc_kernel_k (glibtop *server, libgtop_proc_kernel_t *proc_kernel, pid_t pid) { @@ -182,7 +182,7 @@ glibtop_get_proc_data_proc_kernel_s (glibtop *server, } int -glibtop_get_proc_data_proc_args_s (glibtop *server, pid_t pid, +glibtop_get_proc_data_proc_args_k (glibtop *server, pid_t pid, char *result, size_t max_len) { int name [3] = { CTL_LIBGTOP, LIBGTOP_PROC_ARGS, pid }; @@ -202,7 +202,7 @@ glibtop_get_proc_data_proc_args_s (glibtop *server, pid_t pid, } int -glibtop_get_proc_data_proc_maps_s (glibtop *server, pid_t pid, +glibtop_get_proc_data_proc_maps_k (glibtop *server, pid_t pid, libgtop_proc_maps_t *result, size_t max_len) { @@ -223,7 +223,7 @@ glibtop_get_proc_data_proc_maps_s (glibtop *server, pid_t pid, } int -glibtop_get_proc_data_netload_s (glibtop *server, +glibtop_get_proc_data_netload_k (glibtop *server, libgtop_netload_t *netload, const char *device) { diff --git a/sysdeps/kernel/prockernel.c b/sysdeps/kernel/prockernel.c index 489d174c..786b2493 100644 --- a/sysdeps/kernel/prockernel.c +++ b/sysdeps/kernel/prockernel.c @@ -42,7 +42,7 @@ static const unsigned long _glibtop_sysdeps_proc_kernel_kernel = /* Init function. */ int -glibtop_init_proc_kernel_s (glibtop *server) +glibtop_init_proc_kernel_k (glibtop *server) { server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel | _glibtop_sysdeps_proc_kernel_kernel; @@ -53,7 +53,7 @@ glibtop_init_proc_kernel_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, +glibtop_get_proc_kernel_k (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) { libgtop_proc_state_t proc_state; @@ -62,7 +62,7 @@ glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, memset (buf, 0, sizeof (glibtop_proc_kernel)); - retval = glibtop_get_proc_data_proc_state_s (server, &proc_state, pid); + retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid); if (retval) return retval; @@ -75,7 +75,7 @@ glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, buf->flags = _glibtop_sysdeps_proc_kernel; - retval = glibtop_get_proc_data_proc_kernel_s (server, &proc_kernel, pid); + retval = glibtop_get_proc_data_proc_kernel_k (server, &proc_kernel, pid); if (retval) return retval; diff --git a/sysdeps/kernel/proclist.c b/sysdeps/kernel/proclist.c index 8404ed86..e760781a 100644 --- a/sysdeps/kernel/proclist.c +++ b/sysdeps/kernel/proclist.c @@ -38,7 +38,7 @@ static const unsigned long _glibtop_sysdeps_proclist = /* Init function. */ int -glibtop_init_proclist_s (glibtop *server) +glibtop_init_proclist_k (glibtop *server) { server->sysdeps.proclist = _glibtop_sysdeps_proclist; @@ -53,7 +53,7 @@ glibtop_init_proclist_s (glibtop *server) * each buf->size big. The total size is stored in buf->total. */ unsigned * -glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf, +glibtop_get_proclist_k (glibtop *server, glibtop_proclist *buf, int64_t which, int64_t arg) { libgtop_proclist_t proclist; @@ -62,7 +62,7 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf, memset (buf, 0, sizeof (glibtop_proclist)); - if (glibtop_get_proc_data_proclist_s (server, &proclist, which, arg)) + if (glibtop_get_proc_data_proclist_k (server, &proclist, which, arg)) return NULL; ret = glibtop_calloc_r (server, proclist.count, sizeof (unsigned)); diff --git a/sysdeps/kernel/procmap.c b/sysdeps/kernel/procmap.c index 798461d0..9c3557b7 100644 --- a/sysdeps/kernel/procmap.c +++ b/sysdeps/kernel/procmap.c @@ -46,7 +46,7 @@ static const unsigned long _glibtop_sysdeps_map_entry_vmfile = /* Init function. */ int -glibtop_init_proc_map_s (glibtop *server) +glibtop_init_proc_map_k (glibtop *server) { server->sysdeps.proc_map = _glibtop_sysdeps_proc_map; @@ -56,7 +56,7 @@ glibtop_init_proc_map_s (glibtop *server) /* Provides detailed information about a process. */ glibtop_map_entry * -glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) +glibtop_get_proc_map_k (glibtop *server, glibtop_proc_map *buf, pid_t pid) { glibtop_map_entry *retval = NULL; libgtop_proc_maps_t *maps; @@ -68,13 +68,13 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) memset (buf, 0, sizeof (glibtop_proc_map)); /* Get number of map entries. */ - count = glibtop_get_proc_data_proc_maps_s (server, pid, NULL, 0); + count = glibtop_get_proc_data_proc_maps_k (server, pid, NULL, 0); /* Allocate memory. */ maps = glibtop_calloc_r (server, count, sizeof (libgtop_proc_maps_t)); max_len = count * sizeof (libgtop_proc_maps_t); - ret = glibtop_get_proc_data_proc_maps_s (server, pid, maps, max_len); + ret = glibtop_get_proc_data_proc_maps_k (server, pid, maps, max_len); if (ret < 0) { glibtop_free_r (server, maps); return NULL; diff --git a/sysdeps/kernel/procmem.c b/sysdeps/kernel/procmem.c index 0b48800f..0cd33ead 100644 --- a/sysdeps/kernel/procmem.c +++ b/sysdeps/kernel/procmem.c @@ -46,7 +46,7 @@ static int pageshift; /* log base 2 of the pagesize */ /* Init function. */ int -glibtop_init_proc_mem_s (glibtop *server) +glibtop_init_proc_mem_k (glibtop *server) { register int pagesize; @@ -66,7 +66,7 @@ glibtop_init_proc_mem_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, +glibtop_get_proc_mem_k (glibtop *server, glibtop_proc_mem *buf, pid_t pid) { libgtop_proc_mem_t proc_mem; @@ -74,7 +74,7 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, memset (buf, 0, sizeof (glibtop_proc_mem)); - retval = glibtop_get_proc_data_proc_mem_s (server, &proc_mem, pid); + retval = glibtop_get_proc_data_proc_mem_k (server, &proc_mem, pid); if (retval) return retval; diff --git a/sysdeps/kernel/procsegment.c b/sysdeps/kernel/procsegment.c index 9e15ac37..fe385055 100644 --- a/sysdeps/kernel/procsegment.c +++ b/sysdeps/kernel/procsegment.c @@ -53,7 +53,7 @@ static int pageshift; /* log base 2 of the pagesize */ /* Init function. */ int -glibtop_init_proc_segment_s (glibtop *server) +glibtop_init_proc_segment_k (glibtop *server) { register int pagesize; @@ -74,7 +74,7 @@ glibtop_init_proc_segment_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, +glibtop_get_proc_segment_k (glibtop *server, glibtop_proc_segment *buf, pid_t pid) { libgtop_proc_mem_t proc_mem; @@ -83,7 +83,7 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, memset (buf, 0, sizeof (glibtop_proc_segment)); - retval = glibtop_get_proc_data_proc_mem_s (server, &proc_mem, pid); + retval = glibtop_get_proc_data_proc_mem_k (server, &proc_mem, pid); if (retval) return retval; @@ -101,7 +101,7 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, buf->flags = _glibtop_sysdeps_proc_segment; - retval = glibtop_get_proc_data_proc_state_s (server, &proc_state, pid); + retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid); if (retval) return retval; diff --git a/sysdeps/kernel/procsignal.c b/sysdeps/kernel/procsignal.c index 4fcc092e..4ac1878a 100644 --- a/sysdeps/kernel/procsignal.c +++ b/sysdeps/kernel/procsignal.c @@ -37,7 +37,7 @@ static const unsigned long _glibtop_sysdeps_proc_signal = /* Init function. */ int -glibtop_init_proc_signal_s (glibtop *server) +glibtop_init_proc_signal_k (glibtop *server) { server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal; @@ -47,7 +47,7 @@ glibtop_init_proc_signal_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, +glibtop_get_proc_signal_k (glibtop *server, glibtop_proc_signal *buf, pid_t pid) { libgtop_proc_signal_t proc_signal; @@ -55,7 +55,7 @@ glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, memset (buf, 0, sizeof (glibtop_proc_signal)); - retval = glibtop_get_proc_data_proc_signal_s (server, &proc_signal, pid); + retval = glibtop_get_proc_data_proc_signal_k (server, &proc_signal, pid); if (retval) return retval; diff --git a/sysdeps/kernel/procstate.c b/sysdeps/kernel/procstate.c index a596c54a..50b00b3a 100644 --- a/sysdeps/kernel/procstate.c +++ b/sysdeps/kernel/procstate.c @@ -38,7 +38,7 @@ static const unsigned long _glibtop_sysdeps_proc_state = /* Init function. */ int -glibtop_init_proc_state_s (glibtop *server) +glibtop_init_proc_state_k (glibtop *server) { server->sysdeps.proc_state = _glibtop_sysdeps_proc_state; @@ -48,7 +48,7 @@ glibtop_init_proc_state_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, +glibtop_get_proc_state_k (glibtop *server, glibtop_proc_state *buf, pid_t pid) { libgtop_proc_state_t proc_state; @@ -56,7 +56,7 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, memset (buf, 0, sizeof (glibtop_proc_state)); - retval = glibtop_get_proc_data_proc_state_s (server, &proc_state, pid); + retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid); if (retval) return retval; diff --git a/sysdeps/kernel/proctime.c b/sysdeps/kernel/proctime.c index b779e0aa..26ac25c9 100644 --- a/sysdeps/kernel/proctime.c +++ b/sysdeps/kernel/proctime.c @@ -39,7 +39,7 @@ static const unsigned long _glibtop_sysdeps_proc_time_smp = /* Init function. */ int -glibtop_init_proc_time_s (glibtop *server) +glibtop_init_proc_time_k (glibtop *server) { server->sysdeps.proc_time = _glibtop_sysdeps_proc_time; @@ -52,7 +52,7 @@ glibtop_init_proc_time_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, +glibtop_get_proc_time_k (glibtop *server, glibtop_proc_time *buf, pid_t pid) { libgtop_proc_state_t proc_state; @@ -60,7 +60,7 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, memset (buf, 0, sizeof (glibtop_proc_time)); - retval = glibtop_get_proc_data_proc_state_s (server, &proc_state, pid); + retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid); if (retval) return retval; diff --git a/sysdeps/kernel/procuid.c b/sysdeps/kernel/procuid.c index 12ae619e..d550b874 100644 --- a/sysdeps/kernel/procuid.c +++ b/sysdeps/kernel/procuid.c @@ -46,7 +46,7 @@ static const unsigned long _glibtop_sysdeps_proc_uid = /* Init function. */ int -glibtop_init_proc_uid_s (glibtop *server) +glibtop_init_proc_uid_k (glibtop *server) { server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid; @@ -56,7 +56,7 @@ glibtop_init_proc_uid_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, +glibtop_get_proc_uid_k (glibtop *server, glibtop_proc_uid *buf, pid_t pid) { libgtop_proc_state_t proc_state; @@ -65,7 +65,7 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, memset (buf, 0, sizeof (glibtop_proc_uid)); - retval = glibtop_get_proc_data_proc_state_s (server, &proc_state, pid); + retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid); if (retval) return retval; diff --git a/sysdeps/kernel/sem_limits.c b/sysdeps/kernel/sem_limits.c deleted file mode 100644 index 3f3be427..00000000 --- a/sysdeps/kernel/sem_limits.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig , 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 - -#include -#include - -#ifdef _SEM_SEMUN_UNDEFINED - -/* glibc 2.1 will no longer defines semun, instead it defines - * _SEM_SEMUN_UNDEFINED so users can define semun on their own. - * Thanks to Albert K T Hui . */ - -union semun -{ - int val; - struct semid_ds *buf; - unsigned short int *array; - struct seminfo *__buf; -}; -#endif - -static unsigned long _glibtop_sysdeps_sem_limits = -(1L << GLIBTOP_SEM_LIMITS_SEMMAP) + (1L << GLIBTOP_SEM_LIMITS_SEMMNI) + -(1L << GLIBTOP_SEM_LIMITS_SEMMNS) + (1L << GLIBTOP_SEM_LIMITS_SEMMNU) + -(1L << GLIBTOP_SEM_LIMITS_SEMMSL) + (1L << GLIBTOP_SEM_LIMITS_SEMOPM) + -(1L << GLIBTOP_SEM_LIMITS_SEMUME) + (1L << GLIBTOP_SEM_LIMITS_SEMUSZ) + -(1L << GLIBTOP_SEM_LIMITS_SEMVMX) + (1L << GLIBTOP_SEM_LIMITS_SEMAEM); - -/* Init function. */ - -int -glibtop_init_sem_limits_s (glibtop *server) -{ - server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf) -{ - struct seminfo seminfo; - union semun arg; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0); - - memset (buf, 0, sizeof (glibtop_sem_limits)); - - buf->flags = _glibtop_sysdeps_sem_limits; - - arg.array = (ushort *) &seminfo; - if (semctl (0, 0, IPC_INFO, arg)) - return -1; - - buf->semmap = seminfo.semmap; - buf->semmni = seminfo.semmni; - buf->semmns = seminfo.semmns; - buf->semmnu = seminfo.semmnu; - buf->semmsl = seminfo.semmsl; - buf->semopm = seminfo.semopm; - buf->semume = seminfo.semume; - buf->semusz = seminfo.semusz; - buf->semvmx = seminfo.semvmx; - buf->semaem = seminfo.semaem; - - return 0; -} diff --git a/sysdeps/kernel/shm_limits.c b/sysdeps/kernel/shm_limits.c deleted file mode 100644 index 8eef4ac2..00000000 --- a/sysdeps/kernel/shm_limits.c +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig , 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 - -#include -#include - -static unsigned long _glibtop_sysdeps_shm_limits = -(1L << GLIBTOP_SHM_LIMITS_SHMMAX) + (1L << GLIBTOP_SHM_LIMITS_SHMMIN) + -(1L << GLIBTOP_SHM_LIMITS_SHMMNI) + (1L << GLIBTOP_SHM_LIMITS_SHMSEG) + -(1L << GLIBTOP_SHM_LIMITS_SHMALL); - -/* Init function. */ - -int -glibtop_init_shm_limits_s (glibtop *server) -{ - server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits; - - return 0; -} - -/* Provides information about sysv ipc limits. */ - -int -glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf) -{ - struct shminfo shminfo; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0); - - memset (buf, 0, sizeof (glibtop_shm_limits)); - - buf->flags = _glibtop_sysdeps_shm_limits; - - if (shmctl (0, IPC_INFO, (struct shmid_ds *) &shminfo)) - return -1; - - buf->shmmax = shminfo.shmmax; - buf->shmmin = shminfo.shmmin; - buf->shmmni = shminfo.shmmni; - buf->shmseg = shminfo.shmseg; - buf->shmall = shminfo.shmall; - - return 0; -} diff --git a/sysdeps/kernel/siglist.c b/sysdeps/kernel/siglist.c deleted file mode 100644 index ef58e9c9..00000000 --- a/sysdeps/kernel/siglist.c +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig , 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 -#include - -const glibtop_signame glibtop_sys_siglist [] = -{ { 1, "SIGHUP", NULL }, /* Hangup (POSIX). */ - { 2, "SIGINT", NULL }, /* Interrupt (ANSI). */ - { 3, "SIGQUIT", NULL }, /* Quit (POSIX). */ - { 4, "SIGILL", NULL }, /* Illegal instruction (ANSI). */ - { 5, "SIGTRAP", NULL }, /* Trace trap (POSIX). */ - { 6, "SIGABRT", NULL }, /* Abort (ANSI). */ - { 7, "SIGBUS", NULL }, /* BUS error (4.2 BSD). */ - { 8, "SIGFPE", NULL }, /* Floating-point exception (ANSI). */ - { 9, "SIGKILL", NULL }, /* Kill, unblockable (POSIX). */ - { 10, "SIGUSR1", NULL }, /* User-defined signal 1 (POSIX). */ - { 11, "SIGSEGV", NULL }, /* Segmentation violation (ANSI). */ - { 12, "SIGUSR2", NULL }, /* User-defined signal 2 (POSIX). */ - { 13, "SIGPIPE", NULL }, /* Broken pipe (POSIX). */ - { 14, "SIGALRM", NULL }, /* Alarm clock (POSIX). */ - { 15, "SIGTERM", NULL }, /* Termination (ANSI). */ - { 16, "SIGSTKFLT", NULL }, /* ??? */ - { 17, "SIGCHLD", NULL }, /* Child status has changed (POSIX). */ - { 18, "SIGCONT", NULL }, /* Continue (POSIX). */ - { 19, "SIGSTOP", NULL }, /* Stop, unblockable (POSIX). */ - { 20, "SIGTSTP", NULL }, /* Keyboard stop (POSIX). */ - { 21, "SIGTTIN", NULL }, /* Background read from tty (POSIX). */ - { 22, "SIGTTOU", NULL }, /* Background write to tty (POSIX). */ - { 23, "SIGURG", NULL }, /* Urgent condition on socket (4.2 BSD). */ - { 24, "SIGXCPU", NULL }, /* CPU limit exceeded (4.2 BSD). */ - { 25, "SIGXFSZ", NULL }, /* File size limit exceeded (4.2 BSD). */ - { 26, "SIGVTALRM", NULL }, /* Virtual alarm clock (4.2 BSD). */ - { 27, "SIGPROF", NULL }, /* Profiling alarm clock (4.2 BSD). */ - { 28, "SIGWINCH", NULL }, /* Window size change (4.3 BSD, Sun). */ - { 29, "SIGIO", NULL }, /* I/O now possible (4.2 BSD). */ - { 30, "SIGPWR", NULL }, /* Power failure restart (System V). */ - { 31, "SIGUNUSED", NULL }, - { 0, NULL, NULL }, -}; diff --git a/sysdeps/kernel/swap.c b/sysdeps/kernel/swap.c index 9a1099c3..7375bc66 100644 --- a/sysdeps/kernel/swap.c +++ b/sysdeps/kernel/swap.c @@ -38,7 +38,7 @@ static const unsigned long _glibtop_sysdeps_swap_stat = /* Init function. */ int -glibtop_init_swap_s (glibtop *server) +glibtop_init_swap_k (glibtop *server) { server->sysdeps.swap = _glibtop_sysdeps_swap | _glibtop_sysdeps_swap_stat; @@ -49,7 +49,7 @@ glibtop_init_swap_s (glibtop *server) /* Provides information about swap usage. */ int -glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) +glibtop_get_swap_k (glibtop *server, glibtop_swap *buf) { libgtop_stat_t stat; libgtop_swap_t swap; @@ -57,7 +57,7 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) memset (buf, 0, sizeof (glibtop_swap)); - retval = glibtop_get_proc_data_swap_s (server, &swap); + retval = glibtop_get_proc_data_swap_k (server, &swap); if (retval) return retval; @@ -67,7 +67,7 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) buf->flags = _glibtop_sysdeps_swap; - retval = glibtop_get_proc_data_stat_s (server, &stat); + retval = glibtop_get_proc_data_stat_k (server, &stat); if (retval) return retval; diff --git a/sysdeps/kernel/sysinfo.c b/sysdeps/kernel/sysinfo.c deleted file mode 100644 index 33acac0d..00000000 --- a/sysdeps/kernel/sysinfo.c +++ /dev/null @@ -1,98 +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 , 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 -#include -#include - -#include - -static const unsigned long _glibtop_sysdeps_sysinfo = -(1L << GLIBTOP_SYSINFO_CPUINFO); - -static glibtop_sysinfo sysinfo; - -static void -init_sysinfo (glibtop *server) -{ - char buffer [BUFSIZ]; - static int init = 0; - glibtop_entry *cpuinfo = NULL; - FILE *f; - - if (init) return; - - init = TRUE; - - glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0); - - memset (&sysinfo, 0, sizeof (glibtop_sysinfo)); - - g_return_if_fail (f = fopen ("/proc/cpuinfo", "r")); - - while (fgets (buffer, BUFSIZ, f)) { - char *p, *start, *key, *value; - - if (cpuinfo == NULL) { - cpuinfo = &sysinfo.cpuinfo [sysinfo.ncpu++]; - - cpuinfo->labels = g_ptr_array_new (); - - cpuinfo->values = g_hash_table_new (NULL, NULL); - - if (sysinfo.ncpu > GLIBTOP_NCPU) - sysinfo.ncpu = GLIBTOP_NCPU; - } - - p = strchr (buffer, ':'); - if (!p) continue; - - /* Remove leading spaces from `p'. */ - *p = '\0'; start = p; p++; - while (isspace (*p)) p++; - - /* Remove trailing spaces from `buffer'. */ - while ((start > buffer) && (*start) && isspace (*start)) - *start-- = '\0'; - - key = g_strdup (buffer); - value = g_strdup (p); - - g_ptr_array_add (cpuinfo->labels, key); - - g_hash_table_insert (cpuinfo->values, key, value); - } - - fclose (f); - - sysinfo.flags = _glibtop_sysdeps_sysinfo; -} - -glibtop_sysinfo * -glibtop_get_sysinfo_s (glibtop *server) -{ - init_sysinfo (server); - return &sysinfo; -} diff --git a/sysdeps/kernel/uptime.c b/sysdeps/kernel/uptime.c index 985e28b3..1deea29b 100644 --- a/sysdeps/kernel/uptime.c +++ b/sysdeps/kernel/uptime.c @@ -35,7 +35,7 @@ static unsigned long _glibtop_sysdeps_uptime = /* Init function. */ int -glibtop_init_uptime_s (glibtop *server) +glibtop_init_uptime_k (glibtop *server) { server->sysdeps.uptime = _glibtop_sysdeps_uptime; @@ -45,7 +45,7 @@ glibtop_init_uptime_s (glibtop *server) /* Provides uptime and idle time. */ int -glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) +glibtop_get_uptime_k (glibtop *server, glibtop_uptime *buf) { libgtop_stat_t stat; unsigned long total; @@ -53,7 +53,7 @@ glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) memset (buf, 0, sizeof (glibtop_uptime)); - retval = glibtop_get_proc_data_stat_s (server, &stat); + retval = glibtop_get_proc_data_stat_k (server, &stat); if (retval) return retval;