Compare commits

...

33 Commits

Author SHA1 Message Date
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
136 changed files with 607 additions and 618 deletions

1
.gitignore vendored
View File

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

39
NEWS
View File

@@ -1,3 +1,42 @@
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 5 August 2015: Overview of changes in 2.31.4
============================================= =============================================
* 71 commits ! * 71 commits !

View File

@@ -3,8 +3,8 @@ dnl Configure script for the Gnome library
dnl dnl
m4_define([libgtop_major_version], [2]) m4_define([libgtop_major_version], [2])
m4_define([libgtop_minor_version], [31]) m4_define([libgtop_minor_version], [32])
m4_define([libgtop_micro_version], [4]) m4_define([libgtop_micro_version], [0])
m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version]) m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version])
dnl increment if the interface has additions, changes, removals. 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_LIBS='-L$(libdir)'
LIBGTOP_INCS='-I$(includedir)/libgtop-2.0' 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 if test x$libgtop_have_sysinfo = xyes ; then
LIBGTOP_INCS="$LIBGTOP_INCS -DHAVE_LIBGTOP_SYSINFO" LIBGTOP_INCS="$LIBGTOP_INCS -DHAVE_LIBGTOP_SYSINFO"
fi fi
@@ -307,12 +303,6 @@ LIBGTOP_EXTRA_LIBS="$GLIB_LIBS $LIBGTOP_EXTRA_LIBS"
LIBGTOP_LIBS="$LIBGTOP_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 if test "$GCC" = "yes" ; then
CFLAGS="\ CFLAGS="\
-Winline \ -Winline \

View File

@@ -22,12 +22,17 @@
#ifndef __GLIBTOP_H__ #ifndef __GLIBTOP_H__
#define __GLIBTOP_H__ #define __GLIBTOP_H__
/* for pid_t, uid_t, gid_t */
#include <sys/types.h>
#include <glib.h> #include <glib.h>
#include <glib-object.h> #include <glib-object.h>
G_BEGIN_DECLS G_BEGIN_DECLS
typedef struct _glibtop glibtop; typedef struct _glibtop glibtop;
typedef struct _glibtop_machine glibtop_machine;
/** /**
* LIBGTOP_CHECK_VERSION * LIBGTOP_CHECK_VERSION
@@ -55,10 +60,6 @@ LIBGTOP_MICRO_VERSION >= (micro)))
#include <glibtop_server.h> #include <glibtop_server.h>
#ifdef HAVE_GLIBTOP_MACHINE_H
#include <glibtop_machine.h>
#endif
#ifndef GLIBTOP_MOUNTENTRY_LEN #ifndef GLIBTOP_MOUNTENTRY_LEN
#define GLIBTOP_MOUNTENTRY_LEN 79 #define GLIBTOP_MOUNTENTRY_LEN 79
#endif #endif
@@ -69,34 +70,6 @@ LIBGTOP_MICRO_VERSION >= (micro)))
#include <glibtop/close.h> #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 struct _glibtop
{ {
unsigned flags; unsigned flags;
@@ -118,9 +91,14 @@ struct _glibtop
glibtop_sysdeps sysdeps; /* Detailed feature list */ glibtop_sysdeps sysdeps; /* Detailed feature list */
glibtop_sysdeps required; /* Required feature list */ glibtop_sysdeps required; /* Required feature list */
pid_t pid; /* PID of the server */ 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; 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 \ glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \
sem_limits.h uptime.h command.h mem.h proclist.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 \ procmem.h procuid.h swap.h \
procsegment.h sysdeps.h global.h \ procsegment.h sysdeps.h global.h \
procsignal.h union.h gnuserv.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 \ procwd.h procaffinity.h \
netlist.h procopenfiles.h open.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, ...) \ #define glibtop_debug_r(server, fmt, ...) \
G_STMT_START { \ G_STMT_START { \
if (LIBGTOP_ENABLE_DEBUG) \ 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 } G_STMT_END
#define glibtop_debug(...) glibtop_debug_r(glibtop_global_server, __VA_ARGS__) #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: * glibtop_get_mountlist:
* @buf: (out): * @buf:
* @all_fs: * @all_fs:
* *
* Returns: (transfer full): * 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_NUMBER 0
#define GLIBTOP_PROC_AFFINITY_ALL 1 #define GLIBTOP_PROC_AFFINITY_ALL 1
#define GLIBTOP_MAX_PROC_AFFINITY 2
struct _glibtop_proc_affinity struct _glibtop_proc_affinity
{ {

View File

@@ -79,6 +79,15 @@ char **
glibtop_get_proc_argv_l (glibtop *server, glibtop_proc_args *buf, glibtop_get_proc_argv_l (glibtop *server, glibtop_proc_args *buf,
pid_t pid, unsigned max_len); pid_t pid, unsigned max_len);
/**
* glibtop_get_proc_argv:
* @buf:
* @pid:
* @max_len:
*
* Returns: (transfer full):
*/
char ** char **
glibtop_get_proc_argv (glibtop_proc_args *buf, pid_t pid, unsigned max_len); 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_SHARED_DIRTY 10
#define GLIBTOP_MAP_ENTRY_PRIVATE_CLEAN 11 #define GLIBTOP_MAP_ENTRY_PRIVATE_CLEAN 11
#define GLIBTOP_MAP_ENTRY_PRIVATE_DIRTY 12 #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 #define GLIBTOP_MAP_FILENAME_LEN 215
@@ -78,6 +80,8 @@ struct _glibtop_map_entry
guint64 shared_dirty; guint64 shared_dirty;
guint64 private_clean; guint64 private_clean;
guint64 private_dirty; guint64 private_dirty;
guint64 pss;
guint64 swap;
char filename [GLIBTOP_MAP_FILENAME_LEN+1]; char filename [GLIBTOP_MAP_FILENAME_LEN+1];
}; };
@@ -88,17 +92,18 @@ struct _glibtop_proc_map
guint64 total; /* GLIBTOP_PROC_MAP_TOTAL */ guint64 total; /* GLIBTOP_PROC_MAP_TOTAL */
guint64 size; /* GLIBTOP_PROC_MAP_SIZE */ guint64 size; /* GLIBTOP_PROC_MAP_SIZE */
}; };
glibtop_map_entry *
glibtop_get_proc_map(glibtop_proc_map *buf, pid_t pid);
/** /**
* glibtop_get_proc_map: * glibtop_get_proc_map:
* @buf: (out): * @buf:
* @pid: * @pid:
* *
* Returns: (transfer none): * Returns: (transfer none):
*/ */
glibtop_map_entry *
glibtop_get_proc_map(glibtop_proc_map *buf, pid_t pid);
/** /**
* glibtop_get_proc_map_l: * glibtop_get_proc_map_l:

View File

@@ -53,6 +53,12 @@ struct _glibtop_proc_mem
* of the process; usually 2,147,483,647 */ * 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); void glibtop_get_proc_mem(glibtop_proc_mem *buf, pid_t pid);
#if GLIBTOP_SUID_PROC_MEM #if GLIBTOP_SUID_PROC_MEM

View File

@@ -96,7 +96,7 @@ struct _glibtop_proc_open_files
/** /**
* glibtop_get_proc_open_files: * glibtop_get_proc_open_files:
* @buf: (out): * @buf:
* @pid: * @pid:
* *
* Returns: (transfer none): * 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_NUMBER 0
#define GLIBTOP_PROC_WD_ROOT 1 #define GLIBTOP_PROC_WD_ROOT 1
#define GLIBTOP_PROC_WD_EXE 2 #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_ROOT_LEN 215
#define GLIBTOP_PROC_WD_EXE_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(glibtop_proc_wd *buf, pid_t pid);
char ** glibtop_get_proc_wd_l(glibtop *server, 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 = INTROSPECTION_COMPILER_ARGS =
if HAVE_INTROSPECTION 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/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/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/procmem.h ../include/glibtop/procuid.h ../include/glibtop/swap.h \
../include/glibtop/procsegment.h ../include/glibtop/sysdeps.h ../include/glibtop/global.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 \ ../include/glibtop/procsignal.h ../include/glibtop/union.h ../include/glibtop/gnuserv.h \

View File

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

View File

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

View File

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

View File

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

View File

@@ -56,7 +56,7 @@ _glibtop_init_cpu_p (glibtop *server)
{ {
return; return;
} }
server->machine.sysinfo_offset = result; server->machine->sysinfo_offset = result;
result = _glibtop_get_kmem_offset(server, "cpuinfo"); result = _glibtop_get_kmem_offset(server, "cpuinfo");
if (result == -1) if (result == -1)
@@ -65,9 +65,9 @@ _glibtop_init_cpu_p (glibtop *server)
return; 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; 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)); 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)); &sysinfo, sizeof(struct sysinfo));
if (result <= 0) 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 ; buf->total = buf->idle + buf->user + buf->sys + buf->nice ;
result = _glibtop_get_kmem_info(server, server->machine.cpuinfo_offset, result = _glibtop_get_kmem_info(server, server->machine->cpuinfo_offset,
server->machine.cpuinfo, server->machine->cpuinfo,
_system_configuration.ncpus _system_configuration.ncpus
* sizeof(struct cpuinfo)); * 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++) for (cpu = 0; cpu < MIN(GLIBTOP_NCPU, _system_configuration.ncpus); cpu++)
{ {
buf->xcpu_idle[cpu] = buf->xcpu_idle[cpu] =
server->machine.cpuinfo[cpu].cpu[CPU_IDLE]; server->machine->cpuinfo[cpu].cpu[CPU_IDLE];
buf->xcpu_user[cpu] = buf->xcpu_user[cpu] =
server->machine.cpuinfo[cpu].cpu[CPU_USER]; server->machine->cpuinfo[cpu].cpu[CPU_USER];
buf->xcpu_sys[cpu] = buf->xcpu_sys[cpu] =
server->machine.cpuinfo[cpu].cpu[CPU_KERNEL]; server->machine->cpuinfo[cpu].cpu[CPU_KERNEL];
buf->xcpu_nice[cpu] = 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_total[cpu] = buf->xcpu_idle[cpu] +
buf->xcpu_user[cpu] + buf->xcpu_user[cpu] +

View File

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

View File

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

View File

@@ -44,7 +44,7 @@ _glibtop_init_loadavg_p (glibtop *server)
return; return;
} }
server->machine.loadavg_offset = result; server->machine->loadavg_offset = result;
server->sysdeps.loadavg = _glibtop_sysdeps_loadavg; 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)); 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)); loadavg, sizeof(loadavg));
if (result <= 0) if (result <= 0)
{ {

View File

@@ -44,7 +44,7 @@ _glibtop_init_msg_limits_p (glibtop *server)
return; return;
} }
server->machine.msginfo_offset = result; server->machine->msginfo_offset = result;
server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits; 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)); 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)); &msginfo, sizeof(msginfo));
if (result <= 0) if (result <= 0)

View File

@@ -100,7 +100,7 @@ _glibtop_init_netload_p (glibtop *server)
return; return;
} }
server->machine.ifnet_offset = addr; server->machine->ifnet_offset = addr;
server->sysdeps.netload = _glibtop_sysdeps_netload; 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)); memset (buf, 0, sizeof (glibtop_netload));
for ( offset = server->machine.ifnet_offset; for ( offset = server->machine->ifnet_offset;
offset != 0; offset != 0;
offset = (off_t)ifnet.if_next 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 !!! */ /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
server->machine.uid = getuid (); server->machine->uid = getuid ();
server->machine.euid = geteuid (); server->machine->euid = geteuid ();
server->machine.gid = getgid (); server->machine->gid = getgid ();
server->machine.egid = getegid (); server->machine->egid = getegid ();
/* open kmem */ /* open kmem */
server->machine.kmem_fd = open("/dev/kmem", O_RDONLY); server->machine->kmem_fd = open("/dev/kmem", O_RDONLY);
if (server->machine.kmem_fd == -1) if (server->machine->kmem_fd == -1)
glibtop_error_io_r (server, "Cannot open /dev/kmem"); glibtop_error_io_r (server, "Cannot open /dev/kmem");
/* Drop priviledges. */ /* Drop priviledges. */
if (seteuid (server->machine.uid)) if (seteuid (server->machine->uid))
_exit (1); _exit (1);
if (setegid (server->machine.gid)) if (setegid (server->machine->gid))
_exit (1); _exit (1);
/* !!! END OF SUID ROOT PART !!! */ /* !!! END OF SUID ROOT PART !!! */

View File

@@ -46,7 +46,7 @@ _glibtop_init_sem_limits_p (glibtop *server)
return; return;
} }
server->machine.seminfo_offset = result; server->machine->seminfo_offset = result;
server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits; 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)); 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)); &seminfo, sizeof(seminfo));
if (result <= 0) if (result <= 0)

View File

@@ -44,7 +44,7 @@ _glibtop_init_shm_limits_p (glibtop *server)
return; return;
} }
server->machine.shminfo_offset = result; server->machine->shminfo_offset = result;
server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits; 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)); 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)); &shminfo, sizeof(struct shminfo));
if (result <= 0) 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); 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); glibtop_suid_leave(server);
@@ -86,23 +86,23 @@ _glibtop_get_procinfo (glibtop *server, pid_t pid)
/* test if procsinfo already found */ /* 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 */ /* seek procsinfo if given pid */
first_time = 0; first_time = 0;
current = 0; current = 0;
while ((result = getprocs( &server->machine.last_pinfo while ((result = getprocs( &server->machine->last_pinfo
, sizeof(struct procsinfo) , sizeof(struct procsinfo)
, NULL, 0, &current, 1)) == 1) , 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; return NULL;

View File

@@ -61,7 +61,7 @@ void
_glibtop_init_cpu_p (glibtop *server) _glibtop_init_cpu_p (glibtop *server)
{ {
#ifndef KERN_CP_TIME #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)"); glibtop_warn_io_r (server, "kvm_nlist (cpu)");
return; return;
} }
@@ -100,7 +100,7 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
return; return;
} }
#else #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)) { &cpts, sizeof (cpts)) != sizeof (cpts)) {
glibtop_warn_io_r (server, "kvm_read (cp_time)"); glibtop_warn_io_r (server, "kvm_read (cp_time)");
return; return;

View File

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

View File

@@ -35,11 +35,11 @@ G_BEGIN_DECLS
#define UREADOK(ki) (FORCEUREAD || (KI_PROC(ki)->p_flag & P_INMEM)) #define UREADOK(ki) (FORCEUREAD || (KI_PROC(ki)->p_flag & P_INMEM))
static inline void glibtop_suid_enter (glibtop *server) { 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) { 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); _exit (1);
}; };

View File

@@ -92,7 +92,7 @@ _glibtop_init_mem_p (glibtop *server)
{ {
register int pagesize; 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)"); glibtop_warn_io_r (server, "kvm_nlist (mem)");
return; return;
} }
@@ -154,14 +154,14 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
} }
#else #else
/* Get the data from kvm_* */ /* 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)) { &vmm, sizeof (vmm)) != sizeof (vmm)) {
glibtop_warn_io_r (server, "kvm_read (cnt)"); glibtop_warn_io_r (server, "kvm_read (cnt)");
return; return;
} }
#endif #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)) { &bufspace, sizeof (bufspace)) != sizeof (bufspace)) {
glibtop_warn_io_r (server, "kvm_read (bufspace)"); glibtop_warn_io_r (server, "kvm_read (bufspace)");
return; return;

View File

@@ -75,12 +75,12 @@ static struct nlist nlst [] = {
void void
_glibtop_init_msg_limits_p (glibtop *server) _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)"); glibtop_warn_io_r (server, "kvm_nlist (msg_limits)");
return; 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)) { &_msginfo, sizeof (_msginfo)) != sizeof (_msginfo)) {
glibtop_warn_io_r (server, "kvm_read (msginfo)"); glibtop_warn_io_r (server, "kvm_read (msginfo)");
return; return;

View File

@@ -72,7 +72,7 @@ _glibtop_init_netload_p (glibtop *server)
{ {
server->sysdeps.netload = _glibtop_sysdeps_netload; 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"); 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)); 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)) &ifnetaddr, sizeof (ifnetaddr)) != sizeof (ifnetaddr))
glibtop_error_io_r (server, "kvm_read (ifnet)"); glibtop_error_io_r (server, "kvm_read (ifnet)");
@@ -111,12 +111,12 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
{ {
ifnetfound = ifnetaddr; ifnetfound = ifnetaddr;
if (kvm_read (server->machine.kd, ifnetaddr, &ifnet, if (kvm_read (server->machine->kd, ifnetaddr, &ifnet,
sizeof (ifnet)) != sizeof (ifnet)) sizeof (ifnet)) != sizeof (ifnet))
glibtop_error_io_r (server, "kvm_read (ifnetaddr)"); glibtop_error_io_r (server, "kvm_read (ifnetaddr)");
#if (defined(__FreeBSD__) && (__FreeBSD_version < 501113)) || defined(__bsdi__) #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) tname, 16) != 16)
glibtop_error_io_r (server, "kvm_read (if_name)"); glibtop_error_io_r (server, "kvm_read (if_name)");
tname[15] = '\0'; tname[15] = '\0';
@@ -202,7 +202,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
buf->flags = _glibtop_sysdeps_netload; buf->flags = _glibtop_sysdeps_netload;
while (ifaddraddr) { while (ifaddraddr) {
if ((kvm_read (server->machine.kd, ifaddraddr, &ifaddr, if ((kvm_read (server->machine->kd, ifaddraddr, &ifaddr,
sizeof (ifaddr)) != sizeof (ifaddr))) sizeof (ifaddr)) != sizeof (ifaddr)))
glibtop_error_io_r (server, "kvm_read (ifaddraddr)"); 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 !!! */ /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
server->machine.uid = getuid (); server->machine->uid = getuid ();
server->machine.euid = geteuid (); server->machine->euid = geteuid ();
server->machine.gid = getgid (); server->machine->gid = getgid ();
server->machine.egid = getegid (); server->machine->egid = getegid ();
#ifdef __FreeBSD__ #ifdef __FreeBSD__
server->os_version_code = __FreeBSD_version; server->os_version_code = __FreeBSD_version;
#endif #endif
/* Setup machine-specific data */ /* 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"); glibtop_error_io_r (server, "kvm_open");
/* Drop priviledges. */ /* Drop priviledges. */
if (setreuid (server->machine.euid, server->machine.uid)) if (setreuid (server->machine->euid, server->machine->uid))
_exit (1); _exit (1);
if (setregid (server->machine.egid, server->machine.gid)) if (setregid (server->machine->egid, server->machine->gid))
_exit (1); _exit (1);
/* !!! END OF SUID ROOT PART !!! */ /* !!! END OF SUID ROOT PART !!! */

View File

@@ -81,7 +81,7 @@ _glibtop_init_ppp_p (glibtop *server)
#endif #endif
#endif /* HAVE_I4B */ #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"); 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)); 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)) &data, sizeof (data)) != sizeof (data))
glibtop_error_io_r (server, "kvm_read (i4bisppp_softc)"); 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); glibtop_suid_enter (server);
/* Get the process data */ /* 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)) { if ((pinfo == NULL) || (count < 1)) {
glibtop_suid_leave (server); glibtop_suid_leave (server);
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return NULL; return NULL;
} }
args = kvm_getargv (server->machine.kd, pinfo, max_len); args = kvm_getargv (server->machine->kd, pinfo, max_len);
if (args == NULL) { if (args == NULL) {
glibtop_suid_leave (server); glibtop_suid_leave (server);
glibtop_warn_io_r (server, "kvm_getargv (%d)", pid); 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; if (pid == 0) return;
/* Get the process information */ /* 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)) { if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return; return;
@@ -170,11 +170,11 @@ glibtop_get_proc_kernel_p (glibtop *server,
/* On NetBSD, there is no kvm_uread(), and kvm_read() always reads /* On NetBSD, there is no kvm_uread(), and kvm_read() always reads
* from kernel memory. */ * from kernel memory. */
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
#else #else
if ((pinfo [0].kp_proc.p_flag & P_INMEM) && 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 #endif
(unsigned long) &u_addr->u_stats, (unsigned long) &u_addr->u_stats,
(char *) &pstats, sizeof (pstats)) == sizeof (pstats)) (char *) &pstats, sizeof (pstats)) == sizeof (pstats))
@@ -195,10 +195,10 @@ glibtop_get_proc_kernel_p (glibtop *server,
} }
#ifdef __NetBSD__ #ifdef __NetBSD__
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
#else #else
if ((pinfo [0].kp_proc.p_flag & P_INMEM) && 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 #endif
(unsigned long) &u_addr->u_pcb, (unsigned long) &u_addr->u_pcb,
(char *) &pcb, sizeof (pcb)) == sizeof (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); which = (int)(real_which & GLIBTOP_KERN_PROC_MASK);
/* Get the process data */ /* 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)) { if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (proclist)"); glibtop_warn_io_r (server, "kvm_getprocs (proclist)");
return NULL; return NULL;

View File

@@ -128,7 +128,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
glibtop_suid_enter (server); glibtop_suid_enter (server);
/* Get the process data */ /* 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)) { if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return (glibtop_map_entry*) g_array_free(maps, TRUE); 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. */ /* 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__) #if (defined(__FreeBSD__) && (__FreeBSD_version >= 500013)) || defined(__FreeBSD_kernel__)
(unsigned long) pinfo [0].ki_vmspace, (unsigned long) pinfo [0].ki_vmspace,
#else #else
@@ -147,7 +147,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
first = vmspace.vm_map.header.next; 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, (unsigned long) vmspace.vm_map.header.next,
(char *) &entry, sizeof (entry)) != sizeof (entry)) (char *) &entry, sizeof (entry)) != sizeof (entry))
glibtop_error_io_r (server, "kvm_read (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; guint len;
if (update) { if (update) {
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(unsigned long) entry.next, (unsigned long) entry.next,
&entry, sizeof (entry)) != sizeof (entry)) &entry, sizeof (entry)) != sizeof (entry))
glibtop_error_io_r (server, "kvm_read (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 */ /* We're only interested in vnodes */
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(unsigned long) entry.object.uvm_obj, (unsigned long) entry.object.uvm_obj,
&vnode, sizeof (vnode)) != sizeof (vnode)) { &vnode, sizeof (vnode)) != sizeof (vnode)) {
glibtop_warn_io_r (server, "kvm_read (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 */ /* 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, (unsigned long) entry.object.vm_object,
&object, sizeof (object)) != sizeof (object)) &object, sizeof (object)) != sizeof (object))
glibtop_error_io_r (server, "kvm_read (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) || if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
!vnode.v_data) continue; !vnode.v_data) continue;
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(unsigned long) vnode.v_data, (unsigned long) vnode.v_data,
&inode, sizeof (inode)) != sizeof (inode)) &inode, sizeof (inode)) != sizeof (inode))
glibtop_error_io_r (server, "kvm_read (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) if (!object.handle)
continue; continue;
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(unsigned long) object.handle, (unsigned long) object.handle,
&vnode, sizeof (vnode)) != sizeof (vnode)) &vnode, sizeof (vnode)) != sizeof (vnode))
glibtop_error_io_r (server, "kvm_read (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) || if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
!vnode.v_data) continue; !vnode.v_data) continue;
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(unsigned long) vnode.v_data, (unsigned long) vnode.v_data,
&inode, sizeof (inode)) != sizeof (inode)) &inode, sizeof (inode)) != sizeof (inode))
glibtop_error_io_r (server, "kvm_read (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; if (pid == 0) return;
/* Get the process data */ /* 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)) { if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return; return;
@@ -161,7 +161,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
#define PROC_VMSPACE kp_proc.p_vmspace #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, (unsigned long) pinfo [0].PROC_VMSPACE,
(char *) &plimit, sizeof (plimit)) != sizeof (plimit)) { (char *) &plimit, sizeof (plimit)) != sizeof (plimit)) {
glibtop_warn_io_r (server, "kvm_read (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. */ /* Now we get the shared memory. */
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(unsigned long) pinfo [0].PROC_VMSPACE, (unsigned long) pinfo [0].PROC_VMSPACE,
(char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) { (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) {
glibtop_warn_io_r (server, "kvm_read (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; 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, (unsigned long) vmspace.vm_map.header.next,
(char *) &entry, sizeof (entry)) != sizeof (entry)) { (char *) &entry, sizeof (entry)) != sizeof (entry)) {
glibtop_warn_io_r (server, "kvm_read (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. */ * to OBJT_DEFAULT so if seems this really works. */
while (entry.next != first) { while (entry.next != first) {
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(unsigned long) entry.next, (unsigned long) entry.next,
&entry, sizeof (entry)) != sizeof (entry)) { &entry, sizeof (entry)) != sizeof (entry)) {
glibtop_warn_io_r (server, "kvm_read (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 */ /* We're only interested in vnodes */
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(unsigned long) entry.object.uvm_obj, (unsigned long) entry.object.uvm_obj,
&vnode, sizeof (vnode)) != sizeof (vnode)) { &vnode, sizeof (vnode)) != sizeof (vnode)) {
glibtop_warn_io_r (server, "kvm_read (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 */ /* 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, (unsigned long) entry.object.vm_object,
&object, sizeof (object)) != sizeof (object)) { &object, sizeof (object)) != sizeof (object)) {
glibtop_warn_io_r (server, "kvm_read (object)"); glibtop_warn_io_r (server, "kvm_read (object)");

View File

@@ -53,7 +53,7 @@ glibtop_get_proc_segment_p (glibtop *server,
#if 0 #if 0
/* Get the process info from the kernel */ /* 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) { if (*count != 1) {
return; /* the zeroed-out buffer indicating no data */ 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; if (pid == 0) return;
/* Get the process information */ /* 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)) { if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return; return;

View File

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

View File

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

View File

@@ -77,12 +77,12 @@ static struct nlist nlst [] = {
void void
_glibtop_init_sem_limits_p (glibtop *server) _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)"); glibtop_warn_io_r (server, "kvm_nlist (sem_limits)");
return; 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)) { &_seminfo, sizeof (_seminfo)) != sizeof (_seminfo)) {
glibtop_warn_io_r (server, "kvm_read (seminfo)"); glibtop_warn_io_r (server, "kvm_read (seminfo)");
return; return;

View File

@@ -75,12 +75,12 @@ static struct nlist nlst [] = {
void void
_glibtop_init_shm_limits_p (glibtop *server) _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)"); glibtop_warn_io_r (server, "kvm_nlist (shm_limits)");
return; 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)) { &_shminfo, sizeof (_shminfo)) != sizeof (_shminfo)) {
glibtop_warn_io_r (server, "kvm_read (shminfo)"); glibtop_warn_io_r (server, "kvm_read (shminfo)");
return; return;

View File

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

View File

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

View File

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

View File

@@ -22,12 +22,14 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#include <glibtop_machine.h>
static inline void glibtop_suid_enter (glibtop *server) { 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) { 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); _exit (1);
}; };

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -51,8 +51,6 @@ glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
pid_t last_pid; pid_t last_pid;
size_t len; size_t len;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_LOADAVG, 0);
memset (buf, 0, sizeof (glibtop_loadavg)); memset (buf, 0, sizeof (glibtop_loadavg));
if (getloadavg (buf->loadavg, G_N_ELEMENTS(buf->loadavg)) == -1) 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 membuffer;
gulong memfree; gulong memfree;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
memset (buf, 0, sizeof *buf); memset (buf, 0, sizeof *buf);
memtotal = mem_get_by_bytes (server, "hw.physmem"); 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, GArray *mount_array = g_array_new(FALSE, FALSE,
sizeof(glibtop_mountentry)); sizeof(glibtop_mountentry));
glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_mountlist)); memset (buf, 0, sizeof (glibtop_mountlist));
/* Read filesystem list. */ /* Read filesystem list. */

View File

@@ -48,8 +48,6 @@ glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
size_t len; size_t len;
int msgmax, msgmni, msgmnb, msgtql, msgssz, msgseg; int msgmax, msgmni, msgmnb, msgtql, msgssz, msgseg;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0);
memset (buf, 0, sizeof (glibtop_msg_limits)); memset (buf, 0, sizeof (glibtop_msg_limits));
if (server->sysdeps.msg_limits == 0) 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; struct if_nameindex *ifstart, *ifs;
GPtrArray *devices; GPtrArray *devices;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_NETLIST, 0);
memset (buf, 0, sizeof (glibtop_netlist)); memset (buf, 0, sizeof (glibtop_netlist));
ifs = ifstart = if_nameindex(); ifs = ifstart = if_nameindex();

View File

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

View File

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

View File

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

View File

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

View File

@@ -72,8 +72,6 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
unsigned int i; unsigned int i;
pid_t prev; pid_t prev;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0);
memset (buf, 0, sizeof (glibtop_proclist)); memset (buf, 0, sizeof (glibtop_proclist));
if (sysctlbyname ("kern.proc.all", NULL, &len, NULL, 0)) { 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); glibtop_get_proc_state_p (server, &procstate, pid);
if (procstate.flags & (1L << GLIBTOP_PROC_STATE_STATE)) if (procstate.flags & (1L << GLIBTOP_PROC_STATE_STATE))
if (procstate.state != GLIBTOP_PROCESS_RUNNING) continue; 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) if (which & GLIBTOP_EXCLUDE_SYSTEM)

View File

@@ -91,9 +91,9 @@ _glibtop_sysdeps_freebsd_dev_inode (glibtop *server, struct vnode *vnode,
*inum = 0; *inum = 0;
*dev = 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) || (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)) (char *) tagstr, sizeof (tagstr)) != sizeof (tagstr))
{ {
glibtop_warn_io_r (server, "kvm_read (tagptr)"); glibtop_warn_io_r (server, "kvm_read (tagptr)");
@@ -111,7 +111,7 @@ _glibtop_sysdeps_freebsd_dev_inode (glibtop *server, struct vnode *vnode,
return; 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)) sizeof (inode)) != sizeof (inode))
{ {
glibtop_warn_io_r (server, "kvm_read (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; struct my_zfsvfs zvfs;
if (kvm_read(server->machine.kd, if (kvm_read(server->machine->kd,
(unsigned long)(znode->z_zfsvfs), (unsigned long)(znode->z_zfsvfs),
&zvfs, sizeof zvfs) != sizeof zvfs) { &zvfs, sizeof zvfs) != sizeof zvfs) {
glibtop_warn_io_r(server, "kvm_read (z_zfsvfs)"); 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 (__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)) sizeof (priv))
#else #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) || 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)) sizeof (priv))
#endif #endif
!= sizeof (priv)) != sizeof (priv))
@@ -209,8 +209,6 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
int count; int count;
int update = 0; int update = 0;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MAP), 0);
memset (buf, 0, sizeof (glibtop_proc_map)); memset (buf, 0, sizeof (glibtop_proc_map));
/* It does not work for the swapper task. */ /* 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); glibtop_suid_enter (server);
/* Get the process data */ /* 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)) { if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
glibtop_suid_leave (server); 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. */ /* Now we get the memory maps. */
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(gulong) pinfo [0].ki_vmspace, (gulong) pinfo [0].ki_vmspace,
(char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) { (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) {
glibtop_warn_io_r (server, "kvm_read (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; first = vmspace.vm_map.header.next;
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(gulong) vmspace.vm_map.header.next, (gulong) vmspace.vm_map.header.next,
(char *) &entry, sizeof (entry)) != sizeof (entry)) { (char *) &entry, sizeof (entry)) != sizeof (entry)) {
glibtop_warn_io_r (server, "kvm_read (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; guint len;
if (update) { if (update) {
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(gulong) entry.next, (gulong) entry.next,
(char *) &entry, sizeof (entry)) != sizeof (entry)) { (char *) &entry, sizeof (entry)) != sizeof (entry)) {
glibtop_warn_io_r (server, "kvm_read (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 */ /* 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, (gulong) entry.object.vm_object,
(char *) &object, sizeof (object)) != sizeof (object)) { (char *) &object, sizeof (object)) != sizeof (object)) {
glibtop_warn_io_r (server, "kvm_read (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) if (!object.handle)
continue; continue;
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(gulong) object.handle, (gulong) object.handle,
(char *) &vnode, sizeof (vnode)) != sizeof (vnode)) { (char *) &vnode, sizeof (vnode)) != sizeof (vnode)) {
glibtop_warn_io_r (server, "kvm_read (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; struct vm_object object;
int count; int count;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MEM), 0);
memset (buf, 0, sizeof (glibtop_proc_mem)); memset (buf, 0, sizeof (glibtop_proc_mem));
if (server->sysdeps.proc_mem == 0) 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; if (pid == 0) return;
/* Get the process data */ /* 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)) { if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return; return;
@@ -110,7 +108,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
/* Now we get the shared memory. */ /* Now we get the shared memory. */
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(unsigned long) pinfo [0].PROC_VMSPACE, (unsigned long) pinfo [0].PROC_VMSPACE,
(char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) { (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) {
glibtop_warn_io_r (server, "kvm_read (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; 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, (unsigned long) vmspace.vm_map.header.next,
(char *) &entry, sizeof (entry)) != sizeof (entry)) { (char *) &entry, sizeof (entry)) != sizeof (entry)) {
glibtop_warn_io_r (server, "kvm_read (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. */ * to OBJT_DEFAULT so if seems this really works. */
while (entry.next != first) { while (entry.next != first) {
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(unsigned long) entry.next, (unsigned long) entry.next,
(char *) &entry, sizeof (entry)) != sizeof (entry)) { (char *) &entry, sizeof (entry)) != sizeof (entry)) {
glibtop_warn_io_r (server, "kvm_read (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 */ /* 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, (unsigned long) entry.object.vm_object,
(char *) &object, sizeof (object)) != sizeof (object)) { (char *) &object, sizeof (object)) != sizeof (object)) {
glibtop_warn_io_r (server, "kvm_read (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; struct kinfo_proc *pinfo;
int count = 0; int count = 0;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
memset (buf, 0, sizeof (glibtop_proc_segment)); memset (buf, 0, sizeof (glibtop_proc_segment));
/* It does not work for the swapper task. */ /* It does not work for the swapper task. */
if (pid == 0) return; if (pid == 0) return;
/* Get the process info from the kernel */ /* 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)) { if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return; return;

View File

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

View File

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

View File

@@ -66,8 +66,6 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
int count; int count;
size_t len; size_t len;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0);
memset (buf, 0, sizeof (glibtop_proc_time)); memset (buf, 0, sizeof (glibtop_proc_time));
/* It does not work for the swapper task. */ /* 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); glibtop_suid_enter (server);
/* Get the process information */ /* 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)) { if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
glibtop_suid_leave (server); 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; struct kinfo_proc *pinfo;
int count = 0; int count = 0;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_UID), 0);
memset (buf, 0, sizeof (glibtop_proc_uid)); memset (buf, 0, sizeof (glibtop_proc_uid));
/* It does not work for the swapper task. */ /* It does not work for the swapper task. */
if (pid == 0) return; if (pid == 0) return;
/* Get the process information */ /* 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)) { if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return; 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 semmap, semmni, semmns, semmnu, semmsl, semopm, semume, semusz;
int semvmx, semaem; int semvmx, semaem;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0);
memset (buf, 0, sizeof (glibtop_sem_limits)); memset (buf, 0, sizeof (glibtop_sem_limits));
if (server->sysdeps.sem_limits == 0) 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; unsigned long shmmax, shmmin, shmmni, shmseg, shmall;
#endif #endif
glibtop_init_s (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0);
memset (buf, 0, sizeof (glibtop_shm_limits)); memset (buf, 0, sizeof (glibtop_shm_limits));
if (server->sysdeps.shm_limits == 0) if (server->sysdeps.shm_limits == 0)

View File

@@ -25,6 +25,7 @@
#include <glibtop/cpu.h> #include <glibtop/cpu.h>
#include <glibtop/open.h> #include <glibtop/open.h>
#include <glibtop/init_hooks.h> #include <glibtop/init_hooks.h>
#include <glibtop/machine.h>
/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ /* !!! 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 ()"); glibtop_debug ("glibtop_open_p ()");
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
server->machine.uid = getuid (); server->machine->uid = getuid ();
server->machine.euid = geteuid (); server->machine->euid = geteuid ();
server->machine.gid = getgid (); server->machine->gid = getgid ();
server->machine.egid = getegid (); server->machine->egid = getegid ();
/* Setup machine-specific data */ /* 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"); glibtop_error_io_r (server, "kvm_open");
/* Drop priviledges. */ /* 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); _exit (1);
if (setregid (server->machine.egid, server->machine.gid)) if (setregid (server->machine->egid, server->machine->gid))
_exit (1); _exit (1);
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
/* !!! END OF SUID ROOT PART !!! */ /* !!! END OF SUID ROOT PART !!! */
/* Our effective uid is now those of the user invoking the server, /* 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; int nswdev;
struct kvm_swap kvmsw[16]; struct kvm_swap kvmsw[16];
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SWAP), 0);
memset (buf, 0, sizeof (glibtop_swap)); memset (buf, 0, sizeof (glibtop_swap));
memset (kvmsw, 0, sizeof (kvmsw)); 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; if (nswdev < 1) return;
buf->flags = _glibtop_sysdeps_swap; buf->flags = _glibtop_sysdeps_swap;

View File

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

View File

@@ -58,8 +58,6 @@ glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
size_t size; size_t size;
glibtop_cpu cpu; glibtop_cpu cpu;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_UPTIME, 0);
memset (buf, 0, sizeof (glibtop_uptime)); memset (buf, 0, sizeof (glibtop_uptime));
mib[0] = CTL_KERN; 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; struct statvfs fsd;
glibtop_init_r(&server, 0, 0);
memset(buf, 0, sizeof(glibtop_fsusage)); memset(buf, 0, sizeof(glibtop_fsusage));
if (statvfs(path, &fsd) < 0) { if (statvfs(path, &fsd) < 0) {

View File

@@ -22,21 +22,12 @@
#ifndef __GLIBTOP_MACHINE_H__ #ifndef __GLIBTOP_MACHINE_H__
#define __GLIBTOP_MACHINE_H__ #define __GLIBTOP_MACHINE_H__
#include <unistd.h> #include <glib.h>
#include <fcntl.h>
#include <ctype.h>
G_BEGIN_DECLS G_BEGIN_DECLS
typedef struct _glibtop_machine glibtop_machine;
struct _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 G_END_DECLS

View File

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

View File

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

View File

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

View File

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

View File

@@ -35,11 +35,11 @@ G_BEGIN_DECLS
#define UREADOK(ki) (FORCEUREAD || (KI_PROC(ki)->p_flag & P_INMEM)) #define UREADOK(ki) (FORCEUREAD || (KI_PROC(ki)->p_flag & P_INMEM))
static inline void glibtop_suid_enter (glibtop *server) { 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) { 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); _exit (1);
}; };

View File

@@ -58,12 +58,12 @@ static struct nlist nlst [] = {
void void
_glibtop_init_msg_limits_p (glibtop *server) _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)"); glibtop_warn_io_r (server, "kvm_nlist (msg_limits)");
return; 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)) { &_msginfo, sizeof (_msginfo)) != sizeof (_msginfo)) {
glibtop_warn_io_r (server, "kvm_read (msginfo)"); glibtop_warn_io_r (server, "kvm_read (msginfo)");
return; return;

View File

@@ -73,7 +73,7 @@ _glibtop_init_netload_p (glibtop *server)
{ {
server->sysdeps.netload = _glibtop_sysdeps_netload; 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"); 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)); 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)) &ifnetaddr, sizeof (ifnetaddr)) != sizeof (ifnetaddr))
glibtop_error_io_r (server, "kvm_read (ifnet)"); glibtop_error_io_r (server, "kvm_read (ifnet)");
@@ -109,7 +109,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
{ {
ifnetfound = ifnetaddr; ifnetfound = ifnetaddr;
if (kvm_read (server->machine.kd, ifnetaddr, &ifnet, if (kvm_read (server->machine->kd, ifnetaddr, &ifnet,
sizeof (ifnet)) != sizeof (ifnet)) sizeof (ifnet)) != sizeof (ifnet))
glibtop_error_io_r (server, "kvm_read (ifnetaddr)"); 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; buf->flags = _glibtop_sysdeps_netload;
while (ifaddraddr) { while (ifaddraddr) {
if ((kvm_read (server->machine.kd, ifaddraddr, &ifaddr, if ((kvm_read (server->machine->kd, ifaddraddr, &ifaddr,
sizeof (ifaddr)) != sizeof (ifaddr))) sizeof (ifaddr)) != sizeof (ifaddr)))
glibtop_error_io_r (server, "kvm_read (ifaddraddr)"); glibtop_error_io_r (server, "kvm_read (ifaddraddr)");

View File

@@ -77,7 +77,7 @@ _glibtop_init_ppp_p (glibtop *server)
#endif #endif
#endif /* HAVE_I4B */ #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"); 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)); 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)) &data, sizeof (data)) != sizeof (data))
glibtop_error_io_r (server, "kvm_read (i4bisppp_softc)"); glibtop_error_io_r (server, "kvm_read (i4bisppp_softc)");

View File

@@ -65,7 +65,7 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
glibtop_suid_enter (server); glibtop_suid_enter (server);
/* Get the process data */ /* 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); sizeof (*pinfo), &count);
if (pinfo == NULL) { if (pinfo == NULL) {
glibtop_suid_leave (server); glibtop_suid_leave (server);
@@ -73,7 +73,7 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
return NULL; return NULL;
} }
args = kvm_getargv (server->machine.kd, pinfo, max_len); args = kvm_getargv (server->machine->kd, pinfo, max_len);
if (args == NULL) { if (args == NULL) {
glibtop_suid_leave (server); glibtop_suid_leave (server);
glibtop_warn_io_r (server, "kvm_getargv (%d)", pid); 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); glibtop_suid_enter (server);
/* Get the process information */ /* 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); sizeof(*pinfo), &count);
if (pinfo == NULL) { if (pinfo == NULL) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); 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); which = (int)(real_which & GLIBTOP_KERN_PROC_MASK);
/* Get the process data */ /* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, which, arg, pinfo = kvm_getprocs (server->machine->kd, which, arg,
sizeof (*pinfo), &count); sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count < 1)) { if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (proclist)"); glibtop_warn_io_r (server, "kvm_getprocs (proclist)");

View File

@@ -99,7 +99,7 @@ load_vmmap_entries(glibtop *server, unsigned long kptr,
return -1; return -1;
/* Download entry at kptr. */ /* Download entry at kptr. */
if (kvm_read (server->machine.kd, kptr, if (kvm_read (server->machine->kd, kptr,
(char *)entry, sizeof(*entry)) != sizeof(*entry)) { (char *)entry, sizeof(*entry)) != sizeof(*entry)) {
free(entry); free(entry);
return -1; return -1;
@@ -185,7 +185,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
glibtop_suid_enter (server); glibtop_suid_enter (server);
/* Get the process data */ /* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &count); pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &count);
if (pinfo == NULL) { if (pinfo == NULL) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return (glibtop_map_entry*) g_array_free(maps, TRUE); return (glibtop_map_entry*) g_array_free(maps, TRUE);
@@ -193,7 +193,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
/* Now we get the memory maps. */ /* Now we get the memory maps. */
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(unsigned long) pinfo [0].p_vmspace, (unsigned long) pinfo [0].p_vmspace,
(char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) { (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) {
glibtop_warn_io_r (server, "kvm_read (vmspace)"); glibtop_warn_io_r (server, "kvm_read (vmspace)");
@@ -238,7 +238,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
/* We're only interested in vnodes */ /* We're only interested in vnodes */
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(unsigned long) entry->object.uvm_obj, (unsigned long) entry->object.uvm_obj,
&vnode, sizeof (vnode)) != sizeof (vnode)) { &vnode, sizeof (vnode)) != sizeof (vnode)) {
glibtop_warn_io_r (server, "kvm_read (vnode)"); glibtop_warn_io_r (server, "kvm_read (vnode)");
@@ -254,7 +254,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) || if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
!vnode.v_data) continue; !vnode.v_data) continue;
if (kvm_read (server->machine.kd, if (kvm_read (server->machine->kd,
(unsigned long) vnode.v_data, (unsigned long) vnode.v_data,
&inode, sizeof (inode)) != sizeof (inode)) { &inode, sizeof (inode)) != sizeof (inode)) {
glibtop_warn_io_r (server, "kvm_read (inode)"); glibtop_warn_io_r (server, "kvm_read (inode)");

View File

@@ -113,7 +113,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
if (pid == 0) return; if (pid == 0) return;
/* Get the process data */ /* 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); sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count < 1)) { if ((pinfo == NULL) || (count < 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);

View File

@@ -63,7 +63,7 @@ glibtop_get_proc_segment_p (glibtop *server,
if (pid == 0) return; if (pid == 0) return;
/* Get the process info from the kernel */ /* Get the process info from the kernel */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count); sizeof (*pinfo), &count);
if (pinfo == NULL) { if (pinfo == NULL) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);

View File

@@ -58,7 +58,7 @@ glibtop_get_proc_signal_p (glibtop *server,
if (pid == 0) return; if (pid == 0) return;
/* Get the process information */ /* 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); sizeof (*pinfo), &count);
if (pinfo == NULL) { if (pinfo == NULL) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid); glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);

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