libgtop-01-solaris.diff revision 9427
9311N/Adiff -Nrup libgtop-2.14.4/include/glibtop/error.h libgtop-2.14.4.mod/include/glibtop/error.h
9311N/A--- libgtop-2.14.4/include/glibtop/error.h 2005-02-15 18:14:59.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/include/glibtop/error.h 2006-11-13 20:28:00.229195000 +0800
8402N/A@@ -33,20 +33,20 @@
8402N/A
8402N/A G_BEGIN_DECLS
8402N/A
8402N/A-void glibtop_error_vr (glibtop *server, const char *format, va_list args) G_GNUC_INTERNAL G_GNUC_NORETURN;
8402N/A-void glibtop_warn_vr (glibtop *server, const char *format, va_list args) G_GNUC_INTERNAL;
8402N/A-void glibtop_error_io_vr (glibtop *server, const char *format, int, va_list args) G_GNUC_INTERNAL G_GNUC_NORETURN;
8402N/A-void glibtop_warn_io_vr (glibtop *server, const char *format, int, va_list args) G_GNUC_INTERNAL;
8402N/A-
8402N/A-void glibtop_error_r (glibtop *server, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3) G_GNUC_NORETURN;
8402N/A-void glibtop_warn_r (glibtop *server, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3);
8402N/A-void glibtop_error_io_r (glibtop *server, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3) G_GNUC_NORETURN;
8402N/A-void glibtop_warn_io_r (glibtop *server, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3);
8402N/A-
8402N/A-void glibtop_error (const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(1, 2) G_GNUC_NORETURN;
8402N/A-void glibtop_warn (const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(1, 2);
8402N/A-void glibtop_error_io (const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(1, 2) G_GNUC_NORETURN;
8402N/A-void glibtop_warn_io (const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(1, 2);
8402N/A+G_GNUC_INTERNAL void glibtop_error_vr (glibtop *server, const char *format, va_list args) G_GNUC_NORETURN;
8402N/A+G_GNUC_INTERNAL void glibtop_warn_vr (glibtop *server, const char *format, va_list args) ;
8402N/A+G_GNUC_INTERNAL void glibtop_error_io_vr (glibtop *server, const char *format, int, va_list args) G_GNUC_NORETURN;
8402N/A+G_GNUC_INTERNAL void glibtop_warn_io_vr (glibtop *server, const char *format, int, va_list args) ;
8402N/A+
8402N/A+G_GNUC_INTERNAL void glibtop_error_r (glibtop *server, const char *format, ...) G_GNUC_PRINTF(2, 3) G_GNUC_NORETURN;
8402N/A+G_GNUC_INTERNAL void glibtop_warn_r (glibtop *server, const char *format, ...) G_GNUC_PRINTF(2, 3);
8402N/A+G_GNUC_INTERNAL void glibtop_error_io_r (glibtop *server, const char *format, ...) G_GNUC_PRINTF(2, 3) G_GNUC_NORETURN;
8402N/A+G_GNUC_INTERNAL void glibtop_warn_io_r (glibtop *server, const char *format, ...) G_GNUC_PRINTF(2, 3);
8402N/A+
8402N/A+G_GNUC_INTERNAL void glibtop_error (const char *format, ...) G_GNUC_PRINTF(1, 2) G_GNUC_NORETURN;
8402N/A+G_GNUC_INTERNAL void glibtop_warn (const char *format, ...) G_GNUC_PRINTF(1, 2);
8402N/A+G_GNUC_INTERNAL void glibtop_error_io (const char *format, ...) G_GNUC_PRINTF(1, 2) G_GNUC_NORETURN;
8402N/A+G_GNUC_INTERNAL void glibtop_warn_io (const char *format, ...) G_GNUC_PRINTF(1, 2);
8402N/A
8402N/A G_END_DECLS
8402N/A
9311N/Adiff -Nrup libgtop-2.14.4/include/glibtop/procmem.h libgtop-2.14.4.mod/include/glibtop/procmem.h
9311N/A--- libgtop-2.14.4/include/glibtop/procmem.h 2006-04-23 02:16:53.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/include/glibtop/procmem.h 2006-11-13 20:28:00.231664000 +0800
8402N/A@@ -53,6 +53,7 @@ struct _glibtop_proc_mem
8922N/A guint64 rss; /* resident set size */
8922N/A guint64 rss_rlim; /* current limit (in bytes) of the rss
8402N/A * of the process; usually 2,147,483,647 */
8922N/A+ guint load; /* cpu load for process */
8402N/A };
8402N/A
8402N/A void glibtop_get_proc_mem(glibtop_proc_mem *buf, pid_t pid);
9311N/Adiff -Nrup libgtop-2.14.4/src/daemon/daemon.h libgtop-2.14.4.mod/src/daemon/daemon.h
9311N/A--- libgtop-2.14.4/src/daemon/daemon.h 2006-04-02 17:10:00.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/src/daemon/daemon.h 2006-11-13 20:28:00.073924000 +0800
8402N/A@@ -59,17 +59,17 @@ G_BEGIN_DECLS
8402N/A #define MSG_BUFSZ sizeof (struct _glibtop_ipc_message)
8402N/A #define MSG_MSGSZ (MSG_BUFSZ - sizeof (long))
8402N/A
8402N/A-void handle_parent_connection (int s) G_GNUC_INTERNAL;
8402N/A-void handle_slave_connection (int input, int output) G_GNUC_INTERNAL;
8402N/A-void handle_slave_command (glibtop_command *cmnd, glibtop_response *resp,
8402N/A- const void *parameter) G_GNUC_INTERNAL ;
8402N/A-
8402N/A-void do_output (int s, glibtop_response *resp, off_t offset,
8402N/A- size_t data_size, const void *data) G_GNUC_INTERNAL;
8402N/A-int do_read (int s, void *ptr, size_t total_size) G_GNUC_INTERNAL;
8402N/A+G_GNUC_INTERNAL void handle_parent_connection (int s) ;
8402N/A+G_GNUC_INTERNAL void handle_slave_connection (int input, int output) ;
8402N/A+G_GNUC_INTERNAL void handle_slave_command (glibtop_command *cmnd, glibtop_response *resp,
8402N/A+ const void *parameter) ;
8402N/A+
8402N/A+G_GNUC_INTERNAL void do_output (int s, glibtop_response *resp, off_t offset,
8402N/A+ size_t data_size, const void *data) ;
8402N/A+G_GNUC_INTERNAL int do_read (int s, void *ptr, size_t total_size) ;
8402N/A
8402N/A-void syslog_message (int priority, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3);
8402N/A-void syslog_io_message (int priority, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3);
8402N/A+G_GNUC_INTERNAL void syslog_message (int priority, const char *format, ...) G_GNUC_PRINTF(2, 3);
8402N/A+G_GNUC_INTERNAL void syslog_io_message (int priority, const char *format, ...) G_GNUC_PRINTF(2, 3);
8402N/A
8402N/A extern int enable_debug;
8402N/A extern int verbose_output;
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/common/fsusage.c libgtop-2.14.4.mod/sysdeps/common/fsusage.c
9311N/A--- libgtop-2.14.4/sysdeps/common/fsusage.c 2005-02-28 16:11:15.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/common/fsusage.c 2006-11-13 20:28:00.187415000 +0800
8402N/A@@ -126,10 +126,10 @@ static const unsigned long _glibtop_sysd
8402N/A */
8402N/A
8402N/A #ifdef linux
8402N/A-void
8402N/A+G_GNUC_INTERNAL void
8402N/A _glibtop_linux_get_fsusage_read_write(glibtop *server,
8402N/A glibtop_fsusage *buf,
8402N/A- const char *path) G_GNUC_INTERNAL;
8402N/A+ const char *path) ;
8402N/A
8402N/A static inline void
8402N/A _glibtop_get_fsusage_read_write(glibtop *server,
8402N/A@@ -141,7 +141,7 @@ _glibtop_get_fsusage_read_write(glibtop
8402N/A
8402N/A
8402N/A #elif defined(__FreeBSD__)
8402N/A-void G_GNUC_INTERNAL
8402N/A+G_GNUC_INTERNAL void
8402N/A _glibtop_freebsd_get_fsusage_read_write(glibtop *server,
8402N/A glibtop_fsusage *buf,
8402N/A const char *path);
8922N/A@@ -149,8 +149,17 @@ _glibtop_freebsd_get_fsusage_read_write(
8922N/A #define _glibtop_get_fsusage_read_write(S, B, P) \
8922N/A _glibtop_freebsd_get_fsusage_read_write(S, B, P)
8922N/A
8922N/A+#elif (defined(sun) || defined(__sun))
8922N/A+G_GNUC_INTERNAL void
8922N/A+_glibtop_sun_get_fsusage_read_write(glibtop *server,
8922N/A+ glibtop_fsusage *buf,
8922N/A+ const char *path);
8922N/A+
8922N/A+#define _glibtop_get_fsusage_read_write(S, B, P) \
8922N/A+ _glibtop_sun_get_fsusage_read_write(S, B, P)
8922N/A+
8922N/A #else /* default fallback */
8922N/A-#warning glibtop_get_fsusage .read .write are not implemented.
8922N/A+/*#warning glibtop_get_fsusage .read .write are not implemented.*/
8922N/A static inline void
8922N/A _glibtop_get_fsusage_read_write(glibtop *server,
8922N/A glibtop_fsusage *buf,
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/common/mountlist.c libgtop-2.14.4.mod/sysdeps/common/mountlist.c
9311N/A--- libgtop-2.14.4/sysdeps/common/mountlist.c 2006-06-25 01:24:27.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/common/mountlist.c 2006-11-13 20:28:00.187183000 +0800
8922N/A@@ -477,8 +477,10 @@ read_filesystem_list (void)
8922N/A
8922N/A if (fclose (fp) == EOF)
8922N/A return NULL;
8922N/A- if (ret > 0)
8922N/A+ if (ret > 0) {
8922N/A+ fclose (fp);
8922N/A return NULL;
8922N/A+ }
8922N/A }
8922N/A #endif /* MOUNTED_GETMNTENT2. */
8922N/A
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/Makefile.am libgtop-2.14.4.mod/sysdeps/solaris/Makefile.am
9311N/A--- libgtop-2.14.4/sysdeps/solaris/Makefile.am 2004-11-13 08:53:20.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/Makefile.am 2006-11-13 20:28:00.177639000 +0800
9427N/A@@ -8,7 +8,7 @@
8402N/A proclist.c procstate.c procuid.c \
8402N/A proctime.c procmem.c procsignal.c \
8402N/A prockernel.c procsegment.c procargs.c \
9427N/A- procopenfiles.c \
9427N/A+ procopenfiles.c sysinfo.c fsusage.c \
8402N/A procmap.c netload.c ppp.c procdata.c netlist.c
8402N/A
8402N/A libgtop_sysdeps_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/cpu.c libgtop-2.14.4.mod/sysdeps/solaris/cpu.c
9311N/A--- libgtop-2.14.4/sysdeps/solaris/cpu.c 2005-12-12 18:09:40.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/cpu.c 2006-11-13 20:28:00.175637000 +0800
8402N/A@@ -36,6 +36,7 @@ static const unsigned long _glibtop_sysd
8402N/A
8402N/A static const unsigned long _glibtop_sysdeps_cpu_all =
8402N/A (1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
8402N/A+(1L << GLIBTOP_CPU_NICE) +
8402N/A (1L << GLIBTOP_CPU_SYS) + (1L << GLIBTOP_CPU_IDLE) +
8402N/A (1L << GLIBTOP_XCPU_TOTAL) + (1L << GLIBTOP_XCPU_USER) +
8402N/A (1L << GLIBTOP_XCPU_SYS) + (1L << GLIBTOP_XCPU_IDLE) +
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/fsusage.c libgtop-2.14.4.mod/sysdeps/solaris/fsusage.c
9311N/A--- libgtop-2.14.4/sysdeps/solaris/fsusage.c 1970-01-01 08:00:00.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/fsusage.c 2006-11-13 20:28:00.181048000 +0800
8922N/A@@ -0,0 +1,99 @@
8922N/A+#include <config.h>
8922N/A+#include <glibtop.h>
8922N/A+#include <glibtop/error.h>
8922N/A+#include <glibtop/fsusage.h>
8922N/A+#include <glibtop/union.h>
8922N/A+
8922N/A+#include "glibtop_private.h"
8922N/A+
8922N/A+#include <glib.h>
8922N/A+
8922N/A+#include <unistd.h>
8922N/A+#include <kstat.h>
8922N/A+#include <sys/types.h>
8922N/A+#include <sys/stat.h>
8922N/A+#include <sys/statvfs.h>
8922N/A+
8922N/A+#include <stdio.h>
8922N/A+#include <string.h>
8922N/A+#include <stdlib.h>
8922N/A+
8922N/A+G_GNUC_INTERNAL void
8922N/A+_glibtop_sun_get_fsusage_read_write(glibtop *server,
8922N/A+ glibtop_fsusage *buf,
8922N/A+ const char *path)
8922N/A+{
8922N/A+ struct statvfs64 statvfsbuf;
8922N/A+ char ksname[KSTAT_STRLEN + 1];
8922N/A+ kstat_ctl_t * const kctl = server->machine.kc;
8922N/A+ kstat_t *ksp;
8922N/A+ kstat_io_t kio;
8922N/A+ kstat_named_t *kread, *kwrite;
8922N/A+ int i;
8922N/A+
8922N/A+ /*
8922N/A+ * get a kstat handle and update the user's kstat chain
8922N/A+ */
8922N/A+ if( kctl == NULL ){
8922N/A+ glibtop_warn_io_r (server, "kstat_open ()");
8922N/A+ return;
8922N/A+ }
8922N/A+
8922N/A+ /* make sure we have current data */
8922N/A+ while( kstat_chain_update( kctl ) != 0 )
8922N/A+ ;
8922N/A+
8922N/A+ for (ksp = kctl->kc_chain, i =0; ksp != NULL; ksp = ksp->ks_next, i++) {
8922N/A+ if (ksp->ks_type == KSTAT_TYPE_IO && strcmp(ksp->ks_class,"disk") == 0) {
8922N/A+ kstat_read(kctl, ksp, &kio);
8922N/A+ buf->read += kio.nread;
8922N/A+ buf->write += kio.nwritten;
8922N/A+ }
8922N/A+ }
8922N/A+#if 0
8922N/A+ /* these codes keep here, because they are a good way to get the
8922N/A+ fsusage information, but at the moment, the interfaces used
8922N/A+ are not public or stable. so let's use them when public...
8922N/A+ */
8922N/A+ /*
8922N/A+ * get a kstat handle and update the user's kstat chain
8922N/A+ */
8922N/A+ if( kctl == NULL ){
8922N/A+ glibtop_warn_io_r (server, "kstat_open ()");
8922N/A+ return;
8922N/A+ }
8922N/A+
8922N/A+ while( kstat_chain_update( kctl ) != 0 )
8922N/A+ ;
8922N/A+
8922N/A+ if (statvfs64(path, &statvfsbuf) != 0) {
8922N/A+ glibtop_warn_io_r (server, "kstat_open ()");
8922N/A+ return;
8922N/A+ }
8922N/A+ snprintf(ksname, KSTAT_STRLEN, "%s%lx", VOPSTATS_STR,
8922N/A+ statvfsbuf.f_fsid);
8922N/A+
8922N/A+ /*
8922N/A+ * traverse the kstat chain
8922N/A+ * to find the appropriate statistics
8922N/A+ */
8922N/A+ if( (ksp = kstat_lookup( kctl,
8922N/A+ "unix", 0, ksname )) == NULL ) {
8922N/A+ return;
8922N/A+ }
8922N/A+ if( kstat_read( kctl, ksp, NULL ) == -1 ) {
8922N/A+ return;
8922N/A+ }
8922N/A+
8922N/A+ kread = (kstat_named_t *)kstat_data_lookup(ksp,"read_bytes");
8922N/A+ if( kread != NULL ) {
8922N/A+ buf->read = kread->value.ull;
8922N/A+ }
8922N/A+
8922N/A+ kwrite = (kstat_named_t *)kstat_data_lookup(ksp,"write_bytes");
8922N/A+ if( kwrite != NULL ) {
8922N/A+ buf->write = kwrite->value.ull;
8922N/A+ }
8922N/A+#endif
8922N/A+ buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
8922N/A+}
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/glibtop_machine.h libgtop-2.14.4.mod/sysdeps/solaris/glibtop_machine.h
9311N/A--- libgtop-2.14.4/sysdeps/solaris/glibtop_machine.h 2006-06-25 01:52:28.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/glibtop_machine.h 2006-11-13 20:28:00.176250000 +0800
8922N/A@@ -63,14 +63,7 @@ struct _glibtop_machine
8402N/A int pagesize; /* in bits to shift, ie. 2^pagesize gives Kb */
8402N/A int ticks; /* clock ticks, as returned by sysconf() */
8402N/A unsigned long long boot; /* boot time, although it's ui32 in kstat */
8402N/A- void *libproc; /* libproc handle */
8575N/A-#if GLIBTOP_SOLARIS_RELEASE >= 50600
8402N/A- void (*objname)(void *, uintptr_t, const char *, size_t);
8402N/A- struct ps_prochandle *(*pgrab)(pid_t, int, int *);
8402N/A- void (*pfree)(void *);
8402N/A-#else
8402N/A void *filler[3];
8402N/A-#endif
8402N/A };
8402N/A
8402N/A G_END_DECLS
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/glibtop_server.h libgtop-2.14.4.mod/sysdeps/solaris/glibtop_server.h
9311N/A--- libgtop-2.14.4/sysdeps/solaris/glibtop_server.h 2005-08-12 22:55:37.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/glibtop_server.h 2006-11-13 20:28:00.175760000 +0800
8922N/A@@ -31,9 +31,15 @@ G_BEGIN_DECLS
8922N/A #define GLIBTOP_SUID_SWAP 0
8922N/A #define GLIBTOP_SUID_UPTIME 0
8922N/A #define GLIBTOP_SUID_LOADAVG 0
8922N/A+#if GLIBTOP_SOLARIS_RELEASE < 51000
8922N/A #define GLIBTOP_SUID_SHM_LIMITS (1L << GLIBTOP_SYSDEPS_SHM_LIMITS)
8922N/A #define GLIBTOP_SUID_MSG_LIMITS (1L << GLIBTOP_SYSDEPS_MSG_LIMITS)
8922N/A #define GLIBTOP_SUID_SEM_LIMITS (1L << GLIBTOP_SYSDEPS_SEM_LIMITS)
8922N/A+#else
8922N/A+#define GLIBTOP_SUID_SHM_LIMITS 0
8922N/A+#define GLIBTOP_SUID_MSG_LIMITS 0
8922N/A+#define GLIBTOP_SUID_SEM_LIMITS 0
8922N/A+#endif
8922N/A #define GLIBTOP_SUID_PROCLIST 0
8922N/A #define GLIBTOP_SUID_PROC_STATE 0
8922N/A #define GLIBTOP_SUID_PROC_UID 0
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/msg_limits.c libgtop-2.14.4.mod/sysdeps/solaris/msg_limits.c
9311N/A--- libgtop-2.14.4/sysdeps/solaris/msg_limits.c 2006-06-25 01:16:53.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/msg_limits.c 2006-11-13 20:28:00.176742000 +0800
8922N/A@@ -39,14 +39,24 @@ static const unsigned long _glibtop_sysd
8922N/A (1L << GLIBTOP_IPC_MSGMNB) + (1L << GLIBTOP_IPC_MSGMNI) +
8922N/A (1L << GLIBTOP_IPC_MSGTQL);
8922N/A #else
8922N/A-static const unsigned long _glibtop_sysdeps_msg_limits = 0;
8922N/A+static const unsigned long _glibtop_sysdeps_msg_limits =
8922N/A+(1L << GLIBTOP_IPC_MSGMNB) +
8922N/A+(1L << GLIBTOP_IPC_MSGMNI) +
8922N/A+(1L << GLIBTOP_IPC_MSGMAX) +
8922N/A+(1L << GLIBTOP_IPC_MSGPOOL) +
8922N/A+(1L << GLIBTOP_IPC_MSGTQL);
8922N/A #endif
8922N/A
8922N/A
8922N/A /* Init function. */
8922N/A
8922N/A+#if GLIBTOP_SUID_MSG_LIMITS
8922N/A void
8922N/A glibtop_init_msg_limits_p (glibtop *server)
8922N/A+#else
8922N/A+void
8922N/A+glibtop_init_msg_limits_s (glibtop *server)
8922N/A+#endif
8922N/A {
8922N/A #if GLIBTOP_SOLARIS_RELEASE < 51000
8922N/A
8922N/A@@ -61,8 +71,13 @@ glibtop_init_msg_limits_p (glibtop *serv
8922N/A
8922N/A /* Provides information about sysv ipc limits. */
8922N/A
8922N/A+#if GLIBTOP_SUID_MSG_LIMITS
8922N/A void
8922N/A glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
8922N/A+#else
8922N/A+void
8922N/A+glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
8922N/A+#endif
8922N/A {
8922N/A #if GLIBTOP_SOLARIS_RELEASE < 51000
8922N/A
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/netlist.c libgtop-2.14.4.mod/sysdeps/solaris/netlist.c
9311N/A--- libgtop-2.14.4/sysdeps/solaris/netlist.c 2006-06-25 01:33:05.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/netlist.c 2006-11-13 20:28:00.176984000 +0800
9311N/A@@ -41,7 +41,13 @@ glibtop_get_netlist_s (glibtop *server,
8922N/A {
8922N/A GPtrArray *devices;
8922N/A kstat_t *ksp;
8922N/A- kstat_ctl_t *kc;
8922N/A+ /* use the kc installed in server, don't need to create again,
8922N/A+ it will save some time and improve performance */
8922N/A+ kstat_ctl_t * const kc = server->machine.kc;
9311N/A+ /* use flags as a check condition, if it is 1, check, or not check... zhua */
8922N/A+ int check = buf->flags;
9311N/A+ /* set flags back to 0 */
9311N/A+ buf->flags = 0;
8922N/A
8922N/A glibtop_init_s (&server, GLIBTOP_SYSDEPS_NETLIST, 0);
8922N/A
9311N/A@@ -49,9 +55,9 @@ glibtop_get_netlist_s (glibtop *server,
8922N/A
8922N/A devices = g_ptr_array_new();
8922N/A
8922N/A- kc = kstat_open();
8922N/A if (kc == NULL) {
8922N/A glibtop_warn_io_r(server, "kstat_open()");
8922N/A+ buf->number = 0;
8922N/A return NULL;
8922N/A }
8922N/A
9311N/A@@ -60,12 +66,27 @@ glibtop_get_netlist_s (glibtop *server,
8922N/A if (strcmp(ksp->ks_class, "net") != 0)
8922N/A continue;
8922N/A
8922N/A- g_ptr_array_add(devices, g_strdup(ksp->ks_name));
8922N/A- buf->number++;
8922N/A+ /* do some check to see if the first character is the same between
8922N/A+ name and module, if not, we don't return it, because
8922N/A+ glibtop_get_netload() only want the same ones....
8922N/A+ */
8922N/A+ if (check){
8922N/A+ /* if the first character is not same, they should not
8922N/A+ the one we will use in glibtop_get_netload() */
8922N/A+ if (ksp->ks_name[0] != ksp->ks_module[0])
8922N/A+ continue;
8922N/A+ /* because in glibtop_get_netload(), name
8922N/A+ is at least 1 character longer than module */
8922N/A+ if (strlen( ksp->ks_module ) >= strlen( ksp->ks_name))
8922N/A+ continue;
8922N/A+ /* if it's not digital, continue directly */
8922N/A+ if( !isdigit( (int) ksp->ks_name[strlen( ksp->ks_module )] ))
8922N/A+ continue;
8922N/A+ }
8922N/A+ g_ptr_array_add(devices, g_strdup(ksp->ks_name));
8922N/A+ buf->number++;
8922N/A }
8922N/A
8922N/A- kstat_close(kc);
8922N/A-
8922N/A buf->flags = _glibtop_sysdeps_netlist;
8922N/A
8922N/A g_ptr_array_add(devices, NULL);
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/netload.c libgtop-2.14.4.mod/sysdeps/solaris/netload.c
9311N/A--- libgtop-2.14.4/sysdeps/solaris/netload.c 2005-12-12 18:09:40.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/netload.c 2006-11-13 20:28:00.177150000 +0800
8922N/A@@ -26,14 +26,247 @@
8402N/A #include <glibtop/error.h>
8402N/A #include <glibtop/netload.h>
8402N/A
8402N/A-static const unsigned long _glibtop_sysdeps_netload = 0;
8402N/A+#include "glibtop_private.h"
8402N/A+
8402N/A+#include <errno.h>
8402N/A+#include <string.h>
8922N/A+#include <kstat.h>
8402N/A+
8402N/A+#include <sys/types.h>
8402N/A+#include <sys/socket.h>
8402N/A+#include <sys/ioctl.h>
8402N/A+#include <sys/sockio.h>
8402N/A+
8402N/A+//#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
8402N/A+/* GNU LibC */
8402N/A+#include <net/if.h>
8402N/A+
8402N/A+#ifdef HAVE_IFADDRS_H
8402N/A+/* needed for IPV6 support */
8402N/A+
8402N/A+#include <ifaddrs.h>
8402N/A+
8402N/A+#ifndef IN6_IS_ADDR_GLOBAL
8402N/A+#define IN6_IS_ADDR_GLOBAL(a) \
8402N/A+ (((((__const uint8_t *) (a))[0] & 0xff) == 0x3f \
8402N/A+ || (((__const uint8_t *) (a))[0] & 0xff) == 0x20))
8402N/A+#endif
8402N/A+#endif /* HAVE_IFADDRS_H */
8402N/A+
8402N/A+static const unsigned long _glibtop_sysdeps_netload =
8402N/A+(1L << GLIBTOP_NETLOAD_ERRORS_IN) +
8402N/A+(1L << GLIBTOP_NETLOAD_ERRORS_OUT) +
8402N/A+(1L << GLIBTOP_NETLOAD_COLLISIONS);
8402N/A+
8402N/A+static const unsigned long _glibtop_sysdeps_netload_data =
8402N/A+(1L << GLIBTOP_NETLOAD_ADDRESS) +
8402N/A+(1L << GLIBTOP_NETLOAD_SUBNET) +
8402N/A+(1L << GLIBTOP_NETLOAD_MTU);
8402N/A+
8402N/A+static const unsigned long _glibtop_sysdeps_netload_bytes =
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_IN) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_OUT) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL);
8402N/A+
8402N/A+static const unsigned long _glibtop_sysdeps_netload_packets =
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_IN) +
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_OUT) +
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL);
8402N/A+
8402N/A+static const unsigned long _glibtop_sysdeps_netload_total =
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL);
8402N/A+
8402N/A+static const unsigned long _glibtop_sysdeps_netload_in =
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) +
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_IN) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_IN);
8402N/A+
8402N/A+static const unsigned long _glibtop_sysdeps_netload_out =
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) +
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_OUT) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_OUT);
8402N/A+
8402N/A+static const unsigned long _glibtop_sysdeps_netload_6 =
8402N/A+(1L << GLIBTOP_NETLOAD_ADDRESS6) +
8402N/A+(1L << GLIBTOP_NETLOAD_PREFIX6) +
8402N/A+(1L << GLIBTOP_NETLOAD_SCOPE6);
8402N/A+
8402N/A
8402N/A /* Init function. */
8402N/A
8402N/A void
8402N/A glibtop_init_netload_s (glibtop *server)
8402N/A {
8402N/A- server->sysdeps.netload = _glibtop_sysdeps_netload;
8402N/A+ server->sysdeps.netload = _glibtop_sysdeps_netload |
8402N/A+ _glibtop_sysdeps_netload_bytes |
8402N/A+ _glibtop_sysdeps_netload_packets;
8402N/A+}
8402N/A+
8402N/A+
8402N/A+#ifdef HAVE_IFADDRS_H
8402N/A+
8402N/A+static void get_ipv6(glibtop *server, glibtop_netload *buf,
8402N/A+ const char *interface)
8402N/A+{
8922N/A+/*
8922N/A+ * remove this code, because they are not available at Solaris, but keep them here for reference.
8922N/A+ * in fact, the function will not be called at Solaris, because HAVE_IFADDRS_H don't def.
8922N/A+ *
8922N/A+*/
8922N/A+#if 0
8402N/A+ struct ifaddrs *ifa0, *ifr6;
8402N/A+
8402N/A+ if(getifaddrs (&ifa0) != 0)
8402N/A+ {
8402N/A+ glibtop_warn_r(server, "getifaddrs failed : %s", g_strerror(errno));
8402N/A+ return;
8402N/A+ }
8402N/A+
8402N/A+ for (ifr6 = ifa0; ifr6; ifr6 = ifr6->ifa_next) {
8402N/A+ if (strcmp (ifr6->ifa_name, interface) == 0
8402N/A+ && ifr6->ifa_addr != NULL
8402N/A+ && ifr6->ifa_addr->sa_family == AF_INET6)
8402N/A+ break;
8402N/A+ }
8402N/A+
8402N/A+ if(!ifr6) goto free_ipv6;
8402N/A+
8402N/A+ memcpy(buf->address6,
8402N/A+ &((struct sockaddr_in6 *) ifr6->ifa_addr)->sin6_addr,
8402N/A+ 16);
8402N/A+
8402N/A+ memcpy(buf->prefix6,
8402N/A+ &((struct sockaddr_in6 *) ifr6->ifa_netmask)->sin6_addr,
8402N/A+ 16);
8402N/A+
8402N/A+
8402N/A+ if (IN6_IS_ADDR_LINKLOCAL (buf->address6))
8402N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_LINK;
8402N/A+
8402N/A+ else if (IN6_IS_ADDR_SITELOCAL (buf->address6))
8402N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_SITE;
8402N/A+
8402N/A+ else if (IN6_IS_ADDR_GLOBAL (buf->address6)
8402N/A+ || IN6_IS_ADDR_MC_ORGLOCAL (buf->address6)
8402N/A+ || IN6_IS_ADDR_V4COMPAT (buf->address6)
8402N/A+ || IN6_IS_ADDR_MULTICAST (buf->address6)
8402N/A+ || IN6_IS_ADDR_UNSPECIFIED (buf->address6)
8402N/A+ )
8402N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_GLOBAL;
8402N/A+
8402N/A+ else if (IN6_IS_ADDR_LOOPBACK (buf->address6))
8402N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_HOST;
8402N/A+
8402N/A+ else
8402N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_UNKNOWN;
8402N/A+
8402N/A+ buf->flags |= _glibtop_sysdeps_netload_6;
8402N/A+
8402N/A+ free_ipv6:
8402N/A+ freeifaddrs(ifa0);
8922N/A+#endif
8402N/A+}
8402N/A+
8402N/A+#endif /* HAVE_IFADDRS_H */
8402N/A+
8402N/A+
8402N/A+
8402N/A+static int
8402N/A+solaris_stats(glibtop *server,
8402N/A+ glibtop_netload *buf,
8402N/A+ const char *interface)
8402N/A+{
8402N/A+ char *name = interface;
8402N/A+ char *module;
8402N/A+ char *ptr;
8922N/A+ kstat_ctl_t * const kctl = server->machine.kc;
8402N/A+ kstat_t *ksp;
8402N/A+ kstat_named_t *kdata;
8402N/A+ int have_bytes = 1;
8402N/A+
8402N/A+ /*
8402N/A+ * chop off the trailing interface and
8402N/A+ */
8402N/A+ module = strdup( name );
8402N/A+ ptr = module + strlen( module ) - 1;
8402N/A+ while( (ptr > module) && isdigit( (int) *ptr ) ) {
8402N/A+ *ptr = '\0';
8402N/A+ ptr--;
8402N/A+ }
8402N/A+
8402N/A+ /*
8402N/A+ * get a kstat handle and update the user's kstat chain
8402N/A+ */
8922N/A+ if( kctl == NULL ){
8402N/A+ glibtop_warn_io_r (server, "kstat_open ()");
8402N/A+ free( module );
8402N/A+ return( 0 );
8402N/A+ }
8402N/A+ while( kstat_chain_update( kctl ) != 0 )
8402N/A+ ;
8402N/A+
8402N/A+ /*
8402N/A+ * traverse the kstat chain
8402N/A+ * to find the appropriate statistics
8402N/A+ */
8402N/A+ if( (ksp = kstat_lookup( kctl,
8402N/A+ module, 0, name )) == NULL ) {
8402N/A+ free( module );
8402N/A+ return( 0 );
8402N/A+ }
8402N/A+ if( kstat_read( kctl, ksp, NULL ) == -1 ) {
8402N/A+ free( module );
8402N/A+ return( 0 );
8402N/A+ }
8402N/A+ free( module );
8402N/A+
8402N/A+ /*
8402N/A+ * lookup & store the data
8402N/A+ */
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "ipackets" );
8402N/A+ if( kdata != NULL ) {
8402N/A+ buf->packets_in= kdata->value.ul;
8402N/A+ }
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "opackets" );
8402N/A+ if( kdata != NULL ) {
8402N/A+ buf->packets_out = kdata->value.ul;
8402N/A+ }
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "rbytes" );
8402N/A+ if( kdata != NULL ) {
8402N/A+ buf->bytes_in =kdata->value.ul;
8402N/A+ }
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "obytes" );
8402N/A+ if( kdata != NULL ) {
8402N/A+ buf->bytes_out =kdata->value.ul;
8402N/A+ }
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "ierrors" );
8402N/A+ if( kdata != NULL ) {
8402N/A+ buf->errors_in = kdata->value.ul;
8402N/A+ }
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "oerrors" );
8402N/A+ if( kdata != NULL ) {
8402N/A+ buf->errors_out = kdata->value.ul;
8402N/A+ }
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "collisions" );
8402N/A+ if( kdata != NULL ) {
8402N/A+ buf->collisions = kdata->value.ul;
8402N/A+ }
8402N/A+
8402N/A+ /* Compute total valules. */
8402N/A+
8402N/A+ buf->bytes_total = buf->bytes_in + buf->bytes_out;
8402N/A+ buf->packets_total = buf->packets_in + buf->packets_out;
8402N/A+ buf->errors_total = buf->errors_in + buf->errors_out;
8402N/A+ /* And now the flags. */
8402N/A+ buf->flags |= _glibtop_sysdeps_netload;
8402N/A+ buf->flags |= _glibtop_sysdeps_netload_bytes;
8402N/A+ buf->flags |= _glibtop_sysdeps_netload_packets;
8402N/A+
8402N/A+ /* finished */
8402N/A+
8402N/A }
8402N/A
8402N/A /* Provides network statistics. */
8922N/A@@ -42,5 +275,73 @@ void
8402N/A glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
8402N/A const char *interface)
8402N/A {
8402N/A- memset (buf, 0, sizeof (glibtop_netload));
8402N/A+ int skfd;
8402N/A+ memset (buf, 0, sizeof (glibtop_netload));
8402N/A+
8402N/A+ /* set flag */
8402N/A+ skfd = socket (PF_INET, SOCK_DGRAM, 0);
8402N/A+ if (skfd) {
8402N/A+ struct ifreq ifr;
8402N/A+
8402N/A+ g_strlcpy (ifr.ifr_name, interface, sizeof ifr.ifr_name);
8402N/A+ if (ioctl (skfd, SIOCGIFFLAGS, &ifr) >= 0) {
8402N/A+ const unsigned long long flags = ifr.ifr_flags;
8402N/A+
8402N/A+ buf->flags |= (1L << GLIBTOP_NETLOAD_IF_FLAGS);
8402N/A+
8402N/A+ if (flags & IFF_UP)
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_UP);
8402N/A+
8402N/A+ if (flags & IFF_BROADCAST)
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_BROADCAST);
8402N/A+
8402N/A+ if (flags & IFF_DEBUG)
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_DEBUG);
8402N/A+
8402N/A+ if (flags & IFF_LOOPBACK)
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_LOOPBACK);
8402N/A+
8402N/A+ if (flags & IFF_POINTOPOINT)
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_POINTOPOINT);
8402N/A+
8402N/A+ if (flags & IFF_RUNNING)
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_RUNNING);
8402N/A+
8402N/A+ if (flags & IFF_NOARP)
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_NOARP);
8402N/A+
8402N/A+ if (flags & IFF_PROMISC)
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_PROMISC);
8402N/A+
8402N/A+ if (flags & IFF_ALLMULTI)
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_ALLMULTI);
8402N/A+
8402N/A+ if (flags & IFF_MULTICAST)
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_MULTICAST);
8402N/A+ }
8402N/A+
8402N/A+ g_strlcpy (ifr.ifr_name, interface, sizeof ifr.ifr_name);
8402N/A+ if (!ioctl (skfd, SIOCGIFADDR, &ifr)) {
8402N/A+ buf->address = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr;
8402N/A+ buf->flags |= (1L << GLIBTOP_NETLOAD_ADDRESS);
8402N/A+ }
8402N/A+
8402N/A+ g_strlcpy (ifr.ifr_name, interface, sizeof ifr.ifr_name);
8402N/A+ if (!ioctl (skfd, SIOCGIFNETMASK, &ifr)) {
8402N/A+ buf->subnet = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr;
8402N/A+ buf->flags |= (1L << GLIBTOP_NETLOAD_SUBNET);
8402N/A+ }
8402N/A+ close (skfd);
8402N/A+ }
8402N/A+
8402N/A+ /*
8402N/A+ * Statistics
8402N/A+ */
8402N/A+
8402N/A+ solaris_stats(server, buf, interface);
8402N/A+
8402N/A+#ifdef HAVE_IFADDRS_H
8402N/A+ get_ipv6(server, buf, interface);
8402N/A+#endif /* HAVE_IFADDRS_H */
8402N/A }
8402N/A+
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/open.c libgtop-2.14.4.mod/sysdeps/solaris/open.c
9311N/A--- libgtop-2.14.4/sysdeps/solaris/open.c 2006-06-25 01:39:49.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/open.c 2006-11-13 20:28:00.178413000 +0800
8922N/A@@ -211,34 +211,5 @@ glibtop_open_s (glibtop *server, const c
8922N/A }
8922N/A }
8922N/A
8922N/A- /* Now let's have a bit of magic dust... */
8922N/A-
8922N/A-#if GLIBTOP_SOLARIS_RELEASE >= 50600
8922N/A-
8922N/A- dl = dlopen("/usr/lib/libproc.so", RTLD_LAZY);
8922N/A- if(server->machine.libproc)
8922N/A- dlclose(server->machine.libproc);
8922N/A- server->machine.libproc = dl;
8922N/A- if(dl)
8922N/A- {
8922N/A- void *func;
8922N/A-
8922N/A- func = dlsym(dl, "Pobjname"); /* Solaris 8 */
8922N/A- if(!func)
8922N/A- func = dlsym(dl, "proc_objname"); /* Solaris 7 */
8922N/A- server->machine.objname = (void (*)
8922N/A- (void *, uintptr_t, const char *, size_t))func;
8922N/A- server->machine.pgrab = (struct ps_prochandle *(*)(pid_t, int, int *))
8922N/A- dlsym(dl, "Pgrab");
8922N/A- server->machine.pfree = (void (*)(void *))dlsym(dl, "Pfree");
8922N/A-
8922N/A- }
8922N/A- else
8922N/A- {
8922N/A- server->machine.objname = NULL;
8922N/A- server->machine.pgrab = NULL;
8922N/A- server->machine.pfree = NULL;
8922N/A- }
8922N/A-#endif
8922N/A server->machine.me = getpid();
8922N/A }
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/procmap.c libgtop-2.14.4.mod/sysdeps/solaris/procmap.c
9311N/A--- libgtop-2.14.4/sysdeps/solaris/procmap.c 2006-06-25 01:45:29.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/procmap.c 2006-11-13 21:43:09.817707000 +0800
9311N/A@@ -56,6 +56,12 @@ glibtop_map_entry *
8402N/A glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
8402N/A {
8402N/A int fd, i, nmaps, pr_err, heap;
8922N/A+ char filename [BUFSIZ];
9311N/A+ /* use flags as a check condition, if it is 1, check, or, not check... zhua */
9311N/A+ int check = buf->flags;
9311N/A+ /* set flags back to 0 */
9311N/A+ buf->flags = 0;
9311N/A+
8575N/A #if GLIBTOP_SOLARIS_RELEASE >= 50600
8402N/A prxmap_t *maps;
8402N/A struct ps_prochandle *Pr = NULL;
9311N/A@@ -125,15 +131,29 @@ glibtop_get_proc_map_s (glibtop *server,
8402N/A buf->total = nmaps * sizeof(glibtop_map_entry);
8402N/A entry = g_malloc0(buf->total);
8402N/A
8575N/A-#if GLIBTOP_SOLARIS_RELEASE >= 50600
8402N/A-
8402N/A- if(server->machine.objname && server->machine.pgrab &&
8402N/A- server->machine.pfree)
8402N/A- Pr = (server->machine.pgrab)(pid, 1, &pr_err);
8402N/A-#endif
8402N/A for(heap = 0,i = 0; i < nmaps; ++i)
8402N/A {
8402N/A- int len;
9311N/A+ /* take a check to see if we need all information, if not, just get what we need..
9311N/A+ Also please see comments in get_process_memory_writable() of gnome-system-monitor zhua */
9311N/A+ if (check == 1)
9311N/A+ {
9311N/A+ if(maps[i].pr_mflags & MA_WRITE){
9311N/A+ entry[i].perm |= GLIBTOP_MAP_PERM_WRITE;
9311N/A+ entry[i].size = maps[i].pr_size;
9311N/A+ }
9311N/A+ }
9311N/A+ else
9311N/A+ if (check == 2)
9311N/A+ {
9311N/A+ if(maps[i].pr_mflags & MA_SHARED){
9311N/A+ entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
9311N/A+ /* here use shared_clean to store Shared Memory */
9311N/A+ entry[i].shared_clean = maps[i].pr_size;
9311N/A+ }
9311N/A+ }
9311N/A+ else {
9311N/A+
8402N/A+ int len, rv;
8402N/A
8402N/A entry[i].start = maps[i].pr_vaddr;
8402N/A entry[i].end = maps[i].pr_vaddr + maps[i].pr_size;
9311N/A@@ -156,8 +176,12 @@ glibtop_get_proc_map_s (glibtop *server,
8922N/A }
8922N/A if(maps[i].pr_mflags & MA_EXEC)
8402N/A entry[i].perm |= GLIBTOP_MAP_PERM_EXECUTE;
8922N/A- if(maps[i].pr_mflags & MA_SHARED)
8922N/A- entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
8922N/A+ if(maps[i].pr_mflags & MA_SHARED){
8922N/A+ entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
8922N/A+ /* here use shared_clean to store Shared Memory */
8922N/A+ entry[i].shared_clean = maps[i].pr_size;
8922N/A+ }
8922N/A+
8402N/A else
8402N/A entry[i].perm |= GLIBTOP_MAP_PERM_PRIVATE;
8402N/A entry[i].flags = _glibtop_sysdeps_map_entry;
9311N/A@@ -179,25 +203,25 @@ glibtop_get_proc_map_s (glibtop *server,
8402N/A entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
8402N/A }
8402N/A else
8402N/A- if(Pr)
8402N/A- {
8402N/A- server->machine.objname(Pr, maps[i].pr_vaddr, buffer,
8402N/A- BUFSIZ);
8402N/A- if((len = resolvepath(buffer, entry[i].filename,
8402N/A- GLIBTOP_MAP_FILENAME_LEN)) > 0)
8402N/A- {
8402N/A- entry[i].filename[len] = 0;
8402N/A- entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
8402N/A- }
8402N/A- }
8922N/A+ {
8922N/A+ strcpy(buffer, maps[i].pr_mapname);
8922N/A+ /* from /path get file name */
8922N/A+ g_snprintf(filename, sizeof filename, "/proc/%d/path/%s",
8922N/A+ pid, buffer);
8922N/A+
8922N/A+ rv = readlink(filename, entry[i].filename, sizeof(entry[i].filename) - 1);
8922N/A+ /* read object, if have not, set it as NULL */
8922N/A+ if(rv < 0)
8922N/A+ rv = 0;
8922N/A+ entry[i].filename[rv] = '\0';
8922N/A+ /* now set the flags */
8922N/A+ entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
8922N/A+ }
8402N/A+
8402N/A #endif
9311N/A+ } /* end of else check */
8402N/A }
8402N/A
8575N/A-#if GLIBTOP_SOLARIS_RELEASE >= 50600
8402N/A-
8402N/A- if(Pr)
8402N/A- server->machine.pfree(Pr);
8402N/A-#endif
8402N/A buf->flags = _glibtop_sysdeps_proc_map;
8402N/A s_close(fd);
8402N/A return entry;
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/procmem.c libgtop-2.14.4.mod/sysdeps/solaris/procmem.c
9311N/A--- libgtop-2.14.4/sysdeps/solaris/procmem.c 2005-12-12 18:09:40.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/procmem.c 2006-11-13 21:57:58.082161000 +0800
8402N/A@@ -24,6 +24,7 @@
8402N/A #include <config.h>
8402N/A #include <glibtop.h>
8402N/A #include <glibtop/procmem.h>
8402N/A+#include <glibtop/procmap.h>
8402N/A
8402N/A #include "glibtop_private.h"
8402N/A
9311N/A@@ -59,9 +60,38 @@ glibtop_get_proc_mem_s (glibtop *server,
8402N/A #ifdef HAVE_PROCFS_H
8402N/A buf->size = buf->vsize = psinfo.pr_size << 10;
8402N/A buf->resident = buf->rss = psinfo.pr_rssize << 10;
8922N/A+ buf->load = (guint) psinfo.pr_lwp.pr_pctcpu * 100 / (guint) 0x8000;
8402N/A #else
8402N/A buf->size = buf->vsize = psinfo.pr_size << pagesize << 10;
8402N/A buf->resident = buf->rss = psinfo.pr_rssize << pagesize << 10;
8922N/A+ buf->load = (guint) psinfo.pr_lwp.pr_pctcpu * 100 / (guint) 0x8000;
8402N/A #endif
8922N/A+
8402N/A+/* get Shared Memory */
8922N/A+ glibtop_proc_map mapbuf;
8922N/A+ glibtop_map_entry *maps;
8922N/A+ unsigned i;
8922N/A+ buf->share = 0;
9311N/A+
9311N/A+ /* we have to optimize the performance of libgtop, because update the information will occupy too much cpu.
9311N/A+
9311N/A+ here I would like to make a little update:set glibtop_proc_map.flags=1,so as to let glibtop_get_proc_map_s()
9311N/A+ only return the ones this function need: memwritable
9311N/A+
9311N/A+ we do the check in glibtop_get_proc_map_s(), don't run the others part which don't need by this function,
9311N/A+ I think this will accelerate the transaction lots,
9311N/A+ Also this will not affect the existing codes, because when nobody set glibtop_proc_map.flags,
9311N/A+ glibtop_get_proc_map() will return all as before. zhua
9311N/A+ */
9311N/A+ mapbuf.flags = 2;
8922N/A+
8922N/A+ maps = glibtop_get_proc_map_s(server, &mapbuf, pid);
8922N/A+
8922N/A+ for (i = 0; i < mapbuf.number; ++i) {
8922N/A+ if (maps[i].perm & GLIBTOP_MAP_PERM_SHARED)
8922N/A+ buf->share += maps[i].shared_clean;
8922N/A+ }
8922N/A+ g_free(maps);
8922N/A+
8402N/A buf->flags = _glibtop_sysdeps_proc_mem;
8402N/A }
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/proctime.c libgtop-2.14.4.mod/sysdeps/solaris/proctime.c
9311N/A--- libgtop-2.14.4/sysdeps/solaris/proctime.c 2006-06-25 01:47:34.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/proctime.c 2006-11-13 20:28:00.179929000 +0800
8922N/A@@ -45,8 +45,12 @@ void
8922N/A glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf,
8922N/A pid_t pid)
8922N/A {
8922N/A+#ifdef HAVE_PROCFS_H
8922N/A+ struct psinfo pinfo;
8922N/A+#else
8922N/A+ struct prpsinfo pinfo;
8922N/A+#endif
8922N/A struct prusage prusage;
8922N/A- GTimeVal time;
8922N/A
8922N/A memset (buf, 0, sizeof (glibtop_proc_time));
8922N/A
8922N/A@@ -54,19 +58,18 @@ glibtop_get_proc_time_s (glibtop *server
8922N/A
8922N/A if(pid)
8922N/A {
8922N/A+ if (glibtop_get_proc_data_psinfo_s(server, &pinfo, pid))
8922N/A+ return;
8922N/A+ buf->start_time = pinfo.pr_start.tv_sec;
8922N/A+
8922N/A if (glibtop_get_proc_data_usage_s (server, &prusage, pid))
8922N/A return;
8922N/A
8922N/A- g_get_current_time (&time);
8922N/A- /* prusage.pr_rtime.tv_sec is the during that the process existed */
8922N/A- buf->start_time = time.tv_sec - prusage.pr_rtime.tv_sec;
8922N/A-
8922N/A- buf->rtime = prusage.pr_rtime.tv_sec * 1E+6 +
8922N/A- prusage.pr_rtime.tv_nsec / 1E+3;
8922N/A buf->utime = prusage.pr_utime.tv_sec * 1E+6 +
8922N/A prusage.pr_utime.tv_nsec / 1E+3;
8922N/A buf->stime = prusage.pr_stime.tv_sec * 1E+6 +
8922N/A prusage.pr_stime.tv_nsec / 1E+3;
8922N/A+ buf->rtime = (buf->utime + buf->stime) / 10000;
8922N/A }
8922N/A
8922N/A buf->flags = _glibtop_sysdeps_proc_time;
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/sem_limits.c libgtop-2.14.4.mod/sysdeps/solaris/sem_limits.c
9311N/A--- libgtop-2.14.4/sysdeps/solaris/sem_limits.c 2006-06-25 01:16:53.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/sem_limits.c 2006-11-13 20:28:00.179799000 +0800
8922N/A@@ -41,14 +41,22 @@ static const unsigned long _glibtop_sysd
8922N/A (1L << GLIBTOP_IPC_SEMUSZ) + (1L << GLIBTOP_IPC_SEMVMX) +
8922N/A (1L << GLIBTOP_IPC_SEMAEM);
8922N/A #else
8922N/A-static const unsigned long _glibtop_sysdeps_sem_limits = 0;
8922N/A+static const unsigned long _glibtop_sysdeps_sem_limits =
8922N/A+(1L << GLIBTOP_IPC_SEMMNI) +
8922N/A+(1L << GLIBTOP_IPC_SEMMSL) +
8922N/A+(1L << GLIBTOP_IPC_SEMOPM);
8922N/A #endif
8922N/A
8922N/A
8922N/A /* Init function. */
8922N/A
8922N/A+#if GLIBTOP_SUID_SEM_LIMITS
8922N/A void
8922N/A glibtop_init_sem_limits_p (glibtop *server)
8922N/A+#else
8922N/A+void
8922N/A+glibtop_init_sem_limits_s (glibtop *server)
8922N/A+#endif
8922N/A {
8922N/A #if GLIBTOP_SOLARIS_RELEASE < 51000
8922N/A
8922N/A@@ -63,8 +71,13 @@ glibtop_init_sem_limits_p (glibtop *serv
8922N/A
8922N/A /* Provides information about sysv sem limits. */
8922N/A
8922N/A+#if GLIBTOP_SUID_SEM_LIMITS
8922N/A void
8922N/A glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
8922N/A+#else
8922N/A+void
8922N/A+glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
8922N/A+#endif
8922N/A {
8922N/A #if GLIBTOP_SOLARIS_RELEASE < 51000
8922N/A kvm_t *kd = server->machine.kd;
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/shm_limits.c libgtop-2.14.4.mod/sysdeps/solaris/shm_limits.c
9311N/A--- libgtop-2.14.4/sysdeps/solaris/shm_limits.c 2006-06-25 01:16:53.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/shm_limits.c 2006-11-13 20:28:00.175514000 +0800
8922N/A@@ -32,7 +32,9 @@
8922N/A static const struct nlist nlst[] = { {"glibtop_shm_limits"}, {NULL} };
8922N/A
8922N/A #if GLIBTOP_SOLARIS_RELEASE >=51000
8922N/A-static const unsigned long _glibtop_sysdeps_shm_limits = 0;
8922N/A+static const unsigned long _glibtop_sysdeps_shm_limits =
8922N/A+(1L << GLIBTOP_IPC_SHMMAX) +
8922N/A+(1L << GLIBTOP_IPC_SHMMIN);
8922N/A #else
8922N/A # if GLIBTOP_SOLARIS_RELEASE < 50900
8922N/A static const unsigned long _glibtop_sysdeps_shm_limits =
8922N/A@@ -47,8 +49,13 @@ static const unsigned long _glibtop_sysd
8922N/A
8922N/A /* Init function. */
8922N/A
8922N/A+#if GLIBTOP_SUID_SHM_LIMITS
8922N/A void
8922N/A glibtop_init_shm_limits_p (glibtop *server)
8922N/A+#else
8922N/A+void
8922N/A+glibtop_init_shm_limits_s (glibtop *server)
8922N/A+#endif
8922N/A {
8922N/A #if GLIBTOP_SOLARIS_RELEASE < 51000
8922N/A
8922N/A@@ -63,8 +70,13 @@ glibtop_init_shm_limits_p (glibtop *serv
8922N/A
8922N/A /* Provides information about sysv ipc limits. */
8922N/A
8922N/A+#if GLIBTOP_SUID_SHM_LIMITS
8922N/A void
8922N/A glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
8922N/A+#else
8922N/A+void
8922N/A+glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
8922N/A+#endif
8922N/A {
8922N/A #if GLIBTOP_SOLARIS_RELEASE < 51000
8922N/A
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/siglist.c libgtop-2.14.4.mod/sysdeps/solaris/siglist.c
9311N/A--- libgtop-2.14.4/sysdeps/solaris/siglist.c 2005-12-12 18:09:40.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/siglist.c 2006-11-13 20:28:00.180643000 +0800
8922N/A@@ -63,6 +63,7 @@ const glibtop_signame glibtop_sys_siglis
8402N/A { 35, "SIGTHAW", "Checkpoint Thaw" },
8402N/A { 36, "SIGCANCEL","Thread Cancelation" },
8402N/A { 37, "SIGLOST", "Resource Lost" },
8402N/A+#if GLIBTOP_SOLARIS_RELEASE < 50900 /* S8 */
8402N/A { 38, "SIGRTMIN","First Realtime Signal" },
8402N/A { 39, "SIGRTMIN+1", "Second Realtime Signal" },
8402N/A { 40, "SIGRTMIN+2", "Third Realtime Signal" },
8922N/A@@ -71,5 +72,30 @@ const glibtop_signame glibtop_sys_siglis
8402N/A { 43, "SIGRTMAX-2", "Third Last Realtime Signal" },
8402N/A { 44, "SIGRTMAX-1", "Second Last Realtime Signal" },
8402N/A { 45, "SIGRTMAX", "Last Realtime Signal" },
8402N/A+#endif
8402N/A+#if GLIBTOP_SOLARIS_RELEASE >= 50900
8402N/A+ { 38, "SIGXRES","Resource Control Exceeded" },
8402N/A+#if GLIBTOP_SOLARIS_RELEASE <51000 /* signal here existed in s9 */
8402N/A+ { 39, "SIGRTMIN","First Realtime Signal" },
8402N/A+ { 40, "SIGRTMIN+1", "Second Realtime Signal" },
8402N/A+ { 41, "SIGRTMIN+2", "Third Realtime Signal" },
8402N/A+ { 42, "SIGRTMIN+3", "Fourth Realtime Signal" },
8402N/A+ { 43, "SIGRTMAX-3", "Fourth Last Realtime Signal" },
8402N/A+ { 44, "SIGRTMAX-2", "Third Last Realtime Signal" },
8402N/A+ { 45, "SIGRTMAX-1", "Second Last Realtime Signal" },
8402N/A+ { 46, "SIGRTMAX", "Last Realtime Signal" },
8402N/A+#else /* signal here existed in s10 and s11 */
8402N/A+ { 39, "SIGJVM1","Reserved signal for Java Virtual Machine" },
8402N/A+ { 40, "SIGJVM1","Reserved signal for Java Virtual Machine" },
8402N/A+ { 41, "SIGRTMIN","First Realtime Signal" },
8402N/A+ { 42, "SIGRTMIN+1", "Second Realtime Signal" },
8402N/A+ { 43, "SIGRTMIN+2", "Third Realtime Signal" },
8402N/A+ { 44, "SIGRTMIN+3", "Fourth Realtime Signal" },
8402N/A+ { 45, "SIGRTMAX-3", "Fourth Last Realtime Signal" },
8402N/A+ { 46, "SIGRTMAX-2", "Third Last Realtime Signal" },
8402N/A+ { 47, "SIGRTMAX-1", "Second Last Realtime Signal" },
8402N/A+ { 48, "SIGRTMAX", "Last Realtime Signal" },
8402N/A+#endif
8402N/A+#endif
8402N/A { 0, NULL, NULL }
8402N/A };
9311N/Adiff -Nrup libgtop-2.14.4/sysdeps/solaris/sysinfo.c libgtop-2.14.4.mod/sysdeps/solaris/sysinfo.c
9311N/A--- libgtop-2.14.4/sysdeps/solaris/sysinfo.c 1970-01-01 08:00:00.000000000 +0800
9311N/A+++ libgtop-2.14.4.mod/sysdeps/solaris/sysinfo.c 2006-11-13 20:28:00.181313000 +0800
8402N/A@@ -0,0 +1,48 @@
8402N/A+/* $Id: sysinfo.c,v 1.22 2004/11/28 01:32:55 bdejean Exp $ */
8402N/A+
8402N/A+/* Copyright (C) 1998-99 Martin Baulig
8402N/A+ This file is part of LibGTop 1.0.
8402N/A+
8402N/A+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
8402N/A+
8402N/A+ LibGTop is free software; you can redistribute it and/or modify it
8402N/A+ under the terms of the GNU General Public License as published by
8402N/A+ the Free Software Foundation; either version 2 of the License,
8402N/A+ or (at your option) any later version.
8402N/A+
8402N/A+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
8402N/A+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8402N/A+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8402N/A+ for more details.
8402N/A+
8402N/A+ You should have received a copy of the GNU General Public License
8402N/A+ along with LibGTop; see the file COPYING. If not, write to the
8402N/A+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
8402N/A+ Boston, MA 02111-1307, USA.
8402N/A+*/
8402N/A+
8402N/A+#include <config.h>
8402N/A+#include <glibtop/error.h>
8402N/A+#include <glibtop/cpu.h>
8402N/A+#include <glibtop/sysinfo.h>
8402N/A+
8402N/A+#include "glibtop_private.h"
8402N/A+
8402N/A+
8402N/A+static const unsigned long _glibtop_sysdeps_sysinfo =
8402N/A+(1L << GLIBTOP_SYSINFO_CPUINFO);
8402N/A+
8402N/A+static glibtop_sysinfo sysinfo = { .flags = 0 };
8402N/A+
8402N/A+static void
8402N/A+init_sysinfo (glibtop *server)
8402N/A+{
8402N/A+
8402N/A+}
8402N/A+
8402N/A+const glibtop_sysinfo *
8402N/A+glibtop_get_sysinfo_s (glibtop *server)
8402N/A+{
8402N/A+ init_sysinfo (server);
8402N/A+ return &sysinfo;
8402N/A+}