patches/libgtop-01-solaris.diff
author dcarbery
Mon, 21 Jan 2008 15:14:59 +0000
changeset 11494 fa94717ac3e3
parent 11477 18198fb39803
child 13197 7c6e36efe0d8
permissions -rw-r--r--
2008-01-21 Damien Carbery <[email protected]> * base-specs/libgtop.spec: Revert to 2.20.1 because of build issues and module owner choosing not to bump because of dependency issues with gnome-system-monitor. * patches/libgtop-01-solaris.diff: Revert to 2.20.1 version.

diff -Nrup libgtop-2.19.2/include/glibtop/procstate.h libgtop-2.19.2.mod/include/glibtop/procstate.h
--- libgtop-2.19.2/include/glibtop/procstate.h	2007-04-27 06:27:30.000000000 +0800
+++ libgtop-2.19.2.mod/include/glibtop/procstate.h	2007-05-18 15:45:06.525673000 +0800
@@ -64,11 +64,19 @@ struct _glibtop_proc_state
 	 *                   fields if their values are corrent ! */
 	int uid;		/* UID of process */
 	int gid;		/* GID of process */
-    int ruid;
-    int rgid;
-    int has_cpu;
-    int processor;
-    int last_processor;
+    	int ruid;
+    	int rgid;
+    	int has_cpu;
+    	int processor;
+    	int last_processor;
+	
+        gint32  nice;           /*zhua: used to store nice */
+        guint64 start_time;     /* start time of process -- */
+        guint64 vsize;          /* number of pages of virtual memory ... */
+        guint64 resident;       /* number of resident set */
+        guint   load;           /* cpu load for process */
+        gint32  ppid;           /* pid of parent process */
+
 };
 
 void glibtop_get_proc_state(glibtop_proc_state *buf, pid_t pid);
diff -Nrup libgtop-2.19.2/lib/libgtop.sym libgtop-2.19.2.mod/lib/libgtop.sym
--- libgtop-2.19.2/lib/libgtop.sym	2007-05-13 05:54:57.000000000 +0800
+++ libgtop-2.19.2.mod/lib/libgtop.sym	2007-05-19 00:09:27.355595000 +0800
@@ -1,118 +1,89 @@
 glibtop_call_l
-glibtop_call_p
 glibtop_close
 glibtop_close_p
 glibtop_close_r
 glibtop_close_s
 glibtop_get_cpu
 glibtop_get_cpu_l
-glibtop_get_cpu_p
 glibtop_get_cpu_s
 glibtop_get_fsusage
 glibtop_get_fsusage_l
-glibtop_get_fsusage_p
 glibtop_get_fsusage_s
 glibtop_get_loadavg
 glibtop_get_loadavg_l
-glibtop_get_loadavg_p
 glibtop_get_loadavg_s
 glibtop_get_mem
 glibtop_get_mem_l
-glibtop_get_mem_p
 glibtop_get_mem_s
 glibtop_get_mountlist
 glibtop_get_mountlist_l
-glibtop_get_mountlist_p
 glibtop_get_mountlist_s
 glibtop_get_msg_limits
 glibtop_get_msg_limits_l
-glibtop_get_msg_limits_p
 glibtop_get_msg_limits_s
 glibtop_get_netlist
 glibtop_get_netlist_l
-glibtop_get_netlist_p
 glibtop_get_netlist_s
 glibtop_get_netload
 glibtop_get_netload_l
-glibtop_get_netload_p
 glibtop_get_netload_s
 glibtop_get_parameter_l
-glibtop_get_parameter_p
 glibtop_get_ppp
 glibtop_get_ppp_l
-glibtop_get_ppp_p
 glibtop_get_ppp_s
 glibtop_get_proc_args
 glibtop_get_proc_args_l
-glibtop_get_proc_args_p
 glibtop_get_proc_args_s
 glibtop_get_proc_argv
 glibtop_get_proc_argv_l
-glibtop_get_proc_argv_p
 glibtop_get_proc_kernel
 glibtop_get_proc_kernel_l
-glibtop_get_proc_kernel_p
 glibtop_get_proc_kernel_s
 glibtop_get_proclist
 glibtop_get_proclist_l
-glibtop_get_proclist_p
 glibtop_get_proclist_s
 glibtop_get_proc_map
 glibtop_get_proc_map_l
-glibtop_get_proc_map_p
 glibtop_get_proc_map_s
 glibtop_get_proc_mem
 glibtop_get_proc_mem_l
-glibtop_get_proc_mem_p
 glibtop_get_proc_mem_s
 glibtop_get_proc_open_files
 glibtop_get_proc_open_files_l
-glibtop_get_proc_open_files_p
 glibtop_get_proc_open_files_s
 glibtop_get_proc_segment
 glibtop_get_proc_segment_l
-glibtop_get_proc_segment_p
 glibtop_get_proc_segment_s
 glibtop_get_proc_signal
 glibtop_get_proc_signal_l
-glibtop_get_proc_signal_p
 glibtop_get_proc_signal_s
 glibtop_get_proc_state
 glibtop_get_proc_state_l
-glibtop_get_proc_state_p
 glibtop_get_proc_state_s
 glibtop_get_proc_time
 glibtop_get_proc_time_l
-glibtop_get_proc_time_p
 glibtop_get_proc_time_s
 glibtop_get_proc_uid
 glibtop_get_proc_uid_l
-glibtop_get_proc_uid_p
 glibtop_get_proc_uid_s
 glibtop_get_proc_wd
 glibtop_get_proc_wd_l
-glibtop_get_proc_wd_p
 glibtop_get_proc_wd_s
 glibtop_get_sem_limits
 glibtop_get_sem_limits_l
-glibtop_get_sem_limits_p
 glibtop_get_sem_limits_s
 glibtop_get_shm_limits
 glibtop_get_shm_limits_l
-glibtop_get_shm_limits_p
 glibtop_get_shm_limits_s
 glibtop_get_swap
 glibtop_get_swap_l
-glibtop_get_swap_p
 glibtop_get_swap_s
 glibtop_get_sysdeps
 glibtop_get_sysdeps_r
 glibtop_get_sysinfo
-glibtop_get_sysinfo_p
 glibtop_get_sysinfo_s
 glibtop_get_uptime
 glibtop_get_uptime_l
-glibtop_get_uptime_p
 glibtop_get_uptime_s
 glibtop_global_server
 glibtop_init
@@ -126,5 +97,4 @@ glibtop_open_p
 glibtop_open_s
 glibtop_server_features
 glibtop_set_parameter_l
-glibtop_set_parameter_p
 glibtop_sys_siglist
diff -Nrup libgtop-2.19.2/sysdeps/common/fsusage.c libgtop-2.19.2.mod/sysdeps/common/fsusage.c
--- libgtop-2.19.2/sysdeps/common/fsusage.c	2007-04-27 06:27:34.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/common/fsusage.c	2007-05-18 15:49:16.128329000 +0800
@@ -148,6 +148,15 @@ _glibtop_freebsd_get_fsusage_read_write(
 
 #define _glibtop_get_fsusage_read_write(S, B, P) \
 	_glibtop_freebsd_get_fsusage_read_write(S, B, P)
+	
+#elif (defined(sun) || defined(__sun))
+G_GNUC_INTERNAL void
+_glibtop_sun_get_fsusage_read_write(glibtop *server,
+					glibtop_fsusage *buf,
+					const char *path);
+
+#define _glibtop_get_fsusage_read_write(S, B, P) \
+	_glibtop_sun_get_fsusage_read_write(S, B, P)
 
 #else /* default fallback */
 #warning glibtop_get_fsusage .read .write are not implemented.
diff -Nrup libgtop-2.19.2/sysdeps/common/mountlist.c libgtop-2.19.2.mod/sysdeps/common/mountlist.c
--- libgtop-2.19.2/sysdeps/common/mountlist.c	2007-04-27 06:27:34.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/common/mountlist.c	2007-05-18 15:53:42.191233000 +0800
@@ -590,6 +590,17 @@ glibtop_get_mountlist_s (glibtop *server
 
 	for (cur = &entries[0]; cur != NULL; cur = next) {
 
+                /*zhua: delete these 2 type of fs: objfs,ctfs */
+                if (!strcmp(cur->me_type, "objfs") || !strcmp(cur->me_type,"ctfs")){
+                /* free current mount_entry and move to the next */
+                        next = cur->me_next;
+                        g_free(cur->me_devname);
+                        g_free(cur->me_mountdir);
+                        g_free(cur->me_type);
+                        g_free(cur);
+                        continue;
+                }
+
 		if(all_fs || !ignore_mount_entry(cur)) {
 			/* add a new glibtop_mountentry */
 			glibtop_mountentry e;
diff -Nrup libgtop-2.19.2/sysdeps/solaris/Makefile.am libgtop-2.19.2.mod/sysdeps/solaris/Makefile.am
--- libgtop-2.19.2/sysdeps/solaris/Makefile.am	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/Makefile.am	2007-05-19 00:44:12.362476000 +0800
@@ -8,7 +8,7 @@ libgtop_sysdeps_2_0_la_SOURCES	= open.c 
 				  proclist.c procstate.c procuid.c \
 				  proctime.c procmem.c procsignal.c \
 				  prockernel.c procsegment.c procargs.c \
-				  procopenfiles.c \
+				  procopenfiles.c sysinfo.c fsusage.c procwd.c glibtop_private.c \
 				  procmap.c netload.c ppp.c procdata.c netlist.c
 
 libgtop_sysdeps_2_0_la_LDFLAGS	= $(LT_VERSION_INFO)
diff -Nrup libgtop-2.19.2/sysdeps/solaris/cpu.c libgtop-2.19.2.mod/sysdeps/solaris/cpu.c
--- libgtop-2.19.2/sysdeps/solaris/cpu.c	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/cpu.c	2007-05-18 23:10:50.519504000 +0800
@@ -34,6 +34,7 @@ static const unsigned long _glibtop_sysd
 
 static const unsigned long _glibtop_sysdeps_cpu_all =
 (1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
++(1L << GLIBTOP_CPU_NICE) + /* this value is needed by multiload */
 (1L << GLIBTOP_CPU_SYS) + (1L << GLIBTOP_CPU_IDLE) +
 (1L << GLIBTOP_XCPU_TOTAL) + (1L << GLIBTOP_XCPU_USER) +
 (1L << GLIBTOP_XCPU_SYS) + (1L << GLIBTOP_XCPU_IDLE) +
diff -Nrup libgtop-2.19.2/sysdeps/solaris/fsusage.c libgtop-2.19.2.mod/sysdeps/solaris/fsusage.c
--- libgtop-2.19.2/sysdeps/solaris/fsusage.c	1970-01-01 08:00:00.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/fsusage.c	2007-05-18 23:27:13.387170000 +0800
@@ -0,0 +1,99 @@
+#include <config.h>
+#include <glibtop.h>
+#include <glibtop/error.h>
+#include <glibtop/fsusage.h>
+#include <glibtop/union.h>
+
+#include "glibtop_private.h"
+
+#include <glib.h>
+
+#include <unistd.h>
+#include <kstat.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/statvfs.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+G_GNUC_INTERNAL void 
+_glibtop_sun_get_fsusage_read_write(glibtop *server,
+				      glibtop_fsusage *buf,
+				      const char *path)
+{
+        struct statvfs64       statvfsbuf;
+        char            ksname[KSTAT_STRLEN + 1];
+    	kstat_ctl_t * const kctl = server->machine.kc;
+	kstat_t		*ksp;
+     	kstat_io_t     	kio;
+	kstat_named_t   *kread, *kwrite;
+	int i;
+	
+        /*
+         *  get a kstat handle and update the user's kstat chain
+         */
+        if( kctl == NULL ){ 
+                glibtop_warn_io_r (server, "kstat_open ()");
+                return;
+        }
+	
+        /* make sure we have current data */  
+	while( kstat_chain_update( kctl ) != 0 )
+                ;
+		
+         for (ksp = kctl->kc_chain, i =0; ksp != NULL; ksp = ksp->ks_next, i++) {  
+		if (ksp->ks_type == KSTAT_TYPE_IO && strcmp(ksp->ks_class,"disk") == 0) { 
+              		kstat_read(kctl, ksp, &kio);  
+               		buf->read +=  kio.nread;       
+			buf->write +=  kio.nwritten;
+		}  
+	}
+#if 0
+	/* these codes keep here, because they are a good way to get the 
+	   fsusage information, but at the moment, the interfaces used 
+	   are not public or stable. so let's use them when public...
+	  */
+        /*
+         *  get a kstat handle and update the user's kstat chain
+         */
+        if( kctl == NULL ){
+                glibtop_warn_io_r (server, "kstat_open ()");
+                return;
+        }
+	   
+	while( kstat_chain_update( kctl ) != 0 )
+                ;
+
+	if (statvfs64(path, &statvfsbuf) != 0) {
+                glibtop_warn_io_r (server, "kstat_open ()");
+		return;
+	}        
+	snprintf(ksname, KSTAT_STRLEN, "%s%lx", VOPSTATS_STR,
+                        	statvfsbuf.f_fsid);
+
+       	/*
+         *  traverse the kstat chain
+         *  to find the appropriate statistics
+         */
+        if( (ksp = kstat_lookup( kctl,
+                       "unix", 0, ksname )) == NULL ) {
+               	return;
+        }
+        if( kstat_read( kctl, ksp, NULL ) == -1 ) {
+               	return;
+        }
+
+	kread = (kstat_named_t *)kstat_data_lookup(ksp,"read_bytes");
+        if( kread != NULL ) {
+               	buf->read = kread->value.ull;
+        }
+
+        kwrite = (kstat_named_t *)kstat_data_lookup(ksp,"write_bytes");
+        if( kwrite != NULL ) {
+               	buf->write = kwrite->value.ull;
+        }
+#endif
+        buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
+}
diff -Nrup libgtop-2.19.2/sysdeps/solaris/glibtop_machine.h libgtop-2.19.2.mod/sysdeps/solaris/glibtop_machine.h
--- libgtop-2.19.2/sysdeps/solaris/glibtop_machine.h	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/glibtop_machine.h	2007-05-18 16:05:20.322950000 +0800
@@ -61,14 +61,7 @@ struct _glibtop_machine
     int pagesize;		/* in bits to shift, ie. 2^pagesize gives Kb */
     int ticks;			/* clock ticks, as returned by sysconf() */
     unsigned long long boot;	/* boot time, although it's ui32 in kstat */
-    void *libproc;		/* libproc handle */
-#if GLIBTOP_SOLARIS_RELEASE >= 50600
-    void (*objname)(void *, uintptr_t, const char *, size_t);
-    struct ps_prochandle *(*pgrab)(pid_t, int, int *);
-    void (*pfree)(void *);
-#else
     void *filler[3];
-#endif
 };
 
 G_END_DECLS
diff -Nrup libgtop-2.19.2/sysdeps/solaris/glibtop_private.c libgtop-2.19.2.mod/sysdeps/solaris/glibtop_private.c
--- libgtop-2.19.2/sysdeps/solaris/glibtop_private.c	1970-01-01 08:00:00.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/glibtop_private.c	2007-05-19 00:39:20.309851000 +0800
@@ -0,0 +1,203 @@
+#include <config.h>
+#include <glibtop.h>
+#include <glibtop/error.h>
+
+#include "glibtop_private.h"
+
+#include <glib.h>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+
+#if 0
+unsigned long long
+get_scaled(const char *buffer, const char *key)
+{
+	const char    *ptr;
+	char	      *next;
+	unsigned long long value = 0;
+
+	if (G_LIKELY((ptr = strstr(buffer, key))))
+	{
+		ptr += strlen(key);
+		value = strtoull(ptr, &next, 0);
+
+		for ( ; *next; ++next) {
+			if (*next == 'k') {
+				value *= 1024;
+				break;
+			} else if (*next == 'M') {
+				value *= 1024 * 1024;
+				break;
+			}
+		}
+	} else
+		g_warning("Could not read key '%s' in buffer '%s'",
+			  key, buffer);
+
+	return value;
+}
+
+
+char *
+skip_token (const char *p)
+{
+	p = next_token(p);
+	while (*p && !isspace(*p)) p++;
+	p = next_token(p);
+	return (char *)p;
+}
+
+
+/*
+ * Read functions
+ */
+enum TRY_FILE_TO_BUFFER
+{
+	TRY_FILE_TO_BUFFER_OK = 0,
+	TRY_FILE_TO_BUFFER_OPEN = -1,
+	TRY_FILE_TO_BUFFER_READ = -2
+};
+
+int try_file_to_buffer(char *buffer, const char *format, ...)
+{
+	char path[4096];
+	int fd;
+	ssize_t len;
+	va_list pa;
+
+	va_start(pa, format);
+
+	/* C99 also provides vsnprintf */
+	g_vsnprintf(path, sizeof path, format, pa);
+
+	va_end(pa);
+
+	buffer [0] = '\0';
+
+	if((fd = open (path, O_RDONLY)) < 0)
+		return TRY_FILE_TO_BUFFER_OPEN;
+
+	len = read (fd, buffer, BUFSIZ-1);
+	close (fd);
+
+	if (len < 0)
+		return TRY_FILE_TO_BUFFER_READ;
+
+	buffer [len] = '\0';
+
+	return TRY_FILE_TO_BUFFER_OK;
+}
+
+
+void
+file_to_buffer(glibtop *server, char *buffer, const char *filename)
+{
+	switch(try_file_to_buffer(buffer, filename))
+	{
+	case TRY_FILE_TO_BUFFER_OPEN:
+		glibtop_error_io_r (server, "open (%s)", filename);
+	case TRY_FILE_TO_BUFFER_READ:
+		glibtop_error_io_r (server, "read (%s)", filename);
+	}
+}
+
+
+
+
+static unsigned long
+read_boot_time(glibtop *server)
+{
+	char buffer[BUFSIZ];
+	char *btime;
+
+	file_to_buffer(server, buffer, "/proc/stat");
+
+	btime = strstr(buffer, "btime");
+
+	if (!btime) {
+		glibtop_warn_io_r(server, "cannot find btime in /proc/stat");
+		return 0UL;
+	}
+
+	btime = skip_token(btime);
+	return strtoul(btime, NULL, 10);
+}
+
+
+
+unsigned long
+get_boot_time(glibtop *server)
+{
+	static unsigned long boot_time = 0UL;
+
+	if(G_UNLIKELY(!boot_time))
+	{
+		boot_time = read_boot_time(server);
+	}
+
+	return boot_time;
+}
+
+
+size_t
+get_page_size(void)
+{
+	static size_t pagesize = 0;
+
+	if(G_UNLIKELY(!pagesize))
+	{
+		pagesize = getpagesize();
+	}
+
+	return pagesize;
+}
+
+
+
+gboolean
+check_cpu_line(glibtop *server, const char *line, unsigned i)
+{
+	char start[10];
+
+	g_snprintf(start, sizeof start, "cpu%u", i);
+
+	return g_str_has_prefix(line, start);
+}
+
+
+
+gboolean
+has_sysfs(void)
+{
+	static gboolean init;
+	static gboolean sysfs;
+
+	if (G_UNLIKELY(!init)) {
+		sysfs = g_file_test("/sys", G_FILE_TEST_IS_DIR);
+		init = TRUE;
+	}
+
+	return sysfs;
+}
+#endif
+
+
+gboolean safe_readlink(const char *path, char *buf, size_t bufsiz)
+{
+	ssize_t ret;
+
+	ret = readlink(path, buf, bufsiz - 1);
+
+	if (ret == -1) {
+		g_warning("Could not read link %s : %s", path, strerror(errno));
+		return FALSE;
+	}
+
+	buf[ret] = '\0';
+	return TRUE;
+}
diff -Nrup libgtop-2.19.2/sysdeps/solaris/glibtop_private.h libgtop-2.19.2.mod/sysdeps/solaris/glibtop_private.h
--- libgtop-2.19.2/sysdeps/solaris/glibtop_private.h	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/glibtop_private.h	2007-05-19 00:34:12.544055000 +0800
@@ -60,6 +60,8 @@ int glibtop_get_proc_credentials_s(glibt
 /* Reread kstat chains */
 void glibtop_get_kstats(glibtop *);
 
+gboolean safe_readlink(const char *path, char *buf, size_t bufsiz);
+
 G_END_DECLS
 
 #endif /* __GLIBTOP_PRIVATE_H__ */
diff -Nrup libgtop-2.19.2/sysdeps/solaris/glibtop_server.h libgtop-2.19.2.mod/sysdeps/solaris/glibtop_server.h
--- libgtop-2.19.2/sysdeps/solaris/glibtop_server.h	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/glibtop_server.h	2007-05-18 18:37:08.382200000 +0800
@@ -29,9 +29,15 @@ G_BEGIN_DECLS
 #define GLIBTOP_SUID_SWAP		0
 #define GLIBTOP_SUID_UPTIME		0
 #define GLIBTOP_SUID_LOADAVG		0
+#if GLIBTOP_SOLARIS_RELEASE < 51000
 #define GLIBTOP_SUID_SHM_LIMITS		(1L << GLIBTOP_SYSDEPS_SHM_LIMITS)
 #define GLIBTOP_SUID_MSG_LIMITS		(1L << GLIBTOP_SYSDEPS_MSG_LIMITS)
 #define GLIBTOP_SUID_SEM_LIMITS		(1L << GLIBTOP_SYSDEPS_SEM_LIMITS)
+#else
+#define GLIBTOP_SUID_SHM_LIMITS         0
+#define GLIBTOP_SUID_MSG_LIMITS         0
+#define GLIBTOP_SUID_SEM_LIMITS         0
+#endif
 #define GLIBTOP_SUID_PROCLIST		0
 #define GLIBTOP_SUID_PROC_STATE		0
 #define GLIBTOP_SUID_PROC_UID		0
@@ -44,6 +50,7 @@ G_BEGIN_DECLS
 #define GLIBTOP_SUID_PROC_MAP		0
 #define GLIBTOP_SUID_NETLOAD		0
 #define GLIBTOP_SUID_NETLIST		0
+#define GLIBTOP_SUID_PROC_WD		0
 #define GLIBTOP_SUID_PPP		0
 
 G_END_DECLS
diff -Nrup libgtop-2.19.2/sysdeps/solaris/msg_limits.c libgtop-2.19.2.mod/sysdeps/solaris/msg_limits.c
--- libgtop-2.19.2/sysdeps/solaris/msg_limits.c	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/msg_limits.c	2007-05-18 18:26:18.794307000 +0800
@@ -37,14 +37,24 @@ static const unsigned long _glibtop_sysd
 (1L << GLIBTOP_IPC_MSGMNB) + (1L << GLIBTOP_IPC_MSGMNI) +
 (1L << GLIBTOP_IPC_MSGTQL);
 #else
-static const unsigned long _glibtop_sysdeps_msg_limits = 0;
+static const unsigned long _glibtop_sysdeps_msg_limits =
+(1L << GLIBTOP_IPC_MSGMNB) +
+(1L << GLIBTOP_IPC_MSGMNI) +
+(1L << GLIBTOP_IPC_MSGMAX) +
+(1L << GLIBTOP_IPC_MSGPOOL) +
+(1L << GLIBTOP_IPC_MSGTQL);
 #endif
 
 
 /* Init function. */
 
+#if GLIBTOP_SUID_MSG_LIMITS
 void
 _glibtop_init_msg_limits_p (glibtop *server)
+#else
+void
+_glibtop_init_msg_limits_s (glibtop *server)
+#endif
 {
 #if GLIBTOP_SOLARIS_RELEASE < 51000
 
@@ -59,8 +69,13 @@ _glibtop_init_msg_limits_p (glibtop *ser
 
 /* Provides information about sysv ipc limits. */
 
+#if GLIBTOP_SUID_MSG_LIMITS
 void
 glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
+#else
+void
+glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
+#endif
 {
 #if GLIBTOP_SOLARIS_RELEASE < 51000
 
diff -Nrup libgtop-2.19.2/sysdeps/solaris/netlist.c libgtop-2.19.2.mod/sysdeps/solaris/netlist.c
--- libgtop-2.19.2/sysdeps/solaris/netlist.c	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/netlist.c	2007-05-18 16:11:55.054558000 +0800
@@ -41,7 +41,13 @@ glibtop_get_netlist_s (glibtop *server, 
 {
 	GPtrArray *devices;
 	kstat_t *ksp;
-	kstat_ctl_t *kc;
+	/* use the kc installed in server, don't need to create again, 
+      	   it will save some time and improve performance */
+        kstat_ctl_t * const kc = server->machine.kc;
+	/* use flags as a check condition, if it is 1, check, or not check... zhua */
+        int check = buf->flags;
+	/* set flags back to 0 */
+	buf->flags = 0; 
 
 	glibtop_init_s (&server, GLIBTOP_SYSDEPS_NETLIST, 0);
 
@@ -49,7 +55,6 @@ glibtop_get_netlist_s (glibtop *server, 
 
 	devices = g_ptr_array_new();
 
-	kc = kstat_open();
 	if (kc == NULL) {
 		glibtop_warn_io_r(server, "kstat_open()");
 		return NULL;
@@ -60,11 +65,26 @@ glibtop_get_netlist_s (glibtop *server, 
 		if (strcmp(ksp->ks_class, "net") != 0)
 			continue;
 
-		g_ptr_array_add(devices, g_strdup(ksp->ks_name));
-		buf->number++;
-	}
+               /* do some check to see if the first character is the same between
+                  name and module, if not, we don't return it, because 
+		  glibtop_get_netload() only want the same ones....
+                */
+               if (check){
+                       /* if the first character is not same, they should not
+                          the one we will use in glibtop_get_netload() */
+                       if (ksp->ks_name[0] != ksp->ks_module[0])
+                               continue;
+                       /* because in glibtop_get_netload(), name
+                          is at least 1 character longer than module */
+                       if (strlen( ksp->ks_module ) >= strlen( ksp->ks_name))
+                               continue;
+                       /* if it's not digital, continue directly */
+                       if( !isdigit( (int) ksp->ks_name[strlen( ksp->ks_module )] ))
+                               continue;
+               }
+               g_ptr_array_add(devices, g_strdup(ksp->ks_name));
+               buf->number++;	}
 
-	kstat_close(kc);
 
 	buf->flags = _glibtop_sysdeps_netlist;
 
diff -Nrup libgtop-2.19.2/sysdeps/solaris/netload.c libgtop-2.19.2.mod/sysdeps/solaris/netload.c
--- libgtop-2.19.2/sysdeps/solaris/netload.c	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/netload.c	2007-05-18 18:03:14.142003000 +0800
@@ -24,14 +24,245 @@
 #include <glibtop/error.h>
 #include <glibtop/netload.h>
 
-static const unsigned long _glibtop_sysdeps_netload = 0;
+#include "glibtop_private.h"
+
+#include <errno.h>
+#include <string.h>
+#include <kstat.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/sockio.h>
+
+//#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
+/* GNU LibC */
+#include <net/if.h>
+
+#ifdef HAVE_IFADDRS_H
+/* needed for IPV6 support */
+
+#include <ifaddrs.h>
+
+#ifndef IN6_IS_ADDR_GLOBAL
+#define IN6_IS_ADDR_GLOBAL(a) \
+   (((((__const uint8_t *) (a))[0] & 0xff) == 0x3f   \
+     || (((__const uint8_t *) (a))[0] & 0xff) == 0x20))
+#endif
+#endif /* HAVE_IFADDRS_H */
+
+static const unsigned long _glibtop_sysdeps_netload =
+(1L << GLIBTOP_NETLOAD_ERRORS_IN) +
+(1L << GLIBTOP_NETLOAD_ERRORS_OUT) +
+(1L << GLIBTOP_NETLOAD_COLLISIONS);
+
+static const unsigned long _glibtop_sysdeps_netload_data =
+(1L << GLIBTOP_NETLOAD_ADDRESS) +
+(1L << GLIBTOP_NETLOAD_SUBNET) +
+(1L << GLIBTOP_NETLOAD_MTU);
+
+static const unsigned long _glibtop_sysdeps_netload_bytes =
+(1L << GLIBTOP_NETLOAD_BYTES_IN) +
+(1L << GLIBTOP_NETLOAD_BYTES_OUT) +
+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL);
+
+static const unsigned long _glibtop_sysdeps_netload_packets =
+(1L << GLIBTOP_NETLOAD_PACKETS_IN) +
+(1L << GLIBTOP_NETLOAD_PACKETS_OUT) +
+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL);
+
+static const unsigned long _glibtop_sysdeps_netload_total =
+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL);
+
+static const unsigned long _glibtop_sysdeps_netload_in =
+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) +
+(1L << GLIBTOP_NETLOAD_PACKETS_IN) +
+(1L << GLIBTOP_NETLOAD_BYTES_IN);
+
+static const unsigned long _glibtop_sysdeps_netload_out =
+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) +
+(1L << GLIBTOP_NETLOAD_PACKETS_OUT) +
+(1L << GLIBTOP_NETLOAD_BYTES_OUT);
+
+static const unsigned long _glibtop_sysdeps_netload_6 =
+(1L << GLIBTOP_NETLOAD_ADDRESS6) +
+(1L << GLIBTOP_NETLOAD_PREFIX6) +
+(1L << GLIBTOP_NETLOAD_SCOPE6);
 
 /* Init function. */
 
 void
 _glibtop_init_netload_s (glibtop *server)
 {
-	server->sysdeps.netload = _glibtop_sysdeps_netload;
+   server->sysdeps.netload = _glibtop_sysdeps_netload |
+	_glibtop_sysdeps_netload_bytes |
+	_glibtop_sysdeps_netload_packets;
+}
+
+
+#ifdef HAVE_IFADDRS_H
+
+static void get_ipv6(glibtop *server, glibtop_netload *buf,
+		     const char *interface)
+{
+/* 
+  * remove this code, because they are not available at Solaris, but keep them here for reference.
+  * in fact, the function will not be called at Solaris, because HAVE_IFADDRS_H don't def.
+  *
+*/
+#if 0
+	struct ifaddrs *ifa0, *ifr6;
+
+	if(getifaddrs (&ifa0) != 0)
+	{
+		glibtop_warn_r(server, "getifaddrs failed : %s", g_strerror(errno));
+		return;
+	}
+
+	for (ifr6 = ifa0; ifr6; ifr6 = ifr6->ifa_next) {
+		if (strcmp (ifr6->ifa_name, interface) == 0
+		    && ifr6->ifa_addr != NULL
+		    && ifr6->ifa_addr->sa_family == AF_INET6)
+			break;
+	}
+
+	if(!ifr6) goto free_ipv6;
+
+	memcpy(buf->address6,
+	       &((struct sockaddr_in6 *) ifr6->ifa_addr)->sin6_addr,
+	       16);
+
+	memcpy(buf->prefix6,
+	       &((struct sockaddr_in6 *) ifr6->ifa_netmask)->sin6_addr,
+	       16);
+
+
+	if (IN6_IS_ADDR_LINKLOCAL (buf->address6))
+		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_LINK;
+
+	else if (IN6_IS_ADDR_SITELOCAL (buf->address6))
+		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_SITE;
+
+	else if (IN6_IS_ADDR_GLOBAL (buf->address6)
+		 || IN6_IS_ADDR_MC_ORGLOCAL (buf->address6)
+		 || IN6_IS_ADDR_V4COMPAT (buf->address6)
+		 || IN6_IS_ADDR_MULTICAST (buf->address6)
+		 || IN6_IS_ADDR_UNSPECIFIED (buf->address6)
+		)
+		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_GLOBAL;
+
+	else if (IN6_IS_ADDR_LOOPBACK (buf->address6))
+		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_HOST;
+
+	else
+		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_UNKNOWN;
+
+	buf->flags |= _glibtop_sysdeps_netload_6;
+
+ free_ipv6:
+	freeifaddrs(ifa0);
+#endif
+}
+
+#endif /* HAVE_IFADDRS_H */
+
+
+
+static int
+solaris_stats(glibtop *server,
+		glibtop_netload *buf,
+		const char *interface)
+{
+	char	*name = interface;
+	char	*module;
+	char	*ptr;
+    	kstat_ctl_t * const kctl = server->machine.kc;
+	kstat_t			*ksp;
+	kstat_named_t		*kdata;
+	int have_bytes = 1;
+
+	/*
+	 *  chop off the trailing interface and 
+	 */
+	module = strdup( name );
+	ptr = module + strlen( module ) - 1;
+	while( (ptr > module) && isdigit( (int) *ptr ) ) {
+		*ptr = '\0';
+		ptr--;
+	}
+
+	/*
+	 *  get a kstat handle and update the user's kstat chain
+	 */
+	if( kctl == NULL ){
+		glibtop_warn_io_r (server, "kstat_open ()");
+		free( module );
+		return( 0 );
+	}
+	while( kstat_chain_update( kctl ) != 0 )
+		;
+
+	/*
+	 *  traverse the kstat chain
+	 *  to find the appropriate statistics
+	 */
+	if( (ksp = kstat_lookup( kctl,
+			module, 0, name )) == NULL ) {
+		free( module );
+		return( 0 );
+	}
+	if( kstat_read( kctl, ksp, NULL ) == -1 ) {
+		free( module );
+		return( 0 );
+	}
+	free( module );
+
+	/*
+	 *  lookup & store the data
+	 */
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "ipackets" );
+	if( kdata != NULL ) {
+		buf->packets_in= kdata->value.ul;
+	}
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "opackets" );
+	if( kdata != NULL ) {
+		buf->packets_out = kdata->value.ul;
+	}
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "rbytes" );
+	if( kdata != NULL ) {
+		buf->bytes_in =kdata->value.ul;
+	}
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "obytes" );
+	if( kdata != NULL ) {
+		buf->bytes_out =kdata->value.ul;
+	}
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "ierrors" );
+	if( kdata != NULL ) {
+		buf->errors_in = kdata->value.ul;
+	}
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "oerrors" );
+	if( kdata != NULL ) {
+		buf->errors_out = kdata->value.ul;
+	}
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "collisions" );
+	if( kdata != NULL ) {
+		buf->collisions = kdata->value.ul;
+	}
+	
+	/* Compute total valules. */
+
+	buf->bytes_total = buf->bytes_in + buf->bytes_out;
+	buf->packets_total = buf->packets_in + buf->packets_out;
+	buf->errors_total = buf->errors_in + buf->errors_out;
+	/* And now the flags. */
+	buf->flags |= _glibtop_sysdeps_netload;
+	buf->flags |= _glibtop_sysdeps_netload_bytes;
+	buf->flags |= _glibtop_sysdeps_netload_packets;
+	    
+	/* finished */
 }
 
 /* Provides network statistics. */
@@ -40,5 +271,72 @@ void
 glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
 		       const char *interface)
 {
-	memset (buf, 0, sizeof (glibtop_netload));
+   int skfd;
+    memset (buf, 0, sizeof (glibtop_netload));
+
+    /* set flag */
+    skfd = socket (PF_INET, SOCK_DGRAM, 0);
+    if (skfd) {
+	struct ifreq ifr;
+
+	g_strlcpy (ifr.ifr_name, interface, sizeof ifr.ifr_name);
+	if (ioctl (skfd, SIOCGIFFLAGS, &ifr) >= 0) {
+	    const unsigned long long flags = ifr.ifr_flags;
+
+	    buf->flags |= (1L << GLIBTOP_NETLOAD_IF_FLAGS);
+
+	    if (flags & IFF_UP)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_UP);
+
+	    if (flags & IFF_BROADCAST)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_BROADCAST);
+
+	    if (flags & IFF_DEBUG)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_DEBUG);
+
+	    if (flags & IFF_LOOPBACK)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_LOOPBACK);
+
+	    if (flags & IFF_POINTOPOINT)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_POINTOPOINT);
+
+	    if (flags & IFF_RUNNING)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_RUNNING);
+
+	    if (flags & IFF_NOARP)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_NOARP);
+
+	    if (flags & IFF_PROMISC)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_PROMISC);
+
+	    if (flags & IFF_ALLMULTI)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_ALLMULTI);
+
+	    if (flags & IFF_MULTICAST)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_MULTICAST);
+	    }
+
+	g_strlcpy (ifr.ifr_name, interface, sizeof ifr.ifr_name);
+	if (!ioctl (skfd, SIOCGIFADDR, &ifr)) {
+	    buf->address = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr;
+	    buf->flags |= (1L << GLIBTOP_NETLOAD_ADDRESS);
+	}
+
+	g_strlcpy (ifr.ifr_name, interface, sizeof ifr.ifr_name);
+	if (!ioctl (skfd, SIOCGIFNETMASK, &ifr)) {
+	    buf->subnet = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr;
+	    buf->flags |= (1L << GLIBTOP_NETLOAD_SUBNET);
+	}
+	close (skfd);
+    }
+
+    /*
+     * Statistics
+     */
+     
+    solaris_stats(server, buf, interface);
+
+#ifdef HAVE_IFADDRS_H
+    get_ipv6(server, buf, interface);
+#endif /* HAVE_IFADDRS_H */
 }
diff -Nrup libgtop-2.19.2/sysdeps/solaris/open.c libgtop-2.19.2.mod/sysdeps/solaris/open.c
--- libgtop-2.19.2/sysdeps/solaris/open.c	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/open.c	2007-05-18 16:21:21.872457000 +0800
@@ -209,34 +209,5 @@ glibtop_open_s (glibtop *server, const c
 	    }
     }
 
-    /* Now let's have a bit of magic dust... */
-
-#if GLIBTOP_SOLARIS_RELEASE >= 50600
-
-    dl = dlopen("/usr/lib/libproc.so", RTLD_LAZY);
-    if(server->machine.libproc)
-    	dlclose(server->machine.libproc);
-    server->machine.libproc = dl;
-    if(dl)
-    {
-       void *func;
-
-       func = dlsym(dl, "Pobjname");		/* Solaris 8 */
-       if(!func)
-	  func = dlsym(dl, "proc_objname");	/* Solaris 7 */
-       server->machine.objname = (void (*)
-				 (void *, uintptr_t, const char *, size_t))func;
-       server->machine.pgrab = (struct ps_prochandle *(*)(pid_t, int, int *))
-	  		       dlsym(dl, "Pgrab");
-       server->machine.pfree = (void (*)(void *))dlsym(dl, "Pfree");
-       
-    }
-    else
-    {
-       server->machine.objname = NULL;
-       server->machine.pgrab = NULL;
-       server->machine.pfree = NULL;
-    }
-#endif
     server->machine.me = getpid();
 }
diff -Nrup libgtop-2.19.2/sysdeps/solaris/procmap.c libgtop-2.19.2.mod/sysdeps/solaris/procmap.c
--- libgtop-2.19.2/sysdeps/solaris/procmap.c	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/procmap.c	2007-05-18 17:45:40.836275000 +0800
@@ -54,9 +54,14 @@ glibtop_map_entry *
 glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf,	pid_t pid)
 {
    	int fd, i, nmaps, pr_err, heap;
+        char filename [BUFSIZ];
+	/* use flags as a check condition, if it is 1, check, or, not check... zhua */
+	int check = buf->flags;
+	/* set flags back to 0 */
+	buf->flags = 0;
+		
 #if GLIBTOP_SOLARIS_RELEASE >= 50600
 	prxmap_t *maps;
-	struct ps_prochandle *Pr = NULL;
 #else
 	prmap_t *maps;
 #endif
@@ -123,15 +128,34 @@ glibtop_get_proc_map_s (glibtop *server,
 	buf->total = nmaps * sizeof(glibtop_map_entry);
 	entry = g_malloc0(buf->total);
 
-#if GLIBTOP_SOLARIS_RELEASE >= 50600
-
-	if(server->machine.objname && server->machine.pgrab &&
-	   server->machine.pfree)
-	   Pr = (server->machine.pgrab)(pid, 1, &pr_err);
-#endif
 	for(heap = 0,i = 0; i < nmaps; ++i)
 	{
-	   	int len;
+		/* take a check to see if we need all information, if not, just get what we need.. 
+		   Also please see comments in get_process_memory_writable() of gnome-system-monitor zhua */
+		if (check == 1)
+		{
+			if(maps[i].pr_mflags & MA_WRITE){
+		   	entry[i].perm |= GLIBTOP_MAP_PERM_WRITE;
+		   	entry[i].size = maps[i].pr_size;
+			}
+                if(maps[i].pr_mflags & MA_SHARED){
+                        entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
+			/* here use shared_clean to store Shared Memory */
+                        entry[i].shared_clean = maps[i].pr_size; 
+                	}
+		}
+                else
+                if (check == 2)
+                {
+                       if(maps[i].pr_mflags & MA_SHARED){
+                        entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
+                       /* here use shared_clean to store Shared Memory */
+                        entry[i].shared_clean = maps[i].pr_size;
+                       }
+                }
+		else {
+		
+	   	int len, rv;
 
 	   	entry[i].start = maps[i].pr_vaddr;
 		entry[i].end = maps[i].pr_vaddr + maps[i].pr_size;
@@ -177,25 +201,26 @@ glibtop_get_proc_map_s (glibtop *server,
 		   entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
 		}
 		else
-		   if(Pr)
-		   {
-		      server->machine.objname(Pr, maps[i].pr_vaddr, buffer,
-					      BUFSIZ);
-		      if((len = resolvepath(buffer, entry[i].filename,
-					    GLIBTOP_MAP_FILENAME_LEN)) > 0)
-		      {
-			 entry[i].filename[len] = 0;
-			 entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
-		      }
-		   }
+                {
+                        g_strlcpy(buffer, maps[i].pr_mapname,  sizeof buffer);
+                        /* from /path get file name */
+                        g_snprintf(filename, sizeof filename, "/proc/%d/path/%s",
+                                pid, buffer);
+ 
+                        rv = readlink(filename, entry[i].filename, sizeof(entry[i].filename) - 1);
+                        /* read object, if have not, set it as NULL */
+                        if(rv < 0)
+                                rv = 0;
+                        entry[i].filename[rv] = '\0';
+                        /* now set the flags */
+                        entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
+                }
+		   
 #endif
-	}
+               } /* end of else check */
 
-#if GLIBTOP_SOLARIS_RELEASE >= 50600
+	}
 
-	if(Pr)
-	   	server->machine.pfree(Pr);
-#endif
 	buf->flags = _glibtop_sysdeps_proc_map;
 	s_close(fd);
 	return entry;
diff -Nrup libgtop-2.19.2/sysdeps/solaris/procmem.c libgtop-2.19.2.mod/sysdeps/solaris/procmem.c
--- libgtop-2.19.2/sysdeps/solaris/procmem.c	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/procmem.c	2007-05-18 16:32:37.862629000 +0800
@@ -22,12 +22,14 @@
 #include <config.h>
 #include <glibtop.h>
 #include <glibtop/procmem.h>
+#include <glibtop/procmap.h>
 
 #include "glibtop_private.h"
 
 static const unsigned long _glibtop_sysdeps_proc_mem =
 (1L << GLIBTOP_PROC_MEM_SIZE) + (1L << GLIBTOP_PROC_MEM_VSIZE) +
-(1L << GLIBTOP_PROC_MEM_RESIDENT) + (1L << GLIBTOP_PROC_MEM_RSS);
+(1L << GLIBTOP_PROC_MEM_RESIDENT) + (1L << GLIBTOP_PROC_MEM_RSS) +
+(1L << GLIBTOP_PROC_MEM_SHARE);
 
 /* Init function. */
 
@@ -61,5 +63,31 @@ glibtop_get_proc_mem_s (glibtop *server,
 	buf->size = buf->vsize = psinfo.pr_size << pagesize << 10;
 	buf->resident = buf->rss = psinfo.pr_rssize << pagesize << 10;
 #endif
+/* get Shared Memory  */
+        glibtop_proc_map mapbuf;
+        glibtop_map_entry *maps;
+        unsigned i;
+        buf->share = 0;
+	
+	/* we have to optimize the performance of libgtop, because update the information will occupy too much cpu.
+ 
+           here I would like to make a little update:set glibtop_proc_map.flags=1,so as to let glibtop_get_proc_map_s()
+           only return the ones this function need: memwritable
+ 
+           we do the check in glibtop_get_proc_map_s(), don't run the others part which don't need by this function,
+	   I think this will accelerate the transaction lots,
+           Also this will not affect the existing codes, because when nobody set glibtop_proc_map.flags,
+           glibtop_get_proc_map() will return all as before. zhua
+	*/
+	mapbuf.flags = 2;
+ 
+        maps = glibtop_get_proc_map_s(server, &mapbuf, pid);
+ 
+        for (i = 0; i < mapbuf.number; ++i) {
+                if (maps[i].perm & GLIBTOP_MAP_PERM_SHARED)
+                        buf->share += maps[i].shared_clean;
+        }
+        g_free(maps);
+ 
 	buf->flags = _glibtop_sysdeps_proc_mem;
 }
diff -Nrup libgtop-2.19.2/sysdeps/solaris/procstate.c libgtop-2.19.2.mod/sysdeps/solaris/procstate.c
--- libgtop-2.19.2/sysdeps/solaris/procstate.c	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/procstate.c	2007-05-19 21:18:30.078392000 +0800
@@ -62,6 +62,27 @@ glibtop_get_proc_state_s (glibtop *serve
 	buf->gid = psinfo.pr_egid;
 	buf->ruid = psinfo.pr_uid;
 	buf->rgid = psinfo.pr_gid;
+        /* zhua: get some value here, so that we don't need run open/pread/close psinfo later,
+                 and can delete some other call for psinfo open/pread/close. it will save lots of time*/
+#ifdef HAVE_PROCFS_H
+        buf->nice = psinfo.pr_lwp.pr_nice - NZERO;
+#else
+        buf->nice = psinfo.pr_nice - NZERO;
+#endif
+   
+        buf->start_time = psinfo.pr_start.tv_sec;
+        buf->ppid = psinfo.pr_ppid;
+   
+#ifdef HAVE_PROCFS_H
+        buf->vsize = psinfo.pr_size << 10;
+        buf->resident= psinfo.pr_rssize << 10;
+        buf->load = (guint) psinfo.pr_lwp.pr_pctcpu * 100 / (guint) 0x8000;
+#else
+        buf->vsize = psinfo.pr_size << pagesize << 10;
+        buf->resident = psinfo.pr_rssize << pagesize << 10;
+        buf->load = (guint) psinfo.pr_lwp.pr_pctcpu * 100 / (guint) 0x8000;
+#endif
+	
 
 #ifdef HAVE_PROCFS_H
 	switch(psinfo.pr_lwp.pr_state)
diff -Nrup libgtop-2.19.2/sysdeps/solaris/proctime.c libgtop-2.19.2.mod/sysdeps/solaris/proctime.c
--- libgtop-2.19.2/sysdeps/solaris/proctime.c	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/proctime.c	2007-05-18 23:15:50.623438000 +0800
@@ -43,8 +43,12 @@ void
 glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf,
 			 pid_t pid)
 {
+#ifdef HAVE_PROCFS_H
+       struct psinfo pinfo;
+#else
+       struct prpsinfo pinfo;
+#endif
 	struct prusage prusage;
-        GTimeVal time;
 
 	memset (buf, 0, sizeof (glibtop_proc_time));
 
@@ -52,19 +56,21 @@ glibtop_get_proc_time_s (glibtop *server
 
 	if(pid)
 	{
+  /* zhua remove this function call, because we can change to get start_time in
+        glibtop_get_proc_state(), it don't need open psinfo again here
+
+                if (glibtop_get_proc_data_psinfo_s(server, &pinfo, pid))
+                        return;
+                buf->start_time = pinfo.pr_start.tv_sec; */
+
 		if (glibtop_get_proc_data_usage_s (server, &prusage, pid))
 			return;
 
-                g_get_current_time (&time);
-		/* prusage.pr_rtime.tv_sec is the during that the process existed */
-                buf->start_time = time.tv_sec - prusage.pr_rtime.tv_sec;
-
-		buf->rtime = prusage.pr_rtime.tv_sec * 1E+6 +
-			prusage.pr_rtime.tv_nsec / 1E+3;
 		buf->utime = prusage.pr_utime.tv_sec * 1E+6 +
 			prusage.pr_utime.tv_nsec / 1E+3;
 		buf->stime = prusage.pr_stime.tv_sec * 1E+6 +
 			prusage.pr_stime.tv_nsec / 1E+3;
+		buf->rtime = (buf->utime + buf->stime) / 10000;
 	}
 
 	buf->flags = _glibtop_sysdeps_proc_time;
diff -Nrup libgtop-2.19.2/sysdeps/solaris/procwd.c libgtop-2.19.2.mod/sysdeps/solaris/procwd.c
--- libgtop-2.19.2/sysdeps/solaris/procwd.c	1970-01-01 08:00:00.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/procwd.c	2007-05-19 00:11:54.105195000 +0800
@@ -0,0 +1,98 @@
+/* Copyright (C) 2007 BenoƮt Dejean
+   This file is part of LibGTop 2.
+
+   LibGTop is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License,
+   or (at your option) any later version.
+
+   LibGTop is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with LibGTop; see the file COPYING. If not, write to the
+   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+#include <glibtop/procwd.h>
+#include <glibtop/error.h>
+
+#include <glibtop_private.h>
+
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/types.h>
+
+
+void
+_glibtop_init_proc_wd_s(glibtop *server)
+{
+	server->sysdeps.proc_wd =
+	(1 << GLIBTOP_PROC_WD_EXE) +
+	(1 << GLIBTOP_PROC_WD_ROOT) +
+	(1 << GLIBTOP_PROC_WD_NUMBER);
+
+}
+
+static gboolean is_in(GPtrArray *array, const char *str)
+{
+	guint i;
+
+	for (i = 0; i != array->len; ++i) {
+		if (strcmp(g_ptr_array_index(array, i), str) == 0)
+			return TRUE;
+	}
+
+	return FALSE;
+}
+
+
+char**
+glibtop_get_proc_wd_s(glibtop *server, glibtop_proc_wd *buf, pid_t pid)
+{
+	GPtrArray *dirs;
+	char path[80];
+	char dir[256];
+	DIR *task;
+
+	glibtop_init_s(&server, GLIBTOP_SYSDEPS_PROC_WD, 0);
+
+	memset(buf, 0, sizeof(glibtop_proc_wd));
+
+	g_snprintf(path, sizeof path, "/proc/%u/root", pid);
+	if (safe_readlink(path, buf->root, sizeof buf->root))
+		buf->flags |= (1 << GLIBTOP_PROC_WD_ROOT);
+
+	g_snprintf(path, sizeof path, "/proc/%u/exe", pid);
+	if (safe_readlink(path, buf->exe, sizeof buf->exe))
+		buf->flags |= (1 << GLIBTOP_PROC_WD_EXE);
+
+	dirs = g_ptr_array_sized_new(2);
+
+	g_snprintf(path, sizeof path, "/proc/%u/cwd", pid);
+	if (safe_readlink(path, dir, sizeof dir))
+		g_ptr_array_add(dirs, g_strdup(dir));
+
+	g_snprintf(path, sizeof path, "/proc/%u/task", pid);
+	if ((task = opendir(path)) != NULL) {
+		struct dirent *sub;
+		while ((sub = readdir(task)) != NULL) {
+			g_snprintf(path, sizeof path, "/proc/%u/task/%s/cwd", pid, sub->d_name);
+			if (safe_readlink(path, dir, sizeof dir) && !is_in(dirs, dir))
+				g_ptr_array_add(dirs, g_strdup(dir));
+		}
+		closedir(task);
+	}
+
+	buf->number = dirs->len;
+	buf->flags |= (1 << GLIBTOP_PROC_WD_NUMBER);
+
+	g_ptr_array_add(dirs, NULL);
+
+	return (char**) g_ptr_array_free(dirs, FALSE);
+}
+
diff -Nrup libgtop-2.19.2/sysdeps/solaris/sem_limits.c libgtop-2.19.2.mod/sysdeps/solaris/sem_limits.c
--- libgtop-2.19.2/sysdeps/solaris/sem_limits.c	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/sem_limits.c	2007-05-18 18:27:01.752030000 +0800
@@ -39,14 +39,22 @@ static const unsigned long _glibtop_sysd
 (1L << GLIBTOP_IPC_SEMUSZ) + (1L << GLIBTOP_IPC_SEMVMX) +
 (1L << GLIBTOP_IPC_SEMAEM);
 #else
-static const unsigned long _glibtop_sysdeps_sem_limits = 0;
+static const unsigned long _glibtop_sysdeps_sem_limits =
+(1L << GLIBTOP_IPC_SEMMNI) +
+(1L << GLIBTOP_IPC_SEMMSL) +
+(1L << GLIBTOP_IPC_SEMOPM);
 #endif
 
 
 /* Init function. */
 
+#if GLIBTOP_SUID_SEM_LIMITS
 void
 _glibtop_init_sem_limits_p (glibtop *server)
+#else
+void
+_glibtop_init_sem_limits_s (glibtop *server)
+#endif
 {
 #if GLIBTOP_SOLARIS_RELEASE < 51000
 
@@ -61,8 +69,13 @@ _glibtop_init_sem_limits_p (glibtop *ser
 
 /* Provides information about sysv sem limits. */
 
+#if GLIBTOP_SUID_SEM_LIMITS
 void
 glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
+#else
+void
+glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
+#endif
 {
 #if GLIBTOP_SOLARIS_RELEASE < 51000
    	kvm_t *kd = server->machine.kd;
diff -Nrup libgtop-2.19.2/sysdeps/solaris/shm_limits.c libgtop-2.19.2.mod/sysdeps/solaris/shm_limits.c
--- libgtop-2.19.2/sysdeps/solaris/shm_limits.c	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/shm_limits.c	2007-05-18 18:27:11.803445000 +0800
@@ -30,7 +30,9 @@
 static const struct nlist nlst[] = { {"glibtop_shm_limits"}, {NULL} };
 
 #if GLIBTOP_SOLARIS_RELEASE >=51000
-static const unsigned long _glibtop_sysdeps_shm_limits = 0;
+static const unsigned long _glibtop_sysdeps_shm_limits =
+(1L << GLIBTOP_IPC_SHMMAX) +
+(1L << GLIBTOP_IPC_SHMMIN);
 #else
 # if GLIBTOP_SOLARIS_RELEASE < 50900
 static const unsigned long _glibtop_sysdeps_shm_limits =
@@ -45,8 +47,13 @@ static const unsigned long _glibtop_sysd
 
 /* Init function. */
 
+#if GLIBTOP_SUID_SHM_LIMITS
 void
 _glibtop_init_shm_limits_p (glibtop *server)
+#else
+void
+_glibtop_init_shm_limits_s (glibtop *server)
+#endif
 {
 #if GLIBTOP_SOLARIS_RELEASE < 51000
 
@@ -61,8 +68,13 @@ _glibtop_init_shm_limits_p (glibtop *ser
 
 /* Provides information about sysv ipc limits. */
 
+#if GLIBTOP_SUID_SHM_LIMITS
 void
 glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
+#else
+void
+glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
+#endif
 {
 #if GLIBTOP_SOLARIS_RELEASE < 51000
 
diff -Nrup libgtop-2.19.2/sysdeps/solaris/siglist.c libgtop-2.19.2.mod/sysdeps/solaris/siglist.c
--- libgtop-2.19.2/sysdeps/solaris/siglist.c	2007-04-27 06:27:38.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/siglist.c	2007-05-18 16:43:23.348125000 +0800
@@ -61,6 +61,7 @@ const glibtop_signame glibtop_sys_siglis
    { 35, "SIGTHAW", "Checkpoint Thaw" },
    { 36, "SIGCANCEL","Thread Cancelation" },
    { 37, "SIGLOST", "Resource Lost" },
+#if GLIBTOP_SOLARIS_RELEASE < 50900    /* S8 */   
    { 38, "SIGRTMIN","First Realtime Signal" },
    { 39, "SIGRTMIN+1", "Second Realtime Signal" },
    { 40, "SIGRTMIN+2", "Third Realtime Signal" },
@@ -69,5 +70,30 @@ const glibtop_signame glibtop_sys_siglis
    { 43, "SIGRTMAX-2", "Third Last Realtime Signal" },
    { 44, "SIGRTMAX-1", "Second Last Realtime Signal" },
    { 45, "SIGRTMAX", "Last Realtime Signal" },
+#endif
+#if GLIBTOP_SOLARIS_RELEASE >= 50900
+   { 38, "SIGXRES","Resource Control Exceeded" },
+#if GLIBTOP_SOLARIS_RELEASE <51000	/* signal here existed in s9 */
+   { 39, "SIGRTMIN","First Realtime Signal" },
+   { 40, "SIGRTMIN+1", "Second Realtime Signal" },
+   { 41, "SIGRTMIN+2", "Third Realtime Signal" },
+   { 42, "SIGRTMIN+3", "Fourth Realtime Signal" },
+   { 43, "SIGRTMAX-3", "Fourth Last Realtime Signal" },
+   { 44, "SIGRTMAX-2", "Third Last Realtime Signal" },
+   { 45, "SIGRTMAX-1", "Second Last Realtime Signal" },
+   { 46, "SIGRTMAX", "Last Realtime Signal" },
+#else /*  signal here existed in s10 and s11 */
+   { 39, "SIGJVM1","Reserved signal for Java Virtual Machine" },
+   { 40, "SIGJVM1","Reserved signal for Java Virtual Machine" },
+   { 41, "SIGRTMIN","First Realtime Signal" },
+   { 42, "SIGRTMIN+1", "Second Realtime Signal" },
+   { 43, "SIGRTMIN+2", "Third Realtime Signal" },
+   { 44, "SIGRTMIN+3", "Fourth Realtime Signal" },
+   { 45, "SIGRTMAX-3", "Fourth Last Realtime Signal" },
+   { 46, "SIGRTMAX-2", "Third Last Realtime Signal" },
+   { 47, "SIGRTMAX-1", "Second Last Realtime Signal" },
+   { 48, "SIGRTMAX", "Last Realtime Signal" },
+#endif
+#endif
    {  0, NULL, NULL }
 };
diff -Nrup libgtop-2.19.2/sysdeps/solaris/sysinfo.c libgtop-2.19.2.mod/sysdeps/solaris/sysinfo.c
--- libgtop-2.19.2/sysdeps/solaris/sysinfo.c	1970-01-01 08:00:00.000000000 +0800
+++ libgtop-2.19.2.mod/sysdeps/solaris/sysinfo.c	2007-05-18 17:03:56.558810000 +0800
@@ -0,0 +1,48 @@
+/* $Id: sysinfo.c,v 1.22 2004/11/28 01:32:55 bdejean Exp $ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+   This file is part of LibGTop 1.0.
+
+   Contributed by Martin Baulig <[email protected]>, April 1998.
+
+   LibGTop is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License,
+   or (at your option) any later version.
+
+   LibGTop is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with LibGTop; see the file COPYING. If not, write to the
+   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+#include <glibtop/error.h>
+#include <glibtop/cpu.h>
+#include <glibtop/sysinfo.h>
+
+#include "glibtop_private.h"
+
+
+static const unsigned long _glibtop_sysdeps_sysinfo =
+(1L << GLIBTOP_SYSINFO_CPUINFO);
+
+static glibtop_sysinfo sysinfo = { .flags = 0 };
+
+static void
+init_sysinfo (glibtop *server)
+{
+
+}
+
+const glibtop_sysinfo *
+glibtop_get_sysinfo_s (glibtop *server)
+{
+	init_sysinfo (server);
+	return &sysinfo;
+}