Compare commits

...

45 Commits

Author SHA1 Message Date
Robert Roth
1a8f092264 Prepared release 2.34.0 2016-03-22 09:00:27 +02:00
Robert Roth
5522fae242 Prepared release 2.33.91 2016-02-29 23:08:18 +02:00
Cédric Valmary
870dd5afa6 Updated Occitan translation 2016-02-29 19:07:51 +00:00
Kylie McClain
94968b4406 Fix building on musl-libc
libgtop fails to build on musl libc, due to the header
resulting in the headers that would be loaded for libc 5 being
loaded on musl libc.
musl defines headers which are also defined in linux-headers'
in.h, causing redefinition errors.

https://bugzilla.gnome.org/show_bug.cgi?id=760655

Signed-off-by: Benoît Dejean <bdejean@gmail.com>
2016-02-16 18:12:00 +01:00
Robert Roth
819bfe56ee Prepared release 2.33.4 2016-01-18 23:22:18 +02:00
Antoine Jacoutot
de408a6bba openbsd: only PID 1 is special (init) 2016-01-12 17:14:20 +01:00
Ting-Wei Lan
05cb14dbb2 Call setlocale in main function of libgtop_daemon2
It is required to correctly show translated messages on some locales.

https://bugzilla.gnome.org/show_bug.cgi?id=760432
2016-01-11 14:30:41 +08:00
Robert Roth
7e3e4b6860 Prepared release 3.19.3 2015-12-14 19:40:21 +02:00
Jasper Lievisse Adriaanse
02070b7170 Add various headers to unbreak compilation 2015-12-11 15:03:49 +01:00
Jasper Lievisse Adriaanse
fcfacf3213 PROT_EXECUTE -> PROT_EXEC 2015-12-11 14:59:11 +01:00
Jasper Lievisse Adriaanse
7925f83b57 Fix compilation because glibtop_machine definition has moved. 2015-12-11 14:57:34 +01:00
Cédric Valmary
68104bdde1 Updated Occitan translation 2015-11-10 14:02:39 +00:00
Robert Roth
ac2aef0f47 Prepared release 3.18.0 2015-09-21 20:10:23 +03:00
Robert Roth
9764518807 Prepare release 2.31.91 2015-09-14 19:56:24 +03:00
Piotr Drąg
13f08cf164 Updated Polish translation 2015-08-26 19:48:14 +02:00
Benoît Dejean
c8a4c3d2a1 Post-release version bump. 2015-08-25 22:33:47 +02:00
Benoît Dejean
52c35c1b81 Fix constant name for GLIBTOP_MAX_PROC_WD. 2015-08-25 22:32:57 +02:00
Benoît Dejean
e528a7280b Fix a bunch of doc tags for GI. 2015-08-25 22:32:06 +02:00
Benoît Dejean
99ff3d4dff Define missing GLIBTOP_MAX_PROC_AFFINITY. 2015-08-25 22:31:28 +02:00
Benoît Dejean
f865e95e20 Don't ship glibtop/version.h as this is private. 2015-08-23 12:50:43 +02:00
Benoît Dejean
eec96d8ae8 Fix Darwin build.
Patch by  David Evans.
Bug https://bugzilla.gnome.org/show_bug.cgi?id=753743 .
2015-08-18 16:43:00 +02:00
Robert Roth
d10a584e40 Prepared release 2.31.90 2015-08-17 22:52:24 +03:00
Benoît Dejean
a55eee5863 NEWS for 2.31.5. 2015-08-16 19:34:08 +02:00
Benoit Dejean
7437509412 Fix compilation because glibtop_machine definition has moved. 2015-08-15 10:57:25 +02:00
Benoit Dejean
c9e73e52ac glibtop_machine is defined in glibtop.h.
Don't duplicate the typedef (error unless C11).
2015-08-15 10:56:41 +02:00
Benoit Dejean
4c455ac8a0 Implement glibtop_map_entry Pss and Swap.
Regenerate hash function for fast parsing.
2015-08-15 10:39:39 +02:00
Benoit Dejean
56f03d0987 New API/ABI: add Pss (partial set size) and Swap in glibtop_map_entry. 2015-08-15 10:39:38 +02:00
Benoît Dejean
a3b502ec3f Don't include non-installed glibtop_machine.h in glibtop.h.
That would defeat its purpose.
2015-08-15 10:28:14 +02:00
Benoît Dejean
b74d6abf19 server->machine is now a pointer, so propagate the change from . to ->. 2015-08-08 14:36:47 +02:00
Benoît Dejean
ca42f1f3af Define glibtop_machine for Linux as empty because it's not used.
Fix compilation.
2015-08-08 11:11:30 +02:00
Benoit Dejean
106ee901bb Add missing file. 2015-08-08 11:08:50 +02:00
Benoit Dejean
0642c2d610 Turn glibtop::machine from a value to a pointer, allocated on init.
This hides the glibtop_machine implementation.
2015-08-08 11:00:57 +02:00
Benoit Dejean
42e860e5ad Add uid/euid/gid/egid members to struct glibtop. 2015-08-08 11:00:57 +02:00
Benoit Dejean
8f2f236404 No use for glibtop_machine for now, but who knows in the future. 2015-08-08 11:00:57 +02:00
Benoit Dejean
4e0d819264 Always define gligtop_machine.
There was an ABI mismatch because HAVE_GLIBTOP_MACHINE was only
defined when compiling the library itself. The library code would then
use a larger struct glibtop (with a machine member) than the
application code.

Everyone defines a glibtop_machine but linux (though it as a
glibtop_machine.h) and cygwin (code unchanged for 5 years) so this
should not break anything.
2015-08-08 11:00:57 +02:00
Benoit Dejean
5c6879baab Exclude the "idle" kernel process when GLIBTOP_EXCLUDE_IDLE. 2015-08-08 10:56:25 +02:00
Benoît Dejean
a0e97885c1 Post-release version bump. 2015-08-08 10:56:25 +02:00
Benoit Dejean
d817bee619 Remove useless/meaningless calls to glibtop_init_[prs]() with sysdeps/{freebsd,linux}. 2015-08-08 10:56:25 +02:00
Benoit Dejean
58d50d3546 Ignore *.bak files. 2015-08-08 10:56:24 +02:00
Benoit Dejean
d3a247a60f Don't include the ':' in smaps keys.
Regenerate the hashtable.
2015-08-08 10:56:24 +02:00
Benoit Dejean
45c8452140 More debug messages to trace euid/egid changes. 2015-08-08 10:56:24 +02:00
Benoit Dejean
72b4aed8f1 Display features in hex in debug message. 2015-08-08 10:56:24 +02:00
Benoit Dejean
0e8f911410 Add some debug code to trace effective GID changes. 2015-08-08 10:56:24 +02:00
Benoit Dejean
db8ad19eef Move _glibtop_global_server from .data to .bss. 2015-08-08 10:56:24 +02:00
Benoit Dejean
d30fbb22e0 Also display file/line/function in debug messages. 2015-08-08 10:56:24 +02:00
142 changed files with 703 additions and 686 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
*~
*.bak
*.o
*.out
*.a

59
NEWS
View File

@@ -1,3 +1,62 @@
22 March 2016: Overview of changes in 2.34.0
================================================
* Stable release
29 February 2016: Overview of changes in 2.33.91
* Updated translations
* Fix building on must-libc
18 January 2016: Overview of changes in 2.33.4
* On OpenBSD only PID 1 is special
* Call setlocale in main
14 December: Overview of changes in 2.33.3
* Fixed borken compilation on OpenBSD
* Updated translations.
21 September 2015: Overview of changes in 2.32.0
* Stable release
14 September 2015: Overview of changes in 2.31.91
================================================
* Darwin:
- Fixed build.
* All
- GI docs fixes
- include fixes
- Updated translations
16 August 2015: Overview of changes in 2.31.90
=============================================
* ABI changes:
- ABI was inconsistent on platforms like FreeBSD which make use of
glibtop_machine. The ABI was actually different between the
library and the server. Fixed this by simply always defining
glibtop_machine in glibtop struct.
- Add Pss and Swap members in glibtop_proc_mem.
- This is the second ABI breakage in since 2.28 (the first one was
bumping NCPU), there were no release for 2.30.
* FreeBSD:
- proclist: exclude the "idle" kernel process when GLIBTOP_EXCLUDE_IDLE.
- Remove extraneous glibtop_init() calls.
* Linux:
- proc_mem: implement Pss and Swap.
- Remove extraneous glibtop_init() calls.
* All:
- Propagate the change that machine in struct glibtop is now a
pointer. Hope that change doesn't break build on other platforms,
I can only test Linux and FreeBSD.
5 August 2015: Overview of changes in 2.31.4
=============================================
* 71 commits !

View File

@@ -3,8 +3,8 @@ dnl Configure script for the Gnome library
dnl
m4_define([libgtop_major_version], [2])
m4_define([libgtop_minor_version], [31])
m4_define([libgtop_micro_version], [4])
m4_define([libgtop_minor_version], [34])
m4_define([libgtop_micro_version], [0])
m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version])
dnl increment if the interface has additions, changes, removals.
@@ -275,10 +275,6 @@ dnl These definitions are expanded in make.
LIBGTOP_LIBS='-L$(libdir)'
LIBGTOP_INCS='-I$(includedir)/libgtop-2.0'
if test x$libgtop_use_machine_h = xyes ; then
LIBGTOP_INCS="$LIBGTOP_INCS -DHAVE_GLIBTOP_MACHINE_H"
fi
if test x$libgtop_have_sysinfo = xyes ; then
LIBGTOP_INCS="$LIBGTOP_INCS -DHAVE_LIBGTOP_SYSINFO"
fi
@@ -307,12 +303,6 @@ LIBGTOP_EXTRA_LIBS="$GLIB_LIBS $LIBGTOP_EXTRA_LIBS"
LIBGTOP_LIBS="$LIBGTOP_LIBS"
LIBGTOP_LIBS="$LIBGTOP_LIBS"
machine_incs="-I\$(top_srcdir)/sysdeps/$sysdeps_dir"
AC_SUBST(machine_incs)
if test "$GCC" = "yes" ; then
CFLAGS="\
-Winline \

View File

@@ -22,12 +22,17 @@
#ifndef __GLIBTOP_H__
#define __GLIBTOP_H__
/* for pid_t, uid_t, gid_t */
#include <sys/types.h>
#include <glib.h>
#include <glib-object.h>
G_BEGIN_DECLS
typedef struct _glibtop glibtop;
typedef struct _glibtop_machine glibtop_machine;
/**
* LIBGTOP_CHECK_VERSION
@@ -55,10 +60,6 @@ LIBGTOP_MICRO_VERSION >= (micro)))
#include <glibtop_server.h>
#ifdef HAVE_GLIBTOP_MACHINE_H
#include <glibtop_machine.h>
#endif
#ifndef GLIBTOP_MOUNTENTRY_LEN
#define GLIBTOP_MOUNTENTRY_LEN 79
#endif
@@ -69,34 +70,6 @@ LIBGTOP_MICRO_VERSION >= (micro)))
#include <glibtop/close.h>
#ifdef HAVE_GLIBTOP_MACHINE_H
struct _glibtop
{
unsigned flags;
unsigned method; /* Server Method */
unsigned error_method; /* Error Method */
glibtop_machine machine; /* Machine dependent data */
int input [2]; /* Pipe client <- server */
int output [2]; /* Pipe client -> server */
int socket; /* Accepted connection of a socket */
int ncpu; /* Number of CPUs, zero if single-processor */
int real_ncpu; /* Real number of CPUs. Only ncpu are monitored */
unsigned long os_version_code; /* Version code of the operating system */
const char *name; /* Program name for error messages */
const char *server_command; /* Command used to invoke server */
const char *server_host; /* Host the server should run on */
const char *server_user; /* Name of the user on the target host */
const char *server_rsh; /* Command used to connect to the target host */
unsigned long features; /* Server is required for this features */
unsigned long server_port; /* Port on which daemon is listening */
glibtop_sysdeps sysdeps; /* Detailed feature list */
glibtop_sysdeps required; /* Required feature list */
pid_t pid; /* PID of the server */
};
#else /* !HAVE_GLIBTOP_MACHINE_H */
struct _glibtop
{
unsigned flags;
@@ -118,9 +91,14 @@ struct _glibtop
glibtop_sysdeps sysdeps; /* Detailed feature list */
glibtop_sysdeps required; /* Required feature list */
pid_t pid; /* PID of the server */
};
#endif /* HAVE_GLIBTOP_MACHINE_H */
uid_t uid;
uid_t euid;
gid_t gid;
gid_t egid;
glibtop_machine *machine; /* Machine dependent data */
};
extern glibtop *glibtop_global_server;

View File

@@ -2,7 +2,7 @@ glibtopdir = $(includedir)/libgtop-2.0/glibtop
glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \
sem_limits.h uptime.h command.h mem.h proclist.h \
proctime.h shm_limits.h version.h cpu.h msg_limits.h \
proctime.h shm_limits.h cpu.h msg_limits.h \
procmem.h procuid.h swap.h \
procsegment.h sysdeps.h global.h \
procsignal.h union.h gnuserv.h \
@@ -11,4 +11,6 @@ glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \
procwd.h procaffinity.h \
netlist.h procopenfiles.h open.h
noinst_HEADERS = error.h write.h read_data.h read.h init_hooks.h
noinst_HEADERS = error.h write.h read_data.h read.h init_hooks.h machine.h \
version.h

View File

@@ -50,7 +50,7 @@ void glibtop_warn_io (const char *format, ...) G_GNUC_PRINTF(1, 2);
#define glibtop_debug_r(server, fmt, ...) \
G_STMT_START { \
if (LIBGTOP_ENABLE_DEBUG) \
glibtop_debug_r_real(server, fmt, ##__VA_ARGS__); \
glibtop_debug_r_real(server, "%s:%d %s(): " fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
} G_STMT_END
#define glibtop_debug(...) glibtop_debug_r(glibtop_global_server, __VA_ARGS__)

22
include/glibtop/machine.h Normal file
View File

@@ -0,0 +1,22 @@
#ifndef GLIBTOP_SYSDEPS_COMMON_MACHINE_H_1437506041
#define GLIBTOP_SYSDEPS_COMMON_MACHINE_H_1437506041
#include <glib.h>
#include <glibtop_machine.h>
/* private */
static inline void
glibtop_machine_new(glibtop *server)
{
server->machine = g_new0(glibtop_machine, 1);
}
/* private */
static inline void
glibtop_machine_delete(glibtop *server)
{
g_free(server->machine);
server->machine = NULL;
}
#endif /* GLIBTOP_SYSDEPS_COMMON_MACHINE_H_1437506041 */

View File

@@ -55,7 +55,7 @@ struct _glibtop_mountlist
/**
* glibtop_get_mountlist:
* @buf: (out):
* @buf:
* @all_fs:
*
* Returns: (transfer full):

View File

@@ -29,6 +29,7 @@ typedef struct _glibtop_proc_affinity glibtop_proc_affinity;
#define GLIBTOP_PROC_AFFINITY_NUMBER 0
#define GLIBTOP_PROC_AFFINITY_ALL 1
#define GLIBTOP_MAX_PROC_AFFINITY 2
struct _glibtop_proc_affinity
{

View File

@@ -79,6 +79,15 @@ char **
glibtop_get_proc_argv_l (glibtop *server, glibtop_proc_args *buf,
pid_t pid, unsigned max_len);
/**
* glibtop_get_proc_argv:
* @buf:
* @pid:
* @max_len:
*
* Returns: (transfer full):
*/
char **
glibtop_get_proc_argv (glibtop_proc_args *buf, pid_t pid, unsigned max_len);

View File

@@ -48,8 +48,10 @@ G_BEGIN_DECLS
#define GLIBTOP_MAP_ENTRY_SHARED_DIRTY 10
#define GLIBTOP_MAP_ENTRY_PRIVATE_CLEAN 11
#define GLIBTOP_MAP_ENTRY_PRIVATE_DIRTY 12
#define GLIBTOP_MAP_ENTRY_PSS 13
#define GLIBTOP_MAP_ENTRY_SWAP 14
#define GLIBTOP_MAX_MAP_ENTRY 13
#define GLIBTOP_MAX_MAP_ENTRY 15
#define GLIBTOP_MAP_FILENAME_LEN 215
@@ -78,6 +80,8 @@ struct _glibtop_map_entry
guint64 shared_dirty;
guint64 private_clean;
guint64 private_dirty;
guint64 pss;
guint64 swap;
char filename [GLIBTOP_MAP_FILENAME_LEN+1];
};
@@ -88,17 +92,18 @@ struct _glibtop_proc_map
guint64 total; /* GLIBTOP_PROC_MAP_TOTAL */
guint64 size; /* GLIBTOP_PROC_MAP_SIZE */
};
glibtop_map_entry *
glibtop_get_proc_map(glibtop_proc_map *buf, pid_t pid);
/**
* glibtop_get_proc_map:
* @buf: (out):
* @buf:
* @pid:
*
* Returns: (transfer none):
*/
glibtop_map_entry *
glibtop_get_proc_map(glibtop_proc_map *buf, pid_t pid);
/**
* glibtop_get_proc_map_l:

View File

@@ -53,6 +53,12 @@ struct _glibtop_proc_mem
* of the process; usually 2,147,483,647 */
};
/**
* glibtop_get_proc_map:
* @buf:
* @pid:
*
*/
void glibtop_get_proc_mem(glibtop_proc_mem *buf, pid_t pid);
#if GLIBTOP_SUID_PROC_MEM

View File

@@ -96,7 +96,7 @@ struct _glibtop_proc_open_files
/**
* glibtop_get_proc_open_files:
* @buf: (out):
* @buf:
* @pid:
*
* Returns: (transfer none):

View File

@@ -30,7 +30,7 @@ typedef struct _glibtop_proc_wd glibtop_proc_wd;
#define GLIBTOP_PROC_WD_NUMBER 0
#define GLIBTOP_PROC_WD_ROOT 1
#define GLIBTOP_PROC_WD_EXE 2
#define GLIBTOP_PROC_WD_MAX 3
#define GLIBTOP_MAX_PROC_WD 3
#define GLIBTOP_PROC_WD_ROOT_LEN 215
#define GLIBTOP_PROC_WD_EXE_LEN 215
@@ -44,6 +44,13 @@ struct _glibtop_proc_wd
};
/**
* glibtop_get_proc_wd:
* @buf:
* @pid:
*
* Returns: (transfer full):
*/
char ** glibtop_get_proc_wd(glibtop_proc_wd *buf, pid_t pid);
char ** glibtop_get_proc_wd_l(glibtop *server, glibtop_proc_wd *buf, pid_t pid);

View File

@@ -26,10 +26,10 @@ INTROSPECTION_SCANNER_ARGS = --accept-unprefixed --warn-all
INTROSPECTION_COMPILER_ARGS =
if HAVE_INTROSPECTION
introspection_sources = $(libgtop_2_0_la_SOURCES) lib.c ../glibtop.h \
introspection_sources = $(libgtop_2_0_la_SOURCES) lib.c ../glibtop.h ../libgtopconfig.h \
../include/glibtop/close.h ../include/glibtop/loadavg.h ../include/glibtop/prockernel.h ../include/glibtop/procstate.h \
../include/glibtop/sem_limits.h ../include/glibtop/uptime.h ../include/glibtop/command.h ../include/glibtop/mem.h ../include/glibtop/proclist.h \
../include/glibtop/proctime.h ../include/glibtop/shm_limits.h ../include/glibtop/version.h ../include/glibtop/cpu.h ../include/glibtop/msg_limits.h \
../include/glibtop/proctime.h ../include/glibtop/shm_limits.h ../include/glibtop/cpu.h ../include/glibtop/msg_limits.h \
../include/glibtop/procmem.h ../include/glibtop/procuid.h ../include/glibtop/swap.h \
../include/glibtop/procsegment.h ../include/glibtop/sysdeps.h ../include/glibtop/global.h \
../include/glibtop/procsignal.h ../include/glibtop/union.h ../include/glibtop/gnuserv.h \

View File

@@ -26,12 +26,14 @@
#include <glibtop/open.h>
#include <glibtop/parameter.h>
#include <glibtop/init_hooks.h>
#include <glibtop/machine.h>
#ifndef DEFAULT_PORT
#define DEFAULT_PORT 42800
#endif
static glibtop _glibtop_global_server = { 0 };
static glibtop _glibtop_global_server;
glibtop *glibtop_global_server = &_glibtop_global_server;
static void
@@ -173,6 +175,9 @@ glibtop_init_r (glibtop **server_ptr, unsigned long features, unsigned flags)
/* Do the initialization, but only if not already initialized. */
if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) {
glibtop_machine_new (server);
if (flags & GLIBTOP_FEATURES_EXCEPT)
features = ~features & GLIBTOP_SYSDEPS_ALL;
@@ -221,6 +226,8 @@ glibtop_init_s (glibtop **server_ptr, unsigned long features, unsigned flags)
glibtop *server;
const _glibtop_init_func_t *init_fkt;
glibtop_debug("init_s with features=%#0lx and flags=%#0x", features, flags);
if (server_ptr == NULL)
return NULL;

View File

@@ -153,7 +153,7 @@ glibtop_open_l (glibtop *server, const char *program_name,
memcpy (&server->sysdeps, &sysdeps, sizeof (glibtop_sysdeps));
glibtop_debug ("Server features are %lu.",
glibtop_debug ("Server features are %#0lx.",
server->features);
}

View File

@@ -4,9 +4,6 @@ dnl
dnl It defines the following variables:
dnl
dnl * 'libgtop_sysdeps_dir' - sysdeps dir for libgtop.
dnl * 'libgtop_use_machine_h' - some of system dependend parts of libgtop provide
dnl their own header file. In this case we need to
dnl define 'HAVE_GLIBTOP_MACHINE_H'.
dnl * 'libgtop_need_server' - is the server really needed? Defines 'LIBGTOP_NEED_SERVER'
dnl if true; defines conditional 'LIBGTOP_NEED_SERVER'.
@@ -14,7 +11,6 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
AC_REQUIRE([AC_CANONICAL_HOST])
AC_SUBST(libgtop_sysdeps_dir)
AC_SUBST(libgtop_use_machine_h)
AC_SUBST(libgtop_need_server)
AC_ARG_WITH(libgtop-examples,
@@ -36,7 +32,6 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
case "$host_os" in
linux*)
libgtop_sysdeps_dir=linux
libgtop_use_machine_h=no
libgtop_have_sysinfo=yes
libgtop_need_server=no
libgtop_sysdeps_private_mountlist=yes
@@ -44,13 +39,11 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
;;
netbsd*|bsdi*)
libgtop_sysdeps_dir=bsd
libgtop_use_machine_h=yes
libgtop_need_server=yes
libgtop_postinstall='chgrp kmem $(bindir)/libgtop_server2 && chmod 2755 $(bindir)/libgtop_server2'
;;
openbsd*)
libgtop_sysdeps_dir=openbsd
libgtop_use_machine_h=yes
libgtop_need_server=yes
libgtop_sysdeps_private_mountlist=yes
libgtop_sysdeps_private_fsusage=yes
@@ -58,7 +51,6 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
;;
freebsd*|kfreebsd*)
libgtop_sysdeps_dir=freebsd
libgtop_use_machine_h=yes
libgtop_need_server=yes
libgtop_sysdeps_private_mountlist=yes
libgtop_sysdeps_private_fsusage=yes
@@ -66,27 +58,23 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
;;
solaris*)
libgtop_sysdeps_dir=solaris
libgtop_use_machine_h=yes
libgtop_need_server=yes
libgtop_postinstall='chgrp sys $(bindir)/libgtop_server && chmod 2755 $(bindir)/libgtop_server'
;;
aix*)
libgtop_sysdeps_dir=aix
libgtop_use_machine_h=yes
libgtop_need_server=yes
libgtop_have_sysinfo=yes
libgtop_postinstall='chgrp system $(bindir)/libgtop_server && chmod g+s $(bindir)/libgtop_server2'
;;
darwin*)
libgtop_sysdeps_dir=darwin
libgtop_use_machine_h=yes
libgtop_need_server=yes
libgtop_have_sysinfo=yes
libgtop_postinstall='chgrp kmem $(bindir)/libgtop_server2 && chmod g+s $(bindir)/libgtop_server2'
;;
cygwin*)
libgtop_sysdeps_dir=cygwin
libgtop_use_machine_h=no
libgtop_need_server=no
libgtop_have_sysinfo=yes
libgtop_sysdeps_private_mountlist=yes
@@ -98,23 +86,19 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
#Please note that this port is obsolete and not working at
#all. It is only useful for people who want to fix it ... :-)
libgtop_sysdeps_dir=sun4
libgtop_use_machine_h=yes
libgtop_need_server=yes
;;
osf*)
libgtop_sysdeps_dir=osf1
libgtop_use_machine_h=yes
libgtop_need_server=yes
;;
*)
libgtop_sysdeps_dir=stub
libgtop_use_machine_h=no
libgtop_need_server=no
;;
esac
else
libgtop_sysdeps_dir=stub
libgtop_use_machine_h=no
libgtop_need_server=no
fi
;;
@@ -277,9 +261,6 @@ main (void)
;;
esac
AC_MSG_CHECKING(for machine.h in libgtop sysdeps dir)
AC_MSG_RESULT($libgtop_use_machine_h)
AC_MSG_CHECKING(whether we need libgtop)
AC_MSG_RESULT($libgtop_need_server)
@@ -287,11 +268,6 @@ main (void)
AC_DEFINE(LIBGTOP_NEED_SERVER, 1, [Define if libgtop server is required])
fi
if test x$libgtop_use_machine_h = xyes ; then
AC_DEFINE(HAVE_GLIBTOP_MACHINE_H, 1,
[Define if machine.h in libgtop sysdeps dir])
fi
AM_CONDITIONAL(LIBGTOP_NEED_SERVER, test x$libgtop_need_server = xyes)
AM_CONDITIONAL(LIBGTOP_SYSDEPS_PRIVATE_MOUNTLIST, test x$libgtop_sysdeps_private_mountlist = xyes)
AM_CONDITIONAL(LIBGTOP_SYSDEPS_PRIVATE_FSUSAGE, test x$libgtop_sysdeps_private_fsusage = xyes)

119
po/oc.po
View File

@@ -1,194 +1,193 @@
# Occitan translation of libgtop.
# Copyright (C) 1998-2004 Free Software Foundation, Inc.
# This file is distributed under the GNU General Public License Version 2.
#
#
#
# Cédric Valmary (Tot en Òc) <cvalmary@yahoo.fr>, 2015.
# Cédric Valmary <cvalmary@yahoo.fr>, 2015.
# Cédric Valmary (Tot en òc) <cvalmary@yahoo.fr>, 2015.
msgid ""
msgstr ""
"Project-Id-Version: libgtop 2.9.91\n"
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=libgto"
"p&keywords=I18N+L10N&component=general\n"
"POT-Creation-Date: 2013-12-19 14:39+0000\n"
"PO-Revision-Date: 2015-04-30 09:46+0200\n"
"Last-Translator: Cédric Valmary (Tot en Òc) <cvalmary@yahoo.fr>\n"
"Language-Team: www.totenoc.eu\n"
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?"
"product=libgtop&keywords=I18N+L10N&component=general\n"
"POT-Creation-Date: 2015-11-10 14:02+0000\n"
"PO-Revision-Date: 2015-10-31 08:15+0200\n"
"Last-Translator: Cédric Valmary (Tot en òc) <cvalmary@yahoo.fr>\n"
"Language-Team: Tot en òc (totenoc.eu)\n"
"Language: oc\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Virtaal 0.7.0\n"
"X-Generator: Virtaal 0.7.1\n"
"X-Project-Style: gnome\n"
#: ../lib/read.c:51
#, c-format
#: ../lib/read.c:49
#, c-format
msgid "read %d byte"
msgid_plural "read %d bytes"
msgstr[0] "%d octet legit"
msgstr[1] "%d octets legits"
#: ../lib/read_data.c:51
#: ../lib/read_data.c:49
msgid "read data size"
msgstr "talha de las donadas legidas"
#: ../lib/read_data.c:70
#, c-format
#: ../lib/read_data.c:66
#, c-format
msgid "read %lu byte of data"
msgid_plural "read %lu bytes of data"
msgstr[0] "lectura de %lu octet de donadas"
msgstr[1] "lectura de %lu octets de donadas"
#: ../lib/write.c:51
#, c-format
#: ../lib/write.c:49
#, c-format
msgid "wrote %d byte"
msgid_plural "wrote %d bytes"
msgstr[0] "escritura de %d octet"
msgstr[1] "escritura de %d octets"
#: ../src/daemon/gnuserv.c:455
#: ../src/daemon/gnuserv.c:455
msgid "Enable debugging"
msgstr "Activa lo desbugatge"
#: ../src/daemon/gnuserv.c:457
#: ../src/daemon/gnuserv.c:457
msgid "Enable verbose output"
msgstr "Activa la sortida charraira"
msgstr "Activa la sortida verbosa"
#: ../src/daemon/gnuserv.c:459
#: ../src/daemon/gnuserv.c:459
msgid "Don't fork into background"
msgstr "Aviar pas en prètzfach de fons"
#: ../src/daemon/gnuserv.c:461
#: ../src/daemon/gnuserv.c:461
msgid "Invoked from inetd"
msgstr "Invocat a partir de inetd"
msgstr "Invocat a partir d'inetd"
#: ../src/daemon/gnuserv.c:495
#, c-format
#: ../src/daemon/gnuserv.c:495
#, c-format
msgid "Run '%s --help' to see a full list of available command line options.\n"
msgstr "Aviar « %s --help » per afichar la lista de las opcions de la linha de "
msgstr ""
"Aviar « %s --help » per afichar la lista de las opcions de la linha de "
"comanda.\n"
#: ../sysdeps/osf1/siglist.c:27 ../sysdeps/sun4/siglist.c:27
#: ../sysdeps/osf1/siglist.c:27 ../sysdeps/sun4/siglist.c:27
msgid "Hangup"
msgstr "Hangup"
#: ../sysdeps/osf1/siglist.c:28 ../sysdeps/sun4/siglist.c:28
#: ../sysdeps/osf1/siglist.c:28 ../sysdeps/sun4/siglist.c:28
msgid "Interrupt"
msgstr "Interrupcion"
#: ../sysdeps/osf1/siglist.c:29 ../sysdeps/sun4/siglist.c:29
#: ../sysdeps/osf1/siglist.c:29 ../sysdeps/sun4/siglist.c:29
msgid "Quit"
msgstr "Quitar"
#: ../sysdeps/osf1/siglist.c:30 ../sysdeps/sun4/siglist.c:30
#: ../sysdeps/osf1/siglist.c:30 ../sysdeps/sun4/siglist.c:30
msgid "Illegal instruction"
msgstr "Instruccion illegala"
#: ../sysdeps/osf1/siglist.c:31 ../sysdeps/sun4/siglist.c:31
#: ../sysdeps/osf1/siglist.c:31 ../sysdeps/sun4/siglist.c:31
msgid "Trace trap"
msgstr "Punt d'arrèst rencontrat"
#: ../sysdeps/osf1/siglist.c:32 ../sysdeps/sun4/siglist.c:32
#: ../sysdeps/osf1/siglist.c:32 ../sysdeps/sun4/siglist.c:32
msgid "Abort"
msgstr "Anullacion"
#: ../sysdeps/osf1/siglist.c:33 ../sysdeps/sun4/siglist.c:33
#: ../sysdeps/osf1/siglist.c:33 ../sysdeps/sun4/siglist.c:33
msgid "EMT error"
msgstr "Error EMT"
#: ../sysdeps/osf1/siglist.c:34 ../sysdeps/sun4/siglist.c:34
#: ../sysdeps/osf1/siglist.c:34 ../sysdeps/sun4/siglist.c:34
msgid "Floating-point exception"
msgstr "Excepcion virgula flotanta"
#: ../sysdeps/osf1/siglist.c:35 ../sysdeps/sun4/siglist.c:35
#: ../sysdeps/osf1/siglist.c:35 ../sysdeps/sun4/siglist.c:35
msgid "Kill"
msgstr "Tuar"
#: ../sysdeps/osf1/siglist.c:36 ../sysdeps/sun4/siglist.c:36
#: ../sysdeps/osf1/siglist.c:36 ../sysdeps/sun4/siglist.c:36
msgid "Bus error"
msgstr "Error bus"
#: ../sysdeps/osf1/siglist.c:37 ../sysdeps/sun4/siglist.c:37
#: ../sysdeps/osf1/siglist.c:37 ../sysdeps/sun4/siglist.c:37
msgid "Segmentation violation"
msgstr "Violacion de segmentacion"
#: ../sysdeps/osf1/siglist.c:38 ../sysdeps/sun4/siglist.c:38
#: ../sysdeps/osf1/siglist.c:38 ../sysdeps/sun4/siglist.c:38
msgid "Bad argument to system call"
msgstr "Marrit argument d'apèl sistèma"
#: ../sysdeps/osf1/siglist.c:39 ../sysdeps/sun4/siglist.c:39
#: ../sysdeps/osf1/siglist.c:39 ../sysdeps/sun4/siglist.c:39
msgid "Broken pipe"
msgstr "Tub copat"
#: ../sysdeps/osf1/siglist.c:40 ../sysdeps/sun4/siglist.c:40
#: ../sysdeps/osf1/siglist.c:40 ../sysdeps/sun4/siglist.c:40
msgid "Alarm clock"
msgstr "Alarma de relòtge"
#: ../sysdeps/osf1/siglist.c:41 ../sysdeps/sun4/siglist.c:41
#: ../sysdeps/osf1/siglist.c:41 ../sysdeps/sun4/siglist.c:41
msgid "Termination"
msgstr "Senhal de fin"
#: ../sysdeps/osf1/siglist.c:42 ../sysdeps/sun4/siglist.c:42
#: ../sysdeps/osf1/siglist.c:42 ../sysdeps/sun4/siglist.c:42
msgid "Urgent condition on socket"
msgstr "Condicion urgenta sus socket"
#: ../sysdeps/osf1/siglist.c:43 ../sysdeps/sun4/siglist.c:43
#: ../sysdeps/osf1/siglist.c:43 ../sysdeps/sun4/siglist.c:43
msgid "Stop"
msgstr "Arrèst"
#: ../sysdeps/osf1/siglist.c:44 ../sysdeps/sun4/siglist.c:44
#: ../sysdeps/osf1/siglist.c:44 ../sysdeps/sun4/siglist.c:44
msgid "Keyboard stop"
msgstr "Arrèst dempuèi lo clavièr"
#: ../sysdeps/osf1/siglist.c:45 ../sysdeps/sun4/siglist.c:45
#: ../sysdeps/osf1/siglist.c:45 ../sysdeps/sun4/siglist.c:45
msgid "Continue"
msgstr "Contunhar"
#: ../sysdeps/osf1/siglist.c:46 ../sysdeps/sun4/siglist.c:46
#: ../sysdeps/osf1/siglist.c:46 ../sysdeps/sun4/siglist.c:46
msgid "Child status has changed"
msgstr "L'estat del filh a cambiat"
#: ../sysdeps/osf1/siglist.c:47 ../sysdeps/sun4/siglist.c:47
#: ../sysdeps/osf1/siglist.c:47 ../sysdeps/sun4/siglist.c:47
msgid "Background read from tty"
msgstr "Lectura sus tty en rèire plan"
msgstr "Lectura sus tty en rèireplan"
#: ../sysdeps/osf1/siglist.c:48 ../sysdeps/sun4/siglist.c:48
#: ../sysdeps/osf1/siglist.c:48 ../sysdeps/sun4/siglist.c:48
msgid "Background write to tty"
msgstr "Escritura sus tty en rèire plan"
msgstr "Escritura sus tty en rèireplan"
#: ../sysdeps/osf1/siglist.c:49 ../sysdeps/sun4/siglist.c:49
#: ../sysdeps/osf1/siglist.c:49 ../sysdeps/sun4/siglist.c:49
msgid "I/O now possible"
msgstr "E/S ara possibla"
#: ../sysdeps/osf1/siglist.c:50 ../sysdeps/sun4/siglist.c:50
#: ../sysdeps/osf1/siglist.c:50 ../sysdeps/sun4/siglist.c:50
msgid "CPU limit exceeded"
msgstr "Limit de temps CPU depassat"
#: ../sysdeps/osf1/siglist.c:51 ../sysdeps/sun4/siglist.c:51
#: ../sysdeps/osf1/siglist.c:51 ../sysdeps/sun4/siglist.c:51
msgid "File size limit exceeded"
msgstr "Talha de fichièr excessiva"
#: ../sysdeps/osf1/siglist.c:52 ../sysdeps/sun4/siglist.c:52
#: ../sysdeps/osf1/siglist.c:52 ../sysdeps/sun4/siglist.c:52
msgid "Virtual alarm clock"
msgstr "Alarma virtuala"
#: ../sysdeps/osf1/siglist.c:53 ../sysdeps/sun4/siglist.c:53
#: ../sysdeps/osf1/siglist.c:53 ../sysdeps/sun4/siglist.c:53
msgid "Profiling alarm clock"
msgstr "Perfil de l'alarma"
#: ../sysdeps/osf1/siglist.c:54 ../sysdeps/sun4/siglist.c:54
#: ../sysdeps/osf1/siglist.c:54 ../sysdeps/sun4/siglist.c:54
msgid "Window size change"
msgstr "Redimensionament de la fenèstra"
#: ../sysdeps/osf1/siglist.c:55 ../sysdeps/sun4/siglist.c:55
#: ../sysdeps/osf1/siglist.c:55 ../sysdeps/sun4/siglist.c:55
msgid "Information request"
msgstr "Demanda d'informacion"
#: ../sysdeps/osf1/siglist.c:56 ../sysdeps/sun4/siglist.c:56
#: ../sysdeps/osf1/siglist.c:56 ../sysdeps/sun4/siglist.c:56
msgid "User defined signal 1"
msgstr "Senhal utilizaire 1"
#: ../sysdeps/osf1/siglist.c:57 ../sysdeps/sun4/siglist.c:57
#: ../sysdeps/osf1/siglist.c:57 ../sysdeps/sun4/siglist.c:57
msgid "User defined signal 2"
msgstr "Senhal utilizaire 2"

View File

@@ -6,14 +6,14 @@
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Zbigniew Chyla <chyla@alice.ci.pwr.wroc.pl>, 1999-2002.
# Artur Flinta <aflinta@at.kernel.pl>, 2004-2007.
# Piotr Drąg <piotrdrag@gmail.com>, 2010-2012.
# Aviary.pl <gnomepl@aviary.pl>, 2010-2012.
# Piotr Drąg <piotrdrag@gmail.com>, 2010-2015.
# Aviary.pl <gnomepl@aviary.pl>, 2010-2015.
msgid ""
msgstr ""
"Project-Id-Version: libgtop\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-09-04 18:37+0200\n"
"PO-Revision-Date: 2012-09-04 18:42+0200\n"
"POT-Creation-Date: 2015-08-26 19:45+0200\n"
"PO-Revision-Date: 2015-08-26 19:47+0200\n"
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
"Language-Team: Polish <gnomepl@aviary.pl>\n"
"Language: pl\n"
@@ -25,7 +25,7 @@ msgstr ""
"X-Poedit-Language: Polish\n"
"X-Poedit-Country: Poland\n"
#: ../lib/read.c:51
#: ../lib/read.c:49
#, c-format
msgid "read %d byte"
msgid_plural "read %d bytes"
@@ -33,11 +33,11 @@ msgstr[0] "odczyt %d bajtu"
msgstr[1] "odczyt %d bajtów"
msgstr[2] "odczyt %d bajtów"
#: ../lib/read_data.c:51
#: ../lib/read_data.c:49
msgid "read data size"
msgstr "odczyt rozmiaru danych"
#: ../lib/read_data.c:70
#: ../lib/read_data.c:66
#, c-format
msgid "read %lu byte of data"
msgid_plural "read %lu bytes of data"
@@ -45,7 +45,7 @@ msgstr[0] "odczytano jeden bajt danych"
msgstr[1] "odczytano %lu bajty danych"
msgstr[2] "odczytano %lu bajtów danych"
#: ../lib/write.c:51
#: ../lib/write.c:49
#, c-format
msgid "wrote %d byte"
msgid_plural "wrote %d bytes"
@@ -73,7 +73,7 @@ msgstr "Wywołanie przez inetd"
#, c-format
msgid "Run '%s --help' to see a full list of available command line options.\n"
msgstr ""
"Polecenie \"%s --help\" wyświetli pełną listę dostępnych opcji wiersza "
"Polecenie %s --help wyświetli pełną listę dostępnych opcji wiersza "
"poleceń.\n"
#: ../sysdeps/osf1/siglist.c:27 ../sysdeps/sun4/siglist.c:27

View File

@@ -43,6 +43,7 @@
#include <glibtop/gnuserv.h>
#include <errno.h>
#include <locale.h>
#include "daemon.h"
@@ -473,6 +474,8 @@ main (int argc, char **argv)
int ils = -1; /* internet domain listen socket */
setlocale (LC_ALL, "");
/* On non-glibc systems, this is not set up for us. */
if (!program_invocation_name) {
char *arg;

View File

@@ -25,6 +25,8 @@
#include <glibtop.h>
#include <glibtop/union.h>
#include <glibtop/sysdeps.h>
#include <glibtop/error.h>
#include <glibtop/machine.h>
#include <sys/utsname.h>
@@ -42,6 +44,8 @@ main(int argc, char *argv[])
uid = getuid (); euid = geteuid ();
gid = getgid (); egid = getegid ();
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
if (uname (&uts) < 0) _exit (1);
#ifdef _AIX
@@ -72,12 +76,18 @@ main(int argc, char *argv[])
}
#endif
glibtop_machine_new (glibtop_global_server);
glibtop_init_p (glibtop_global_server, 0, 0);
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
if (setreuid (euid, uid)) _exit (1);
if (setregid (egid, gid)) _exit (1);
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
/* !!! END OF SUID ROOT PART !!! */
handle_slave_connection (0, 0);

View File

@@ -56,7 +56,7 @@ _glibtop_init_cpu_p (glibtop *server)
{
return;
}
server->machine.sysinfo_offset = result;
server->machine->sysinfo_offset = result;
result = _glibtop_get_kmem_offset(server, "cpuinfo");
if (result == -1)
@@ -65,9 +65,9 @@ _glibtop_init_cpu_p (glibtop *server)
return;
}
server->machine.cpuinfo_offset = result;
server->machine->cpuinfo_offset = result;
server->machine.cpuinfo = (struct cpuinfo*)calloc(_system_configuration.ncpus, sizeof(struct cpuinfo));
server->machine->cpuinfo = (struct cpuinfo*)calloc(_system_configuration.ncpus, sizeof(struct cpuinfo));
server->sysdeps.cpu = _glibtop_sysdeps_cpu;
}
@@ -85,7 +85,7 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
memset (buf, 0, sizeof (glibtop_cpu));
result = _glibtop_get_kmem_info(server, server->machine.sysinfo_offset,
result = _glibtop_get_kmem_info(server, server->machine->sysinfo_offset,
&sysinfo, sizeof(struct sysinfo));
if (result <= 0)
{
@@ -100,8 +100,8 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
buf->total = buf->idle + buf->user + buf->sys + buf->nice ;
result = _glibtop_get_kmem_info(server, server->machine.cpuinfo_offset,
server->machine.cpuinfo,
result = _glibtop_get_kmem_info(server, server->machine->cpuinfo_offset,
server->machine->cpuinfo,
_system_configuration.ncpus
* sizeof(struct cpuinfo));
@@ -115,13 +115,13 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
for (cpu = 0; cpu < MIN(GLIBTOP_NCPU, _system_configuration.ncpus); cpu++)
{
buf->xcpu_idle[cpu] =
server->machine.cpuinfo[cpu].cpu[CPU_IDLE];
server->machine->cpuinfo[cpu].cpu[CPU_IDLE];
buf->xcpu_user[cpu] =
server->machine.cpuinfo[cpu].cpu[CPU_USER];
server->machine->cpuinfo[cpu].cpu[CPU_USER];
buf->xcpu_sys[cpu] =
server->machine.cpuinfo[cpu].cpu[CPU_KERNEL];
server->machine->cpuinfo[cpu].cpu[CPU_KERNEL];
buf->xcpu_nice[cpu] =
server->machine.cpuinfo[cpu].cpu[CPU_WAIT];
server->machine->cpuinfo[cpu].cpu[CPU_WAIT];
buf->xcpu_total[cpu] = buf->xcpu_idle[cpu] +
buf->xcpu_user[cpu] +

View File

@@ -26,8 +26,6 @@
G_BEGIN_DECLS
typedef struct _glibtop_machine glibtop_machine;
struct _glibtop_machine
{
uid_t uid, euid;

View File

@@ -29,11 +29,11 @@ G_BEGIN_DECLS
#endif
static inline void glibtop_suid_enter (glibtop *server) {
setegid (server->machine.egid);
setegid (server->machine->egid);
}
static inline void glibtop_suid_leave (glibtop *server) {
if (setegid (server->machine.gid))
if (setegid (server->machine->gid))
_exit (1);
}

View File

@@ -44,7 +44,7 @@ _glibtop_init_loadavg_p (glibtop *server)
return;
}
server->machine.loadavg_offset = result;
server->machine->loadavg_offset = result;
server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
}
@@ -61,7 +61,7 @@ glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf)
memset (buf, 0, sizeof (glibtop_loadavg));
result = _glibtop_get_kmem_info(server, server->machine.loadavg_offset,
result = _glibtop_get_kmem_info(server, server->machine->loadavg_offset,
loadavg, sizeof(loadavg));
if (result <= 0)
{

View File

@@ -44,7 +44,7 @@ _glibtop_init_msg_limits_p (glibtop *server)
return;
}
server->machine.msginfo_offset = result;
server->machine->msginfo_offset = result;
server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
}
@@ -61,7 +61,7 @@ glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
memset (buf, 0, sizeof (glibtop_msg_limits));
result = _glibtop_get_kmem_info(server, server->machine.msginfo_offset,
result = _glibtop_get_kmem_info(server, server->machine->msginfo_offset,
&msginfo, sizeof(msginfo));
if (result <= 0)

View File

@@ -100,7 +100,7 @@ _glibtop_init_netload_p (glibtop *server)
return;
}
server->machine.ifnet_offset = addr;
server->machine->ifnet_offset = addr;
server->sysdeps.netload = _glibtop_sysdeps_netload;
}
@@ -122,7 +122,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
memset (buf, 0, sizeof (glibtop_netload));
for ( offset = server->machine.ifnet_offset;
for ( offset = server->machine->ifnet_offset;
offset != 0;
offset = (off_t)ifnet.if_next
)

View File

@@ -56,23 +56,23 @@ glibtop_open_p (glibtop *server, const char *program_name,
{
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
server->machine.uid = getuid ();
server->machine.euid = geteuid ();
server->machine.gid = getgid ();
server->machine.egid = getegid ();
server->machine->uid = getuid ();
server->machine->euid = geteuid ();
server->machine->gid = getgid ();
server->machine->egid = getegid ();
/* open kmem */
server->machine.kmem_fd = open("/dev/kmem", O_RDONLY);
if (server->machine.kmem_fd == -1)
server->machine->kmem_fd = open("/dev/kmem", O_RDONLY);
if (server->machine->kmem_fd == -1)
glibtop_error_io_r (server, "Cannot open /dev/kmem");
/* Drop priviledges. */
if (seteuid (server->machine.uid))
if (seteuid (server->machine->uid))
_exit (1);
if (setegid (server->machine.gid))
if (setegid (server->machine->gid))
_exit (1);
/* !!! END OF SUID ROOT PART !!! */

View File

@@ -46,7 +46,7 @@ _glibtop_init_sem_limits_p (glibtop *server)
return;
}
server->machine.seminfo_offset = result;
server->machine->seminfo_offset = result;
server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
}
@@ -63,7 +63,7 @@ glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
memset (buf, 0, sizeof (glibtop_sem_limits));
result = _glibtop_get_kmem_info(server, server->machine.seminfo_offset,
result = _glibtop_get_kmem_info(server, server->machine->seminfo_offset,
&seminfo, sizeof(seminfo));
if (result <= 0)

View File

@@ -44,7 +44,7 @@ _glibtop_init_shm_limits_p (glibtop *server)
return;
}
server->machine.shminfo_offset = result;
server->machine->shminfo_offset = result;
server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
}
@@ -62,7 +62,7 @@ glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
memset (buf, 0, sizeof (glibtop_shm_limits));
result = _glibtop_get_kmem_info(server, server->machine.shminfo_offset,
result = _glibtop_get_kmem_info(server, server->machine->shminfo_offset,
&shminfo, sizeof(struct shminfo));
if (result <= 0)
{

View File

@@ -68,9 +68,9 @@ _glibtop_get_kmem_info(glibtop* server, off_t offset, void* buf, size_t len)
glibtop_suid_enter(server);
lseek(server->machine.kmem_fd, offset, SEEK_SET);
lseek(server->machine->kmem_fd, offset, SEEK_SET);
result = read(server->machine.kmem_fd, buf, len);
result = read(server->machine->kmem_fd, buf, len);
glibtop_suid_leave(server);
@@ -86,23 +86,23 @@ _glibtop_get_procinfo (glibtop *server, pid_t pid)
/* test if procsinfo already found */
if ((server->machine.last_pinfo.pi_pid == pid) && (!first_time))
if ((server->machine->last_pinfo.pi_pid == pid) && (!first_time))
{
return &server->machine.last_pinfo;
return &server->machine->last_pinfo;
}
/* seek procsinfo if given pid */
first_time = 0;
current = 0;
while ((result = getprocs( &server->machine.last_pinfo
while ((result = getprocs( &server->machine->last_pinfo
, sizeof(struct procsinfo)
, NULL, 0, &current, 1)) == 1)
{
if (pid == server->machine.last_pinfo.pi_pid)
if (pid == server->machine->last_pinfo.pi_pid)
{
return &server->machine.last_pinfo;
return &server->machine->last_pinfo;
}
}
return NULL;

View File

@@ -61,7 +61,7 @@ void
_glibtop_init_cpu_p (glibtop *server)
{
#ifndef KERN_CP_TIME
if (kvm_nlist (server->machine.kd, nlst) < 0) {
if (kvm_nlist (server->machine->kd, nlst) < 0) {
glibtop_warn_io_r (server, "kvm_nlist (cpu)");
return;
}
@@ -100,7 +100,7 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
return;
}
#else
if (kvm_read (server->machine.kd, nlst [0].n_value,
if (kvm_read (server->machine->kd, nlst [0].n_value,
&cpts, sizeof (cpts)) != sizeof (cpts)) {
glibtop_warn_io_r (server, "kvm_read (cp_time)");
return;

View File

@@ -47,8 +47,6 @@
G_BEGIN_DECLS
typedef struct _glibtop_machine glibtop_machine;
struct _glibtop_machine
{
uid_t uid, euid;

View File

@@ -35,11 +35,11 @@ G_BEGIN_DECLS
#define UREADOK(ki) (FORCEUREAD || (KI_PROC(ki)->p_flag & P_INMEM))
static inline void glibtop_suid_enter (glibtop *server) {
setregid (server->machine.gid, server->machine.egid);
setregid (server->machine->gid, server->machine->egid);
};
static inline void glibtop_suid_leave (glibtop *server) {
if (setregid (server->machine.egid, server->machine.gid))
if (setregid (server->machine->egid, server->machine->gid))
_exit (1);
};

View File

@@ -92,7 +92,7 @@ _glibtop_init_mem_p (glibtop *server)
{
register int pagesize;
if (kvm_nlist (server->machine.kd, nlst) < 0) {
if (kvm_nlist (server->machine->kd, nlst) < 0) {
glibtop_warn_io_r (server, "kvm_nlist (mem)");
return;
}
@@ -154,14 +154,14 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
}
#else
/* Get the data from kvm_* */
if (kvm_read (server->machine.kd, nlst[1].n_value,
if (kvm_read (server->machine->kd, nlst[1].n_value,
&vmm, sizeof (vmm)) != sizeof (vmm)) {
glibtop_warn_io_r (server, "kvm_read (cnt)");
return;
}
#endif
if (kvm_read (server->machine.kd, nlst[0].n_value,
if (kvm_read (server->machine->kd, nlst[0].n_value,
&bufspace, sizeof (bufspace)) != sizeof (bufspace)) {
glibtop_warn_io_r (server, "kvm_read (bufspace)");
return;

View File

@@ -75,12 +75,12 @@ static struct nlist nlst [] = {
void
_glibtop_init_msg_limits_p (glibtop *server)
{
if (kvm_nlist (server->machine.kd, nlst) < 0) {
if (kvm_nlist (server->machine->kd, nlst) < 0) {
glibtop_warn_io_r (server, "kvm_nlist (msg_limits)");
return;
}
if (kvm_read (server->machine.kd, nlst [0].n_value,
if (kvm_read (server->machine->kd, nlst [0].n_value,
&_msginfo, sizeof (_msginfo)) != sizeof (_msginfo)) {
glibtop_warn_io_r (server, "kvm_read (msginfo)");
return;

View File

@@ -72,7 +72,7 @@ _glibtop_init_netload_p (glibtop *server)
{
server->sysdeps.netload = _glibtop_sysdeps_netload;
if (kvm_nlist (server->machine.kd, nlst) < 0)
if (kvm_nlist (server->machine->kd, nlst) < 0)
glibtop_error_io_r (server, "kvm_nlist");
}
@@ -99,7 +99,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
memset (buf, 0, sizeof (glibtop_netload));
if (kvm_read (server->machine.kd, nlst [0].n_value,
if (kvm_read (server->machine->kd, nlst [0].n_value,
&ifnetaddr, sizeof (ifnetaddr)) != sizeof (ifnetaddr))
glibtop_error_io_r (server, "kvm_read (ifnet)");
@@ -111,12 +111,12 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
{
ifnetfound = ifnetaddr;
if (kvm_read (server->machine.kd, ifnetaddr, &ifnet,
if (kvm_read (server->machine->kd, ifnetaddr, &ifnet,
sizeof (ifnet)) != sizeof (ifnet))
glibtop_error_io_r (server, "kvm_read (ifnetaddr)");
#if (defined(__FreeBSD__) && (__FreeBSD_version < 501113)) || defined(__bsdi__)
if (kvm_read (server->machine.kd, (u_long) ifnet.if_name,
if (kvm_read (server->machine->kd, (u_long) ifnet.if_name,
tname, 16) != 16)
glibtop_error_io_r (server, "kvm_read (if_name)");
tname[15] = '\0';
@@ -202,7 +202,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
buf->flags = _glibtop_sysdeps_netload;
while (ifaddraddr) {
if ((kvm_read (server->machine.kd, ifaddraddr, &ifaddr,
if ((kvm_read (server->machine->kd, ifaddraddr, &ifaddr,
sizeof (ifaddr)) != sizeof (ifaddr)))
glibtop_error_io_r (server, "kvm_read (ifaddraddr)");

View File

@@ -58,27 +58,27 @@ glibtop_open_p (glibtop *server, const char *program_name,
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
server->machine.uid = getuid ();
server->machine.euid = geteuid ();
server->machine.gid = getgid ();
server->machine.egid = getegid ();
server->machine->uid = getuid ();
server->machine->euid = geteuid ();
server->machine->gid = getgid ();
server->machine->egid = getegid ();
#ifdef __FreeBSD__
server->os_version_code = __FreeBSD_version;
#endif
/* Setup machine-specific data */
server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "kvm_open");
server->machine->kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "kvm_open");
if (server->machine.kd == NULL)
if (server->machine->kd == NULL)
glibtop_error_io_r (server, "kvm_open");
/* Drop priviledges. */
if (setreuid (server->machine.euid, server->machine.uid))
if (setreuid (server->machine->euid, server->machine->uid))
_exit (1);
if (setregid (server->machine.egid, server->machine.gid))
if (setregid (server->machine->egid, server->machine->gid))
_exit (1);
/* !!! END OF SUID ROOT PART !!! */

View File

@@ -81,7 +81,7 @@ _glibtop_init_ppp_p (glibtop *server)
#endif
#endif /* HAVE_I4B */
if (kvm_nlist (server->machine.kd, nlst) < 0)
if (kvm_nlist (server->machine->kd, nlst) < 0)
glibtop_error_io_r (server, "kvm_nlist");
}
@@ -102,7 +102,7 @@ glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device)
memset (buf, 0, sizeof (glibtop_ppp));
if (kvm_read (server->machine.kd, nlst [0].n_value,
if (kvm_read (server->machine->kd, nlst [0].n_value,
&data, sizeof (data)) != sizeof (data))
glibtop_error_io_r (server, "kvm_read (i4bisppp_softc)");

View File

@@ -72,14 +72,14 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
glibtop_suid_enter (server);
/* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count < 1)) {
glibtop_suid_leave (server);
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return NULL;
}
args = kvm_getargv (server->machine.kd, pinfo, max_len);
args = kvm_getargv (server->machine->kd, pinfo, max_len);
if (args == NULL) {
glibtop_suid_leave (server);
glibtop_warn_io_r (server, "kvm_getargv (%d)", pid);

View File

@@ -113,7 +113,7 @@ glibtop_get_proc_kernel_p (glibtop *server,
if (pid == 0) return;
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;
@@ -170,11 +170,11 @@ glibtop_get_proc_kernel_p (glibtop *server,
/* On NetBSD, there is no kvm_uread(), and kvm_read() always reads
* from kernel memory. */
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
#else
if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
kvm_uread (server->machine->kd, &(pinfo [0]).kp_proc,
#endif
(unsigned long) &u_addr->u_stats,
(char *) &pstats, sizeof (pstats)) == sizeof (pstats))
@@ -195,10 +195,10 @@ glibtop_get_proc_kernel_p (glibtop *server,
}
#ifdef __NetBSD__
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
#else
if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
kvm_uread (server->machine->kd, &(pinfo [0]).kp_proc,
#endif
(unsigned long) &u_addr->u_pcb,
(char *) &pcb, sizeof (pcb)) == sizeof (pcb))

View File

@@ -72,7 +72,7 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
which = (int)(real_which & GLIBTOP_KERN_PROC_MASK);
/* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, which, arg, &count);
pinfo = kvm_getprocs (server->machine->kd, which, arg, &count);
if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (proclist)");
return NULL;

View File

@@ -128,7 +128,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
glibtop_suid_enter (server);
/* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return (glibtop_map_entry*) g_array_free(maps, TRUE);
@@ -136,7 +136,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
/* Now we get the memory maps. */
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
#if (defined(__FreeBSD__) && (__FreeBSD_version >= 500013)) || defined(__FreeBSD_kernel__)
(unsigned long) pinfo [0].ki_vmspace,
#else
@@ -147,7 +147,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
first = vmspace.vm_map.header.next;
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) vmspace.vm_map.header.next,
(char *) &entry, sizeof (entry)) != sizeof (entry))
glibtop_error_io_r (server, "kvm_read (entry)");
@@ -173,7 +173,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
guint len;
if (update) {
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) entry.next,
&entry, sizeof (entry)) != sizeof (entry))
glibtop_error_io_r (server, "kvm_read (entry)");
@@ -206,7 +206,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
/* We're only interested in vnodes */
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) entry.object.uvm_obj,
&vnode, sizeof (vnode)) != sizeof (vnode)) {
glibtop_warn_io_r (server, "kvm_read (vnode)");
@@ -218,7 +218,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
/* We're only interested in `vm_object's */
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) entry.object.vm_object,
&object, sizeof (object)) != sizeof (object))
glibtop_error_io_r (server, "kvm_read (object)");
@@ -232,7 +232,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
!vnode.v_data) continue;
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) vnode.v_data,
&inode, sizeof (inode)) != sizeof (inode))
glibtop_error_io_r (server, "kvm_read (inode)");
@@ -251,7 +251,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
if (!object.handle)
continue;
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) object.handle,
&vnode, sizeof (vnode)) != sizeof (vnode))
glibtop_error_io_r (server, "kvm_read (vnode)");
@@ -270,7 +270,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
!vnode.v_data) continue;
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) vnode.v_data,
&inode, sizeof (inode)) != sizeof (inode))
glibtop_error_io_r (server, "kvm_read (inode)");

View File

@@ -140,7 +140,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
if (pid == 0) return;
/* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;
@@ -161,7 +161,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
#define PROC_VMSPACE kp_proc.p_vmspace
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) pinfo [0].PROC_VMSPACE,
(char *) &plimit, sizeof (plimit)) != sizeof (plimit)) {
glibtop_warn_io_r (server, "kvm_read (plimit)");
@@ -182,7 +182,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
/* Now we get the shared memory. */
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) pinfo [0].PROC_VMSPACE,
(char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) {
glibtop_warn_io_r (server, "kvm_read (vmspace)");
@@ -191,7 +191,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
first = vmspace.vm_map.header.next;
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) vmspace.vm_map.header.next,
(char *) &entry, sizeof (entry)) != sizeof (entry)) {
glibtop_warn_io_r (server, "kvm_read (entry)");
@@ -205,7 +205,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
* to OBJT_DEFAULT so if seems this really works. */
while (entry.next != first) {
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) entry.next,
&entry, sizeof (entry)) != sizeof (entry)) {
glibtop_warn_io_r (server, "kvm_read (entry)");
@@ -236,7 +236,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
/* We're only interested in vnodes */
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) entry.object.uvm_obj,
&vnode, sizeof (vnode)) != sizeof (vnode)) {
glibtop_warn_io_r (server, "kvm_read (vnode)");
@@ -248,7 +248,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
/* We're only interested in `vm_object's */
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) entry.object.vm_object,
&object, sizeof (object)) != sizeof (object)) {
glibtop_warn_io_r (server, "kvm_read (object)");

View File

@@ -53,7 +53,7 @@ glibtop_get_proc_segment_p (glibtop *server,
#if 0
/* Get the process info from the kernel */
kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, count);
kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, count);
if (*count != 1) {
return; /* the zeroed-out buffer indicating no data */
}

View File

@@ -62,7 +62,7 @@ glibtop_get_proc_signal_p (glibtop *server,
if (pid == 0) return;
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;

View File

@@ -65,7 +65,7 @@ glibtop_get_proc_state_p (glibtop *server,
if (pid == 0) return;
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;

View File

@@ -136,7 +136,7 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
#endif
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;
@@ -156,7 +156,7 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
#if (defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)) || (defined(OpenBSD) && (OpenBSD >= 199912))
glibtop_suid_enter (server);
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) pinfo [0].kp_proc.p_stats,
&pstats, sizeof (pstats)) != sizeof (pstats)) {
glibtop_warn_io_r (server, "kvm_read (pstats)");
@@ -202,7 +202,7 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
#elif (__FreeBSD_version <= 500013)
if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
kvm_uread (server->machine->kd, &(pinfo [0]).kp_proc,
(unsigned long) &u_addr->u_stats,
(char *) &pstats, sizeof (pstats)) == sizeof (pstats))
{
@@ -218,7 +218,7 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
#else
if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
kvm_uread (server->machine->kd, &(pinfo [0]).kp_proc,
(unsigned long) &u_addr->u_stats,
(char *) &pstats, sizeof (pstats)) == sizeof (pstats))
{

View File

@@ -69,7 +69,7 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
if (pid == 0) return;
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;
@@ -128,7 +128,7 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
ucred_ptr = (void *) pinfo [0].kp_eproc.e_pcred.pc_ucred;
if (ucred_ptr) {
if (kvm_read (server->machine.kd, (unsigned long) ucred_ptr,
if (kvm_read (server->machine->kd, (unsigned long) ucred_ptr,
&ucred, sizeof (ucred)) != sizeof (ucred)) {
glibtop_warn_io_r (server, "kvm_read (ucred)");
} else {

View File

@@ -77,12 +77,12 @@ static struct nlist nlst [] = {
void
_glibtop_init_sem_limits_p (glibtop *server)
{
if (kvm_nlist (server->machine.kd, nlst) < 0) {
if (kvm_nlist (server->machine->kd, nlst) < 0) {
glibtop_warn_io_r (server, "kvm_nlist (sem_limits)");
return;
}
if (kvm_read (server->machine.kd, nlst [0].n_value,
if (kvm_read (server->machine->kd, nlst [0].n_value,
&_seminfo, sizeof (_seminfo)) != sizeof (_seminfo)) {
glibtop_warn_io_r (server, "kvm_read (seminfo)");
return;

View File

@@ -75,12 +75,12 @@ static struct nlist nlst [] = {
void
_glibtop_init_shm_limits_p (glibtop *server)
{
if (kvm_nlist (server->machine.kd, nlst) < 0) {
if (kvm_nlist (server->machine->kd, nlst) < 0) {
glibtop_warn_io_r (server, "kvm_nlist (shm_limits)");
return;
}
if (kvm_read (server->machine.kd, nlst [0].n_value,
if (kvm_read (server->machine->kd, nlst [0].n_value,
&_shminfo, sizeof (_shminfo)) != sizeof (_shminfo)) {
glibtop_warn_io_r (server, "kvm_read (shminfo)");
return;

View File

@@ -94,14 +94,14 @@ _glibtop_init_swap_p (glibtop *server)
{
#if defined(__FreeBSD__) || defined(__bsdi__) || defined(__FreeBSD_kernel__)
#if __FreeBSD__ < 4 || defined(__bsdi__)
if (kvm_nlist (server->machine.kd, nlst) < 0) {
if (kvm_nlist (server->machine->kd, nlst) < 0) {
glibtop_warn_io_r (server, "kvm_nlist (swap)");
return;
}
#else
struct kvm_swap dummy;
if (kvm_getswapinfo (server->machine.kd, &dummy, 1, 0) != 0) {
if (kvm_getswapinfo (server->machine->kd, &dummy, 1, 0) != 0) {
glibtop_warn_io_r (server, "kvm_swap (swap)");
return;
}
@@ -109,7 +109,7 @@ _glibtop_init_swap_p (glibtop *server)
#endif
#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)) && !defined(__OpenBSD__)
if (kvm_nlist (server->machine.kd, nlst2) < 0) {
if (kvm_nlist (server->machine->kd, nlst2) < 0) {
glibtop_warn_io_r (server, "kvm_nlist (cnt)");
return;
}
@@ -181,7 +181,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
#else
/* This is used to get the `pagein' and `pageout' members. */
if (kvm_read (server->machine.kd, nlst2[0].n_value,
if (kvm_read (server->machine->kd, nlst2[0].n_value,
&vmm, sizeof (vmm)) != sizeof (vmm)) {
glibtop_warn_io_r (server, "kvm_read (cnt)");
return;
@@ -228,7 +228,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
/* Size of largest swap device. */
if (kvm_read (server->machine.kd, nlst[VM_NSWAP].n_value,
if (kvm_read (server->machine->kd, nlst[VM_NSWAP].n_value,
&nswap, sizeof (nswap)) != sizeof (nswap)) {
glibtop_warn_io_r (server, "kvm_read (nswap)");
return;
@@ -236,7 +236,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
/* Number of swap devices. */
if (kvm_read (server->machine.kd, nlst[VM_NSWDEV].n_value,
if (kvm_read (server->machine->kd, nlst[VM_NSWDEV].n_value,
&nswdev, sizeof (nswdev)) != sizeof (nswdev)) {
glibtop_warn_io_r (server, "kvm_read (nswdev)");
return;
@@ -244,7 +244,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
/* Maximum size of a swap block. */
if (kvm_read (server->machine.kd, nlst[VM_DMMAX].n_value,
if (kvm_read (server->machine->kd, nlst[VM_DMMAX].n_value,
&dmmax, sizeof (dmmax)) != sizeof (dmmax)) {
glibtop_warn_io_r (server, "kvm_read (dmmax)");
return;
@@ -252,7 +252,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
/* List of free swap areas. */
if (kvm_read (server->machine.kd, nlst[VM_SWAPLIST].n_value,
if (kvm_read (server->machine->kd, nlst[VM_SWAPLIST].n_value,
&swaplist, sizeof (swaplist)) != sizeof (swaplist)) {
glibtop_warn_io_r (server, "kvm_read (swaplist)");
return;
@@ -260,7 +260,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
/* Kernel offset of list of swap devices and sizes. */
if (kvm_read (server->machine.kd, nlst[VM_SWDEVT].n_value,
if (kvm_read (server->machine->kd, nlst[VM_SWDEVT].n_value,
&ptr, sizeof (ptr)) != sizeof (ptr)) {
glibtop_warn_io_r (server, "kvm_read (swdevt)");
return;
@@ -271,7 +271,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
sw_size = nswdev * sizeof (*sw);
sw = g_malloc (sw_size);
if (kvm_read (server->machine.kd, ptr, sw, sw_size) != (ssize_t)sw_size) {
if (kvm_read (server->machine->kd, ptr, sw, sw_size) != (ssize_t)sw_size) {
glibtop_warn_io_r (server, "kvm_read (*swdevt)");
return;
}
@@ -288,7 +288,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
while (swapptr) {
int top, bottom, next_block;
if (kvm_read (server->machine.kd, (int) swapptr, &head,
if (kvm_read (server->machine->kd, (int) swapptr, &head,
sizeof (struct rlist)) != sizeof (struct rlist)) {
glibtop_warn_io_r (server, "kvm_read (swapptr)");
return;
@@ -365,7 +365,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
#else
nswdev = kvm_getswapinfo(server->machine.kd, kvmsw, 16, 0);
nswdev = kvm_getswapinfo(server->machine->kd, kvmsw, 16, 0);
buf->flags = _glibtop_sysdeps_swap;
@@ -380,7 +380,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
/* General info about swap devices. */
if (kvm_read (server->machine.kd, nlst[0].n_value,
if (kvm_read (server->machine->kd, nlst[0].n_value,
&swap, sizeof (swap)) != sizeof (swap)) {
glibtop_warn_io_r (server, "kvm_read (swap)");
return;

View File

@@ -28,8 +28,6 @@
G_BEGIN_DECLS
typedef struct _glibtop_machine glibtop_machine;
struct _glibtop_machine
{
pid_t last_pid;

View File

@@ -22,8 +22,6 @@
G_BEGIN_DECLS
typedef struct _glibtop_machine glibtop_machine;
struct _glibtop_machine
{
uid_t uid, euid; /* Real and effective user id */

View File

@@ -22,12 +22,14 @@
G_BEGIN_DECLS
#include <glibtop_machine.h>
static inline void glibtop_suid_enter (glibtop *server) {
setreuid (server->machine.uid, server->machine.euid);
setreuid (server->machine->uid, server->machine->euid);
};
static inline void glibtop_suid_leave (glibtop *server) {
if (setreuid (server->machine.euid, server->machine.uid))
if (setreuid (server->machine->euid, server->machine->uid))
_exit (1);
};

View File

@@ -23,6 +23,8 @@
#include <glibtop/cpu.h>
#include <glibtop/open.h>
#include <glibtop_machine.h>
#include <mach/mach_host.h>
#include <mach/mach_init.h>
#include <mach/mach_interface.h>
@@ -67,17 +69,17 @@ glibtop_open_p (glibtop *server, const char *program_name,
server->name = program_name;
server->machine.uid = getuid ();
server->machine.euid = geteuid ();
server->machine.gid = getgid ();
server->machine.egid = getegid ();
server->machine->uid = getuid ();
server->machine->euid = geteuid ();
server->machine->gid = getgid ();
server->machine->egid = getegid ();
/* Drop priviledges. */
if (setreuid (server->machine.euid, server->machine.uid))
if (setreuid (server->machine->euid, server->machine->uid))
_exit (1);
if (setregid (server->machine.egid, server->machine.gid))
if (setregid (server->machine->egid, server->machine->gid))
_exit (1);
/* !!! END OF SUID ROOT PART !!! */

View File

@@ -59,8 +59,6 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
size_t length;
int ncpu, i;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
memset (buf, 0, sizeof (glibtop_cpu));
length = sizeof (cpts);

View File

@@ -142,8 +142,6 @@ glibtop_get_fsusage_s(glibtop *server, glibtop_fsusage *buf, const char *path)
{
struct statvfs fsd;
glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_fsusage));
if (statvfs (path, &fsd) < 0)

View File

@@ -38,8 +38,6 @@
G_BEGIN_DECLS
typedef struct _glibtop_machine glibtop_machine;
struct _glibtop_machine
{
uid_t uid, euid;

View File

@@ -28,6 +28,8 @@ G_BEGIN_DECLS
#include <sys/param.h>
#endif
#include <glibtop_machine.h>
#define KI_PROC(ki) (&(ki))->kp_proc)
#define KI_EPROC(ki) (&(ki))->kp_eproc)
@@ -35,12 +37,16 @@ G_BEGIN_DECLS
#define UREADOK(ki) (FORCEUREAD || (KI_PROC(ki)->p_flag & P_INMEM))
static inline void glibtop_suid_enter (glibtop *server) {
setregid (server->machine.gid, server->machine.egid);
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
setregid (server->machine->gid, server->machine->egid);
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
};
static inline void glibtop_suid_leave (glibtop *server) {
if (setregid (server->machine.egid, server->machine.gid))
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
if (setregid (server->machine->egid, server->machine->gid))
_exit (1);
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
};
void

View File

@@ -51,8 +51,6 @@ glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
pid_t last_pid;
size_t len;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_LOADAVG, 0);
memset (buf, 0, sizeof (glibtop_loadavg));
if (getloadavg (buf->loadavg, G_N_ELEMENTS(buf->loadavg)) == -1)

View File

@@ -76,8 +76,6 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
gulong membuffer;
gulong memfree;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
memset (buf, 0, sizeof *buf);
memtotal = mem_get_by_bytes (server, "hw.physmem");

View File

@@ -126,8 +126,6 @@ glibtop_get_mountlist_s (glibtop *server, glibtop_mountlist *buf, int all_fs)
GArray *mount_array = g_array_new(FALSE, FALSE,
sizeof(glibtop_mountentry));
glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_mountlist));
/* Read filesystem list. */

View File

@@ -48,8 +48,6 @@ glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
size_t len;
int msgmax, msgmni, msgmnb, msgtql, msgssz, msgseg;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0);
memset (buf, 0, sizeof (glibtop_msg_limits));
if (server->sysdeps.msg_limits == 0)

View File

@@ -41,8 +41,6 @@ glibtop_get_netlist_s (glibtop *server, glibtop_netlist *buf)
struct if_nameindex *ifstart, *ifs;
GPtrArray *devices;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_NETLIST, 0);
memset (buf, 0, sizeof (glibtop_netlist));
ifs = ifstart = if_nameindex();

View File

@@ -77,7 +77,7 @@ static struct nlist nlst [] =
void
_glibtop_init_netload_p (glibtop *server)
{
if (kvm_nlist (server->machine.kd, nlst) < 0) {
if (kvm_nlist (server->machine->kd, nlst) < 0) {
glibtop_warn_io_r (server, "kvm_nlist");
return;
}
@@ -100,13 +100,11 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
struct in_ifaddr in;
} ifaddr;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_NETLOAD), 0);
memset (buf, 0, sizeof (glibtop_netload));
if (server->sysdeps.netload == 0) return;
if (kvm_read (server->machine.kd, nlst [0].n_value,
if (kvm_read (server->machine->kd, nlst [0].n_value,
&ifnetaddr, sizeof (ifnetaddr)) != sizeof (ifnetaddr)) {
glibtop_warn_io_r (server, "kvm_read (ifnet)");
return;
@@ -118,7 +116,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
register char *cp;
u_long ifaddraddr;
if (kvm_read (server->machine.kd, ifnetaddr, &ifnet,
if (kvm_read (server->machine->kd, ifnetaddr, &ifnet,
sizeof (ifnet)) != sizeof (ifnet)) {
glibtop_warn_io_r (server,
"kvm_read (ifnetaddr)");
@@ -185,7 +183,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
buf->flags = _glibtop_sysdeps_netload;
for (ifaddraddr = (u_long) ifnet.if_addrhead.tqh_first; ifaddraddr; ifaddraddr = (u_long) ifaddr.ifa.ifa_link.tqe_next) {
if ((kvm_read (server->machine.kd, ifaddraddr, &ifaddr,
if ((kvm_read (server->machine->kd, ifaddraddr, &ifaddr,
sizeof (ifaddr)) != sizeof (ifaddr))) {
glibtop_warn_io_r (server,
"kvm_read (ifaddraddr)");

View File

@@ -77,7 +77,7 @@ _glibtop_init_ppp_p (glibtop *server)
#endif
#endif /* HAVE_I4B */
if (kvm_nlist (server->machine.kd, nlst) < 0) {
if (kvm_nlist (server->machine->kd, nlst) < 0) {
glibtop_warn_io_r (server, "kvm_nlist");
server->sysdeps.ppp = 0;
}
@@ -96,13 +96,11 @@ glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device)
#endif
int phase;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PPP), 0);
memset (buf, 0, sizeof (glibtop_ppp));
if (server->sysdeps.ppp == 0) return;
if (kvm_read (server->machine.kd, nlst [0].n_value,
if (kvm_read (server->machine->kd, nlst [0].n_value,
&data, sizeof (data)) != sizeof (data)) {
glibtop_warn_io_r (server, "kvm_read (i4bisppp_softc)");
return;

View File

@@ -52,8 +52,6 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
size_t size = 0, pos = 0;
int count;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_ARGS), 0);
memset (buf, 0, sizeof (glibtop_proc_args));
/* swapper, init, pagedaemon, vmdaemon, update - this doen't work. */
@@ -62,14 +60,14 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
glibtop_suid_enter (server);
/* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
glibtop_suid_leave (server);
return NULL;
}
args = kvm_getargv (server->machine.kd, pinfo, max_len);
args = kvm_getargv (server->machine->kd, pinfo, max_len);
if (args == NULL) {
glibtop_warn_io_r (server, "kvm_getargv (%d)", pid);
glibtop_suid_leave (server);

View File

@@ -69,8 +69,6 @@ glibtop_get_proc_kernel_p (glibtop *server,
struct kinfo_proc *pinfo;
int count;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
memset (buf, 0, sizeof (glibtop_proc_kernel));
if (server->sysdeps.proc_time == 0)
@@ -82,7 +80,7 @@ glibtop_get_proc_kernel_p (glibtop *server,
glibtop_suid_enter (server);
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
glibtop_suid_leave (server);

View File

@@ -72,8 +72,6 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
unsigned int i;
pid_t prev;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0);
memset (buf, 0, sizeof (glibtop_proclist));
if (sysctlbyname ("kern.proc.all", NULL, &len, NULL, 0)) {
@@ -145,6 +143,9 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
glibtop_get_proc_state_p (server, &procstate, pid);
if (procstate.flags & (1L << GLIBTOP_PROC_STATE_STATE))
if (procstate.state != GLIBTOP_PROCESS_RUNNING) continue;
if (pinfo[i].ki_ppid == 0 && !strcmp(pinfo[i].ki_comm, "idle"))
continue;
}
if (which & GLIBTOP_EXCLUDE_SYSTEM)

View File

@@ -91,9 +91,9 @@ _glibtop_sysdeps_freebsd_dev_inode (glibtop *server, struct vnode *vnode,
*inum = 0;
*dev = 0;
if (kvm_read (server->machine.kd, (gulong) &vnode->v_tag,
if (kvm_read (server->machine->kd, (gulong) &vnode->v_tag,
(char *) &tagptr, sizeof (tagptr)) != sizeof (tagptr) ||
kvm_read (server->machine.kd, (gulong) tagptr,
kvm_read (server->machine->kd, (gulong) tagptr,
(char *) tagstr, sizeof (tagstr)) != sizeof (tagstr))
{
glibtop_warn_io_r (server, "kvm_read (tagptr)");
@@ -111,7 +111,7 @@ _glibtop_sysdeps_freebsd_dev_inode (glibtop *server, struct vnode *vnode,
return;
}
if (kvm_read (server->machine.kd, (gulong) VTOI(vn), (char *) &inode,
if (kvm_read (server->machine->kd, (gulong) VTOI(vn), (char *) &inode,
sizeof (inode)) != sizeof (inode))
{
glibtop_warn_io_r (server, "kvm_read (inode)");
@@ -151,7 +151,7 @@ _glibtop_sysdeps_freebsd_dev_inode (glibtop *server, struct vnode *vnode,
struct my_zfsvfs zvfs;
if (kvm_read(server->machine.kd,
if (kvm_read(server->machine->kd,
(unsigned long)(znode->z_zfsvfs),
&zvfs, sizeof zvfs) != sizeof zvfs) {
glibtop_warn_io_r(server, "kvm_read (z_zfsvfs)");
@@ -167,12 +167,12 @@ _glibtop_sysdeps_freebsd_dev_inode (glibtop *server, struct vnode *vnode,
#if (__FreeBSD_version >= 800039) || (__FreeBSD_kernel_version >= 800039)
if (kvm_read (server->machine.kd, (gulong) cdev2priv(inode.i_dev), (char *) &priv,
if (kvm_read (server->machine->kd, (gulong) cdev2priv(inode.i_dev), (char *) &priv,
sizeof (priv))
#else
if (kvm_read (server->machine.kd, (gulong) inode.i_dev, (char *) &si,
if (kvm_read (server->machine->kd, (gulong) inode.i_dev, (char *) &si,
sizeof (si)) != sizeof (si) ||
kvm_read (server->machine.kd, (gulong) si.si_priv, (char *) &priv,
kvm_read (server->machine->kd, (gulong) si.si_priv, (char *) &priv,
sizeof (priv))
#endif
!= sizeof (priv))
@@ -209,8 +209,6 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
int count;
int update = 0;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MAP), 0);
memset (buf, 0, sizeof (glibtop_proc_map));
/* It does not work for the swapper task. */
@@ -221,7 +219,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
glibtop_suid_enter (server);
/* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
glibtop_suid_leave (server);
@@ -230,7 +228,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
/* Now we get the memory maps. */
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(gulong) pinfo [0].ki_vmspace,
(char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) {
glibtop_warn_io_r (server, "kvm_read (vmspace)");
@@ -240,7 +238,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
first = vmspace.vm_map.header.next;
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(gulong) vmspace.vm_map.header.next,
(char *) &entry, sizeof (entry)) != sizeof (entry)) {
glibtop_warn_io_r (server, "kvm_read (entry)");
@@ -263,7 +261,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
guint len;
if (update) {
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(gulong) entry.next,
(char *) &entry, sizeof (entry)) != sizeof (entry)) {
glibtop_warn_io_r (server, "kvm_read (entry)");
@@ -281,7 +279,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
/* We're only interested in `vm_object's */
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(gulong) entry.object.vm_object,
(char *) &object, sizeof (object)) != sizeof (object)) {
glibtop_warn_io_r (server, "kvm_read (object)");
@@ -296,7 +294,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
if (!object.handle)
continue;
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(gulong) object.handle,
(char *) &vnode, sizeof (vnode)) != sizeof (vnode)) {
glibtop_warn_io_r (server, "kvm_read (vnode)");

View File

@@ -75,8 +75,6 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
struct vm_object object;
int count;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MEM), 0);
memset (buf, 0, sizeof (glibtop_proc_mem));
if (server->sysdeps.proc_mem == 0)
@@ -86,7 +84,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
if (pid == 0) return;
/* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;
@@ -110,7 +108,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
/* Now we get the shared memory. */
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) pinfo [0].PROC_VMSPACE,
(char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) {
glibtop_warn_io_r (server, "kvm_read (vmspace)");
@@ -119,7 +117,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
first = vmspace.vm_map.header.next;
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) vmspace.vm_map.header.next,
(char *) &entry, sizeof (entry)) != sizeof (entry)) {
glibtop_warn_io_r (server, "kvm_read (entry)");
@@ -133,7 +131,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
* to OBJT_DEFAULT so if seems this really works. */
while (entry.next != first) {
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) entry.next,
(char *) &entry, sizeof (entry)) != sizeof (entry)) {
glibtop_warn_io_r (server, "kvm_read (entry)");
@@ -148,7 +146,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
/* We're only interested in `vm_object's */
if (kvm_read (server->machine.kd,
if (kvm_read (server->machine->kd,
(unsigned long) entry.object.vm_object,
(char *) &object, sizeof (object)) != sizeof (object)) {
glibtop_warn_io_r (server, "kvm_read (object)");

View File

@@ -55,15 +55,13 @@ glibtop_get_proc_segment_p (glibtop *server,
struct kinfo_proc *pinfo;
int count = 0;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
memset (buf, 0, sizeof (glibtop_proc_segment));
/* It does not work for the swapper task. */
if (pid == 0) return;
/* Get the process info from the kernel */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;

View File

@@ -52,15 +52,13 @@ glibtop_get_proc_signal_p (glibtop *server,
struct kinfo_proc *pinfo;
int count = 0;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
memset (buf, 0, sizeof (glibtop_proc_signal));
/* It does not work for the swapper task. */
if (pid == 0) return;
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;

View File

@@ -50,12 +50,10 @@ glibtop_get_proc_state_p (glibtop *server,
struct kinfo_proc *pinfo;
int count = 0;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_STATE), 0);
memset (buf, 0, sizeof (glibtop_proc_state));
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;

View File

@@ -66,8 +66,6 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
int count;
size_t len;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0);
memset (buf, 0, sizeof (glibtop_proc_time));
/* It does not work for the swapper task. */
@@ -76,7 +74,7 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
glibtop_suid_enter (server);
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
glibtop_suid_leave (server);

View File

@@ -50,15 +50,13 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
struct kinfo_proc *pinfo;
int count = 0;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_UID), 0);
memset (buf, 0, sizeof (glibtop_proc_uid));
/* It does not work for the swapper task. */
if (pid == 0) return;
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;

View File

@@ -51,8 +51,6 @@ glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
int semmap, semmni, semmns, semmnu, semmsl, semopm, semume, semusz;
int semvmx, semaem;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0);
memset (buf, 0, sizeof (glibtop_sem_limits));
if (server->sysdeps.sem_limits == 0)

View File

@@ -53,8 +53,6 @@ glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
unsigned long shmmax, shmmin, shmmni, shmseg, shmall;
#endif
glibtop_init_s (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0);
memset (buf, 0, sizeof (glibtop_shm_limits));
if (server->sysdeps.shm_limits == 0)

View File

@@ -25,6 +25,7 @@
#include <glibtop/cpu.h>
#include <glibtop/open.h>
#include <glibtop/init_hooks.h>
#include <glibtop/machine.h>
/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
@@ -59,24 +60,28 @@ glibtop_open_p (glibtop *server, const char *program_name,
glibtop_debug ("glibtop_open_p ()");
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
server->machine.uid = getuid ();
server->machine.euid = geteuid ();
server->machine.gid = getgid ();
server->machine.egid = getegid ();
server->machine->uid = getuid ();
server->machine->euid = geteuid ();
server->machine->gid = getgid ();
server->machine->egid = getegid ();
/* Setup machine-specific data */
server->machine.kd = kvm_openfiles (NULL, NULL, NULL, O_RDONLY, errbuf);
server->machine->kd = kvm_openfiles (NULL, NULL, NULL, O_RDONLY, errbuf);
if (server->machine.kd == NULL)
if (server->machine->kd == NULL)
glibtop_error_io_r (server, "kvm_open");
/* Drop priviledges. */
if (setreuid (server->machine.euid, server->machine.uid))
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
if (setreuid (server->machine->euid, server->machine->uid))
_exit (1);
if (setregid (server->machine.egid, server->machine.gid))
if (setregid (server->machine->egid, server->machine->gid))
_exit (1);
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
/* !!! END OF SUID ROOT PART !!! */
/* Our effective uid is now those of the user invoking the server,

View File

@@ -56,12 +56,10 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
int nswdev;
struct kvm_swap kvmsw[16];
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SWAP), 0);
memset (buf, 0, sizeof (glibtop_swap));
memset (kvmsw, 0, sizeof (kvmsw));
nswdev = kvm_getswapinfo (server->machine.kd, kvmsw, 16, 0);
nswdev = kvm_getswapinfo (server->machine->kd, kvmsw, 16, 0);
if (nswdev < 1) return;
buf->flags = _glibtop_sysdeps_swap;

View File

@@ -43,8 +43,6 @@ init_sysinfo (glibtop *server)
if (G_LIKELY (sysinfo.flags))
return;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
ncpus = server->ncpu + 1;
len = 0;

View File

@@ -58,8 +58,6 @@ glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
size_t size;
glibtop_cpu cpu;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_UPTIME, 0);
memset (buf, 0, sizeof (glibtop_uptime));
mib[0] = CTL_KERN;

View File

@@ -194,7 +194,6 @@ glibtop_get_fsusage_s(glibtop *server, glibtop_fsusage *buf, const char *path)
{
struct statvfs fsd;
glibtop_init_r(&server, 0, 0);
memset(buf, 0, sizeof(glibtop_fsusage));
if (statvfs(path, &fsd) < 0) {

View File

@@ -22,21 +22,12 @@
#ifndef __GLIBTOP_MACHINE_H__
#define __GLIBTOP_MACHINE_H__
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
#include <glib.h>
G_BEGIN_DECLS
typedef struct _glibtop_machine glibtop_machine;
struct _glibtop_machine
{
pid_t last_pid;
int no_update;
int fd_stat, fd_meminfo, fd_loadavg;
char proc_stat [BUFSIZ], proc_statm [BUFSIZ];
char proc_status [BUFSIZ];
};
G_END_DECLS

View File

@@ -118,7 +118,6 @@ glibtop_get_mountlist_s(glibtop *server, glibtop_mountlist *buf, int all_fs)
GArray* entries;
IgnoreList* ig = NULL;
glibtop_init_r(&server, 0, 0);
memset(buf, 0, sizeof(glibtop_mountlist));
/* wild guess, preallocate 8 entries

View File

@@ -34,7 +34,7 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
#if !defined (__GLIBC__) || __GNU_LIBRARY__ > 1
/* GNU LibC */
#include <net/if.h>
#include <netinet/ip_icmp.h>
@@ -43,7 +43,7 @@
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <net/if.h>
#else /* Libc 5 */
#elif defined (__GLIBC__) /* Libc 5 */
#include <linux/if.h>
#include <linux/in.h>
#include <linux/ip.h>

View File

@@ -52,6 +52,7 @@ static const unsigned long _glibtop_sysdeps_map_entry =
static const unsigned long _glibtop_sysdeps_map_entry_smaps =
(1UL << GLIBTOP_MAP_ENTRY_SIZE) + (1UL << GLIBTOP_MAP_ENTRY_RSS) +
(1UL << GLIBTOP_MAP_ENTRY_PSS) + (1UL << GLIBTOP_MAP_ENTRY_SWAP) +
(1UL << GLIBTOP_MAP_ENTRY_SHARED_DIRTY) + (1UL << GLIBTOP_MAP_ENTRY_SHARED_CLEAN) +
(1UL << GLIBTOP_MAP_ENTRY_PRIVATE_DIRTY) + (1UL << GLIBTOP_MAP_ENTRY_PRIVATE_CLEAN);
@@ -98,7 +99,7 @@ parse_smaps(glibtop_map_entry *entry, const char* line)
if ((colon = is_smap_value(line)) == NULL)
return FALSE;
len = colon - line + 1;
len = colon - line;
smap = _glibtop_find_smap(line, len);
// g_debug("smap %s -> %p", line, smap);

View File

@@ -1,10 +1,6 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* ANSI-C code produced by gperf version 3.0.3 */
/* Command-line: gperf sysdeps/linux/procmap_smaps.gperf */
/* Computed positions: -k'9' */
/* Computed positions: -k'1,$' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -42,12 +38,13 @@
#line 14 "sysdeps/linux/procmap_smaps.gperf"
struct smap_value { int name; ptrdiff_t offset; };
#include <string.h>
#include <stddef.h>
#define TOTAL_KEYWORDS 6
#define MIN_WORD_LENGTH 4
#define MAX_WORD_LENGTH 14
#define MIN_HASH_VALUE 4
#define MAX_HASH_VALUE 19
#define TOTAL_KEYWORDS 8
#define MIN_WORD_LENGTH 3
#define MAX_WORD_LENGTH 13
#define MIN_HASH_VALUE 3
#define MAX_HASH_VALUE 18
/* maximum key range = 16, duplicates = 0 */
#ifdef __GNUC__
@@ -62,67 +59,57 @@ hash (register const char *str, register unsigned int len)
{
static const unsigned char asso_values[] =
{
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 5, 0, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 5, 20, 20, 0, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
0, 19, 5, 0, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 5, 19, 19, 19, 19, 19, 19, 19, 19,
5, 19, 0, 19, 19, 0, 19, 19, 19, 19,
19, 0, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19
};
register int hval = len;
switch (hval)
{
default:
hval += asso_values[(unsigned char)str[8]];
/*FALLTHROUGH*/
case 8:
case 7:
case 6:
case 5:
case 4:
break;
}
return hval;
return len + asso_values[(unsigned char)str[len - 1]] + asso_values[(unsigned char)str[0]];
}
struct stringpool_t
{
char stringpool_str4[sizeof("Rss:")];
char stringpool_str5[sizeof("Size:")];
char stringpool_str13[sizeof("Shared_Clean:")];
char stringpool_str14[sizeof("Private_Dirty:")];
char stringpool_str18[sizeof("Shared_Dirty:")];
char stringpool_str19[sizeof("Private_Clean:")];
char stringpool_str3[sizeof("Pss")];
char stringpool_str4[sizeof("Swap")];
char stringpool_str8[sizeof("Rss")];
char stringpool_str9[sizeof("Size")];
char stringpool_str12[sizeof("Shared_Dirty")];
char stringpool_str13[sizeof("Private_Dirty")];
char stringpool_str17[sizeof("Shared_Clean")];
char stringpool_str18[sizeof("Private_Clean")];
};
static const struct stringpool_t stringpool_contents =
{
"Rss:",
"Size:",
"Shared_Clean:",
"Private_Dirty:",
"Shared_Dirty:",
"Private_Clean:"
"Pss",
"Swap",
"Rss",
"Size",
"Shared_Dirty",
"Private_Dirty",
"Shared_Clean",
"Private_Clean"
};
#define stringpool ((const char *) &stringpool_contents)
#ifdef __GNUC__
@@ -137,26 +124,31 @@ _glibtop_find_smap (register const char *str, register unsigned int len)
{
static const unsigned char lengthtable[] =
{
0, 0, 0, 0, 4, 5, 0, 0, 0, 0, 0, 0, 0, 13,
14, 0, 0, 0, 13, 14
0, 0, 0, 3, 4, 0, 0, 0, 3, 4, 0, 0, 12, 13,
0, 0, 0, 12, 13
};
static const struct smap_value wordlist[] =
{
{-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1},
#line 18 "sysdeps/linux/procmap_smaps.gperf"
{(int)(long)&((struct stringpool_t *)0)->stringpool_str4, SMAP_OFFSET(rss)},
#line 21 "sysdeps/linux/procmap_smaps.gperf"
{(int)(long)&((struct stringpool_t *)0)->stringpool_str5, SMAP_OFFSET(size)},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{offsetof(struct stringpool_t, stringpool_str3), SMAP_OFFSET(pss)},
#line 23 "sysdeps/linux/procmap_smaps.gperf"
{offsetof(struct stringpool_t, stringpool_str4), SMAP_OFFSET(swap),},
{-1}, {-1}, {-1},
#line 19 "sysdeps/linux/procmap_smaps.gperf"
{(int)(long)&((struct stringpool_t *)0)->stringpool_str13, SMAP_OFFSET(shared_clean)},
{offsetof(struct stringpool_t, stringpool_str8), SMAP_OFFSET(rss)},
#line 22 "sysdeps/linux/procmap_smaps.gperf"
{offsetof(struct stringpool_t, stringpool_str9), SMAP_OFFSET(size)},
{-1}, {-1},
#line 21 "sysdeps/linux/procmap_smaps.gperf"
{offsetof(struct stringpool_t, stringpool_str12), SMAP_OFFSET(shared_dirty)},
#line 17 "sysdeps/linux/procmap_smaps.gperf"
{(int)(long)&((struct stringpool_t *)0)->stringpool_str14, SMAP_OFFSET(private_dirty)},
{offsetof(struct stringpool_t, stringpool_str13), SMAP_OFFSET(private_dirty)},
{-1}, {-1}, {-1},
#line 20 "sysdeps/linux/procmap_smaps.gperf"
{(int)(long)&((struct stringpool_t *)0)->stringpool_str18, SMAP_OFFSET(shared_dirty)},
{offsetof(struct stringpool_t, stringpool_str17), SMAP_OFFSET(shared_clean)},
#line 16 "sysdeps/linux/procmap_smaps.gperf"
{(int)(long)&((struct stringpool_t *)0)->stringpool_str19, SMAP_OFFSET(private_clean)}
{offsetof(struct stringpool_t, stringpool_str18), SMAP_OFFSET(private_clean)}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)

View File

@@ -13,9 +13,11 @@
%}
struct smap_value { int name; ptrdiff_t offset; };
%%
Private_Clean:, SMAP_OFFSET(private_clean)
Private_Dirty:, SMAP_OFFSET(private_dirty)
Rss:, SMAP_OFFSET(rss)
Shared_Clean:, SMAP_OFFSET(shared_clean)
Shared_Dirty:, SMAP_OFFSET(shared_dirty)
Size:, SMAP_OFFSET(size)
Private_Clean, SMAP_OFFSET(private_clean)
Private_Dirty, SMAP_OFFSET(private_dirty)
Pss, SMAP_OFFSET(pss)
Rss, SMAP_OFFSET(rss)
Shared_Clean, SMAP_OFFSET(shared_clean)
Shared_Dirty, SMAP_OFFSET(shared_dirty)
Size, SMAP_OFFSET(size)
Swap, SMAP_OFFSET(swap),

View File

@@ -36,8 +36,6 @@
G_BEGIN_DECLS
typedef struct _glibtop_machine glibtop_machine;
struct _glibtop_machine
{
uid_t uid, euid;

View File

@@ -28,6 +28,8 @@ G_BEGIN_DECLS
#include <sys/param.h>
#endif
#include <glibtop_machine.h>
#define KI_PROC(ki) (&(ki))->kp_proc)
#define KI_EPROC(ki) (&(ki))->kp_eproc)
@@ -35,11 +37,11 @@ G_BEGIN_DECLS
#define UREADOK(ki) (FORCEUREAD || (KI_PROC(ki)->p_flag & P_INMEM))
static inline void glibtop_suid_enter (glibtop *server) {
setregid (server->machine.gid, server->machine.egid);
setregid (server->machine->gid, server->machine->egid);
};
static inline void glibtop_suid_leave (glibtop *server) {
if (setregid (server->machine.egid, server->machine.gid))
if (setregid (server->machine->egid, server->machine->gid))
_exit (1);
};

View File

@@ -58,12 +58,12 @@ static struct nlist nlst [] = {
void
_glibtop_init_msg_limits_p (glibtop *server)
{
if (kvm_nlist (server->machine.kd, nlst) < 0) {
if (kvm_nlist (server->machine->kd, nlst) < 0) {
glibtop_warn_io_r (server, "kvm_nlist (msg_limits)");
return;
}
if (kvm_read (server->machine.kd, nlst [0].n_value,
if (kvm_read (server->machine->kd, nlst [0].n_value,
&_msginfo, sizeof (_msginfo)) != sizeof (_msginfo)) {
glibtop_warn_io_r (server, "kvm_read (msginfo)");
return;

View File

@@ -73,7 +73,7 @@ _glibtop_init_netload_p (glibtop *server)
{
server->sysdeps.netload = _glibtop_sysdeps_netload;
if (kvm_nlist (server->machine.kd, nlst) < 0)
if (kvm_nlist (server->machine->kd, nlst) < 0)
glibtop_error_io_r (server, "kvm_nlist");
}
@@ -97,7 +97,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
memset (buf, 0, sizeof (glibtop_netload));
if (kvm_read (server->machine.kd, nlst [0].n_value,
if (kvm_read (server->machine->kd, nlst [0].n_value,
&ifnetaddr, sizeof (ifnetaddr)) != sizeof (ifnetaddr))
glibtop_error_io_r (server, "kvm_read (ifnet)");
@@ -109,7 +109,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
{
ifnetfound = ifnetaddr;
if (kvm_read (server->machine.kd, ifnetaddr, &ifnet,
if (kvm_read (server->machine->kd, ifnetaddr, &ifnet,
sizeof (ifnet)) != sizeof (ifnet))
glibtop_error_io_r (server, "kvm_read (ifnetaddr)");
@@ -176,7 +176,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
buf->flags = _glibtop_sysdeps_netload;
while (ifaddraddr) {
if ((kvm_read (server->machine.kd, ifaddraddr, &ifaddr,
if ((kvm_read (server->machine->kd, ifaddraddr, &ifaddr,
sizeof (ifaddr)) != sizeof (ifaddr)))
glibtop_error_io_r (server, "kvm_read (ifaddraddr)");

View File

@@ -21,6 +21,7 @@
#include <config.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <glibtop.h>
#include <glibtop/open.h>
#include <glibtop/cpu.h>

View File

@@ -77,7 +77,7 @@ _glibtop_init_ppp_p (glibtop *server)
#endif
#endif /* HAVE_I4B */
if (kvm_nlist (server->machine.kd, nlst) < 0)
if (kvm_nlist (server->machine->kd, nlst) < 0)
glibtop_error_io_r (server, "kvm_nlist");
}
@@ -98,7 +98,7 @@ glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device)
memset (buf, 0, sizeof (glibtop_ppp));
if (kvm_read (server->machine.kd, nlst [0].n_value,
if (kvm_read (server->machine->kd, nlst [0].n_value,
&data, sizeof (data)) != sizeof (data))
glibtop_error_io_r (server, "kvm_read (i4bisppp_softc)");

View File

@@ -56,16 +56,13 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
memset (buf, 0, sizeof (glibtop_proc_args));
/*
* Don't bother with PIDs below 20, because everything below this
* number is highly likely to be a kernel thread.
*/
if (pid < 19) return NULL;
/* Ignore init */
if (pid < 2) return NULL;
glibtop_suid_enter (server);
/* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count);
if (pinfo == NULL) {
glibtop_suid_leave (server);
@@ -73,7 +70,7 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
return NULL;
}
args = kvm_getargv (server->machine.kd, pinfo, max_len);
args = kvm_getargv (server->machine->kd, pinfo, max_len);
if (args == NULL) {
glibtop_suid_leave (server);
glibtop_warn_io_r (server, "kvm_getargv (%d)", pid);

View File

@@ -72,7 +72,7 @@ glibtop_get_proc_kernel_p (glibtop *server,
glibtop_suid_enter (server);
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid,
sizeof(*pinfo), &count);
if (pinfo == NULL) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);

View File

@@ -72,7 +72,7 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
which = (int)(real_which & GLIBTOP_KERN_PROC_MASK);
/* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, which, arg,
pinfo = kvm_getprocs (server->machine->kd, which, arg,
sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (proclist)");

Some files were not shown because too many files have changed in this diff Show More