15978N/Adiff -urN libgtop-2.25.91/include/glibtop/procstate.h ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/include/glibtop/procstate.h
15978N/A--- libgtop-2.25.91/include/glibtop/procstate.h 2008-05-23 22:13:20.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/include/glibtop/procstate.h 2009-02-25 17:16:38.052247000 +0000
15978N/A@@ -69,6 +69,13 @@
13939N/A int has_cpu;
13939N/A int processor;
13939N/A int last_processor;
13939N/A+
9799N/A+ gint32 nice; /*zhua: used to store nice */
9799N/A+ guint64 start_time; /* start time of process -- */
9799N/A+ guint64 vsize; /* number of pages of virtual memory ... */
9799N/A+ guint64 resident; /* number of resident set */
9799N/A+ guint load; /* cpu load for process */
9799N/A+ gint32 ppid; /* pid of parent process */
9799N/A };
9799N/A
9799N/A void glibtop_get_proc_state(glibtop_proc_state *buf, pid_t pid);
15978N/Adiff -urN libgtop-2.25.91/procmap.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/procmap.c
15978N/A--- libgtop-2.25.91/procmap.c 1970-01-01 00:00:00.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/procmap.c 2009-02-25 17:16:38.053079000 +0000
13939N/A@@ -0,0 +1,252 @@
13939N/A+/* Copyright (C) 1998-99 Martin Baulig
13939N/A+ This file is part of LibGTop 1.0.
13939N/A+
13939N/A+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
13939N/A+
13939N/A+ LibGTop is free software; you can redistribute it and/or modify it
13939N/A+ under the terms of the GNU General Public License as published by
13939N/A+ the Free Software Foundation; either version 2 of the License,
13939N/A+ or (at your option) any later version.
13939N/A+
13939N/A+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
13939N/A+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13939N/A+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13939N/A+ for more details.
13939N/A+
13939N/A+ You should have received a copy of the GNU General Public License
13939N/A+ along with LibGTop; see the file COPYING. If not, write to the
13939N/A+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
13939N/A+ Boston, MA 02111-1307, USA.
13939N/A+*/
13939N/A+
13939N/A+
13939N/A+#include <config.h>
13939N/A+#include <glibtop.h>
13939N/A+#include <glibtop/error.h>
13939N/A+#include <glibtop/procmap.h>
13939N/A+
13939N/A+#include <errno.h>
13939N/A+
13939N/A+#include "safeio.h"
13939N/A+
13939N/A+
13939N/A+static const unsigned long _glibtop_sysdeps_proc_map =
13939N/A+(1L << GLIBTOP_PROC_MAP_NUMBER) + (1L << GLIBTOP_PROC_MAP_TOTAL) +
13939N/A+(1L << GLIBTOP_PROC_MAP_SIZE);
13939N/A+static const unsigned long _glibtop_sysdeps_map_entry =
13939N/A+(1L << GLIBTOP_MAP_ENTRY_START) + (1L << GLIBTOP_MAP_ENTRY_END) +
13939N/A+(1L << GLIBTOP_MAP_ENTRY_OFFSET) + (1L << GLIBTOP_MAP_ENTRY_PERM);
13939N/A+static const unsigned long _glibtop_sysdeps_map_device =
13939N/A+(1L << GLIBTOP_MAP_ENTRY_DEVICE) + (1L << GLIBTOP_MAP_ENTRY_INODE);
13939N/A+
13939N/A+
13939N/A+/* Init function. */
13939N/A+
13939N/A+void
13939N/A+_glibtop_init_proc_map_s (glibtop *server)
13939N/A+{
13939N/A+ server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
13939N/A+}
13939N/A+
13939N/A+/* Provides detailed information about a process. */
13939N/A+
13939N/A+glibtop_map_entry *
13939N/A+glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
13939N/A+{
13939N/A+ int fd, i, nmaps, pr_err, heap;
13939N/A+
13939N/A+ char filename [BUFSIZ];
13939N/A+ /* use flags as a check condition, if it is 1, check, or, not check... zhua */
13939N/A+ int check = buf->flags;
13939N/A+ /* set flags back to 0 */
13939N/A+ buf->flags = 0;
13939N/A+
13939N/A+#if GLIBTOP_SOLARIS_RELEASE >= 50600
13939N/A+ prxmap_t *maps;
13939N/A+// struct ps_prochandle *Pr = NULL;
13939N/A+#else
13939N/A+ prmap_t *maps;
13939N/A+#endif
13939N/A+
13939N/A+ /* A few defines, to make it shorter down there */
13939N/A+
13939N/A+#ifdef HAVE_PROCFS_H
13939N/A+# define OFFSET pr_offset
13939N/A+#else
13939N/A+# define OFFSET pr_off
13939N/A+#endif
13939N/A+
13939N/A+ glibtop_map_entry *entry;
13939N/A+ struct stat inode;
13939N/A+ char buffer[BUFSIZ];
13939N/A+
13939N/A+ memset (buf, 0, sizeof (glibtop_proc_map));
12236N/A+
13939N/A+#ifdef HAVE_PROCFS_H
13939N/A+ sprintf(buffer, "/proc/%d/xmap", (int)pid);
13939N/A+#else
13939N/A+ sprintf(buffer, "/proc/%d", (int)pid);
13939N/A+#endif
13939N/A+ if((fd = s_open(buffer, O_RDONLY)) < 0)
13939N/A+ {
13939N/A+ if (errno != EPERM && errno != EACCES)
13939N/A+ glibtop_warn_io_r(server, "open (%s)", buffer);
13939N/A+ return NULL;
13939N/A+ }
13939N/A+#ifdef HAVE_PROCFS_H
13939N/A+ if(fstat(fd, &inode) < 0)
13939N/A+ {
13939N/A+ if(errno != EOVERFLOW)
13939N/A+ glibtop_warn_io_r(server, "fstat (%s)", buffer);
13939N/A+ /* else call daemon for 64-bit support */
13939N/A+ s_close(fd);
13939N/A+ return NULL;
13939N/A+ }
13939N/A+ maps = g_alloca(inode.st_size);
13939N/A+ nmaps = inode.st_size / sizeof(prxmap_t);
13939N/A+ if(s_pread(fd, maps, inode.st_size, 0) != inode.st_size)
13939N/A+ {
13939N/A+ glibtop_warn_io_r(server, "pread (%s)", buffer);
13939N/A+ s_close(fd);
13939N/A+ return NULL;
13939N/A+ }
13939N/A+#else
13939N/A+ if(ioctl(fd, PIOCNMAP, &nmaps) < 0)
13939N/A+ {
13939N/A+ glibtop_warn_io_r(server, "ioctl(%s, PIOCNMAP)", buffer);
13939N/A+ s_close(fd);
13939N/A+ return NULL;
13939N/A+ }
13939N/A+ maps = g_alloca((nmaps + 1) * sizeof(prmap_t));
13939N/A+ if(ioctl(fd, PIOCMAP, maps) < 0)
13939N/A+ {
13939N/A+ glibtop_warn_io_r(server, "ioctl(%s, PIOCMAP)", buffer);
13939N/A+ s_close(fd);
13939N/A+ return NULL;
13939N/A+ }
13939N/A+#endif
13939N/A+ buf->number = nmaps;
13939N/A+ buf->size = sizeof(glibtop_map_entry);
13939N/A+ buf->total = nmaps * sizeof(glibtop_map_entry);
13939N/A+ entry = g_malloc0(buf->total);
13939N/A+
13939N/A+//#if GLIBTOP_SOLARIS_RELEASE >= 50600
13939N/A+
13939N/A+// if(server->machine.objname && server->machine.pgrab &&
13939N/A+// server->machine.pfree)
13939N/A+// Pr = (server->machine.pgrab)(pid, 1, &pr_err);
13939N/A+//#endif
13939N/A+ for(heap = 0,i = 0; i < nmaps; ++i)
13939N/A+ {
13939N/A+ int len;
13939N/A+
13939N/A+ /* take a check to see if we need all information, if not, just get what we need..
13939N/A+ Also please see comments in get_process_memory_writable() of gnome-system-monitor zhua */
13939N/A+ if (check == 1)
13939N/A+ {
13939N/A+ if(maps[i].pr_mflags & MA_WRITE){
13939N/A+ entry[i].perm |= GLIBTOP_MAP_PERM_WRITE;
13939N/A+ entry[i].size = maps[i].pr_size;
13939N/A+ }
13939N/A+ if(maps[i].pr_mflags & MA_SHARED){
13939N/A+ entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
13939N/A+ /* here use shared_clean to store Shared Memory */
13939N/A+ entry[i].shared_clean = maps[i].pr_size;
13939N/A+ }
13939N/A+ }
13939N/A+ else
13939N/A+ if (check == 2)
13939N/A+ {
13939N/A+ if(maps[i].pr_mflags & MA_SHARED){
13939N/A+ entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
13939N/A+ /* here use shared_clean to store Shared Memory */
13939N/A+ entry[i].shared_clean = maps[i].pr_size;
13939N/A+ }
13939N/A+ }
13939N/A+ else {
13939N/A+
13939N/A+ int len, rv;
13939N/A+
13939N/A+
13939N/A+ entry[i].start = maps[i].pr_vaddr;
13939N/A+ entry[i].end = maps[i].pr_vaddr + maps[i].pr_size;
13939N/A+
13939N/A+#if GLIBTOP_SOLARIS_RELEASE >= 50600
13939N/A+
13939N/A+ if(maps[i].pr_dev != PRNODEV)
13939N/A+ {
13939N/A+ entry[i].device = maps[i].pr_dev;
13939N/A+ entry[i].inode = maps[i].pr_ino;
13939N/A+ entry[i].flags |= _glibtop_sysdeps_map_device;
13939N/A+ }
13939N/A+#endif
13939N/A+ entry[i].offset = maps[i].OFFSET;
13939N/A+ if(maps[i].pr_mflags & MA_READ)
13939N/A+ entry[i].perm |= GLIBTOP_MAP_PERM_READ;
13939N/A+ if(maps[i].pr_mflags & MA_WRITE){
13939N/A+ entry[i].perm |= GLIBTOP_MAP_PERM_WRITE;
13939N/A+ entry[i].size = maps[i].pr_size;
13939N/A+ }
13939N/A+ if(maps[i].pr_mflags & MA_EXEC)
13939N/A+ entry[i].perm |= GLIBTOP_MAP_PERM_EXECUTE;
13939N/A+ if(maps[i].pr_mflags & MA_SHARED)
13939N/A+ entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
13939N/A+ else
13939N/A+ entry[i].perm |= GLIBTOP_MAP_PERM_PRIVATE;
13939N/A+ entry[i].flags = _glibtop_sysdeps_map_entry;
13939N/A+
13939N/A+#if GLIBTOP_SOLARIS_RELEASE >= 50600
13939N/A+
13939N/A+ if(maps[i].pr_mflags & MA_ANON)
13939N/A+ {
13939N/A+ if(!heap)
13939N/A+ {
13939N/A+ ++heap;
13939N/A+ strcpy(entry[i].filename, "[ heap ]");
13939N/A+ }
13939N/A+ else
13939N/A+ if(i == nmaps - 1)
13939N/A+ strcpy(entry[i].filename, "[ stack ]");
13939N/A+ else
13939N/A+ strcpy(entry[i].filename, "[ anon ]");
13939N/A+ entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
13939N/A+ }
13939N/A+ else
13939N/A+// if(Pr)
13939N/A+// {
13939N/A+// server->machine.objname(Pr, maps[i].pr_vaddr, buffer,
13939N/A+// BUFSIZ);
13939N/A+// if((len = resolvepath(buffer, entry[i].filename,
13939N/A+// GLIBTOP_MAP_FILENAME_LEN)) > 0)
13939N/A+// {
13939N/A+// entry[i].filename[len] = 0;
13939N/A+// entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
13939N/A+// }
13939N/A+// }
13939N/A+ {
13939N/A+ g_strlcpy(buffer, maps[i].pr_mapname, sizeof buffer);
13939N/A+ /* from /path get file name */
13939N/A+ g_snprintf(filename, sizeof filename, "/proc/%d/path/%s",
13939N/A+ pid, buffer);
13939N/A+
13939N/A+ rv = readlink(filename, entry[i].filename, sizeof(entry[i].filename) - 1);
13939N/A+ /* read object, if have not, set it as NULL */
13939N/A+ if(rv < 0)
13939N/A+ rv = 0;
13939N/A+ entry[i].filename[rv] = '\0';
13939N/A+ /* now set the flags */
13939N/A+ entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
13939N/A+ }
13939N/A+#endif
13939N/A+ }
13939N/A+ }
13939N/A+
13939N/A+//#if GLIBTOP_SOLARIS_RELEASE >= 50600
13939N/A+
13939N/A+// if(Pr)
13939N/A+// server->machine.pfree(Pr);
13939N/A+//#endif
13939N/A+ buf->flags = _glibtop_sysdeps_proc_map;
13939N/A+ s_close(fd);
13939N/A+ return entry;
13939N/A+}
15978N/Adiff -urN libgtop-2.25.91/sysdeps/common/fsusage.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/common/fsusage.c
15978N/A--- libgtop-2.25.91/sysdeps/common/fsusage.c 2008-05-23 22:13:22.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/common/fsusage.c 2009-02-25 17:25:57.183257000 +0000
15978N/A@@ -149,6 +149,15 @@
15978N/A #define _glibtop_get_fsusage_read_write(S, B, P) \
15978N/A _glibtop_freebsd_get_fsusage_read_write(S, B, P)
15978N/A
15978N/A+#elif (defined(sun) || defined(__sun))
15978N/A+G_GNUC_INTERNAL void
15978N/A+_glibtop_sun_get_fsusage_read_write(glibtop *server,
15978N/A+ glibtop_fsusage *buf,
15978N/A+ const char *path);
15978N/A+
15978N/A+#define _glibtop_get_fsusage_read_write(S, B, P) \
15978N/A+ _glibtop_sun_get_fsusage_read_write(S, B, P)
15978N/A+
15978N/A #else /* default fallback */
15978N/A #warning glibtop_get_fsusage .read .write are not implemented.
15978N/A static inline void
15978N/Adiff -urN libgtop-2.25.91/sysdeps/common/mountlist.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/common/mountlist.c
15978N/A--- libgtop-2.25.91/sysdeps/common/mountlist.c 2008-05-23 22:13:22.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/common/mountlist.c 2009-02-25 17:16:38.053543000 +0000
15978N/A@@ -591,6 +591,17 @@
12236N/A
12236N/A for (cur = &entries[0]; cur != NULL; cur = next) {
12236N/A
12236N/A+ /*zhua: delete these 2 type of fs: objfs,ctfs */
12236N/A+ if (!strcmp(cur->me_type, "objfs") || !strcmp(cur->me_type,"ctfs")){
12236N/A+ /* free current mount_entry and move to the next */
12236N/A+ next = cur->me_next;
12236N/A+ g_free(cur->me_devname);
12236N/A+ g_free(cur->me_mountdir);
12236N/A+ g_free(cur->me_type);
12236N/A+ g_free(cur);
12236N/A+ continue;
12236N/A+ }
12236N/A+
12236N/A if(all_fs || !ignore_mount_entry(cur)) {
12236N/A /* add a new glibtop_mountentry */
12236N/A glibtop_mountentry e;
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/Makefile.am ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/Makefile.am
15978N/A--- libgtop-2.25.91/sysdeps/solaris/Makefile.am 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/Makefile.am 2009-02-25 17:27:23.462319000 +0000
15978N/A@@ -8,7 +8,8 @@
15978N/A proclist.c procstate.c procuid.c \
8402N/A proctime.c procmem.c procsignal.c \
8402N/A prockernel.c procsegment.c procargs.c \
15978N/A- procopenfiles.c \
15978N/A+ procopenfiles.c sysinfo.c fsusage.c procwd.c \
15978N/A+ glibtop_private.c procaffinity.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)
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/cpu.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/cpu.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/cpu.c 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/cpu.c 2009-02-25 17:16:38.055204000 +0000
15978N/A@@ -34,6 +34,7 @@
8402N/A
8402N/A static const unsigned long _glibtop_sysdeps_cpu_all =
8402N/A (1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
13939N/A+(1L << GLIBTOP_CPU_NICE) + /* this value is needed by multiload */
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) +
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/fsusage.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/fsusage.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/fsusage.c 1970-01-01 00:00:00.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/fsusage.c 2009-02-25 17:20:33.608888000 +0000
15978N/A@@ -0,0 +1,99 @@
15978N/A+#include <config.h>
15978N/A+#include <glibtop.h>
15978N/A+#include <glibtop/error.h>
15978N/A+#include <glibtop/fsusage.h>
15978N/A+#include <glibtop/union.h>
15978N/A+
15978N/A+#include "glibtop_private.h"
15978N/A+
15978N/A+#include <glib.h>
15978N/A+
15978N/A+#include <unistd.h>
15978N/A+#include <kstat.h>
15978N/A+#include <sys/types.h>
15978N/A+#include <sys/stat.h>
15978N/A+#include <sys/statvfs.h>
15978N/A+
15978N/A+#include <stdio.h>
15978N/A+#include <string.h>
15978N/A+#include <stdlib.h>
15978N/A+
15978N/A+G_GNUC_INTERNAL void
15978N/A+_glibtop_sun_get_fsusage_read_write(glibtop *server,
15978N/A+ glibtop_fsusage *buf,
15978N/A+ const char *path)
15978N/A+{
15978N/A+ struct statvfs64 statvfsbuf;
15978N/A+ char ksname[KSTAT_STRLEN + 1];
15978N/A+ kstat_ctl_t * const kctl = server->machine.kc;
15978N/A+ kstat_t *ksp;
15978N/A+ kstat_io_t kio;
15978N/A+ kstat_named_t *kread, *kwrite;
15978N/A+ int i;
15978N/A+
15978N/A+ /*
15978N/A+ * get a kstat handle and update the user's kstat chain
15978N/A+ */
15978N/A+ if( kctl == NULL ){
15978N/A+ glibtop_warn_io_r (server, "kstat_open ()");
15978N/A+ return;
15978N/A+ }
15978N/A+
15978N/A+ /* make sure we have current data */
15978N/A+ while( kstat_chain_update( kctl ) != 0 )
15978N/A+ ;
15978N/A+
15978N/A+ for (ksp = kctl->kc_chain, i =0; ksp != NULL; ksp = ksp->ks_next, i++) {
15978N/A+ if (ksp->ks_type == KSTAT_TYPE_IO && strcmp(ksp->ks_class,"disk") == 0) {
15978N/A+ kstat_read(kctl, ksp, &kio);
15978N/A+ buf->read += kio.nread;
15978N/A+ buf->write += kio.nwritten;
15978N/A+ }
15978N/A+ }
15978N/A+#if 0
15978N/A+ /* these codes keep here, because they are a good way to get the
15978N/A+ fsusage information, but at the moment, the interfaces used
15978N/A+ are not public or stable. so let's use them when public...
15978N/A+ */
15978N/A+ /*
15978N/A+ * get a kstat handle and update the user's kstat chain
15978N/A+ */
15978N/A+ if( kctl == NULL ){
15978N/A+ glibtop_warn_io_r (server, "kstat_open ()");
15978N/A+ return;
15978N/A+ }
15978N/A+
15978N/A+ while( kstat_chain_update( kctl ) != 0 )
15978N/A+ ;
15978N/A+
15978N/A+ if (statvfs64(path, &statvfsbuf) != 0) {
15978N/A+ glibtop_warn_io_r (server, "kstat_open ()");
15978N/A+ return;
15978N/A+ }
15978N/A+ snprintf(ksname, KSTAT_STRLEN, "%s%lx", VOPSTATS_STR,
15978N/A+ statvfsbuf.f_fsid);
15978N/A+
15978N/A+ /*
15978N/A+ * traverse the kstat chain
15978N/A+ * to find the appropriate statistics
15978N/A+ */
15978N/A+ if( (ksp = kstat_lookup( kctl,
15978N/A+ "unix", 0, ksname )) == NULL ) {
15978N/A+ return;
15978N/A+ }
15978N/A+ if( kstat_read( kctl, ksp, NULL ) == -1 ) {
15978N/A+ return;
15978N/A+ }
15978N/A+
15978N/A+ kread = (kstat_named_t *)kstat_data_lookup(ksp,"read_bytes");
15978N/A+ if( kread != NULL ) {
15978N/A+ buf->read = kread->value.ull;
15978N/A+ }
15978N/A+
15978N/A+ kwrite = (kstat_named_t *)kstat_data_lookup(ksp,"write_bytes");
15978N/A+ if( kwrite != NULL ) {
15978N/A+ buf->write = kwrite->value.ull;
15978N/A+ }
15978N/A+#endif
15978N/A+ buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
15978N/A+}
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/glibtop_machine.h ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_machine.h
15978N/A--- libgtop-2.25.91/sysdeps/solaris/glibtop_machine.h 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_machine.h 2009-02-25 17:16:38.055426000 +0000
15978N/A@@ -61,14 +61,14 @@
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
13939N/A+// void *libproc; /* libproc handle */
13939N/A+//#if GLIBTOP_SOLARIS_RELEASE >= 50600
13939N/A+// void (*objname)(void *, uintptr_t, const char *, size_t);
13939N/A+// struct ps_prochandle *(*pgrab)(pid_t, int, int *);
13939N/A+// void (*pfree)(void *);
13939N/A+//#else
8402N/A void *filler[3];
8402N/A-#endif
13939N/A+//#endif
8402N/A };
8402N/A
8402N/A G_END_DECLS
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/glibtop_private.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_private.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/glibtop_private.c 1970-01-01 00:00:00.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_private.c 2009-02-25 17:16:38.055744000 +0000
10671N/A@@ -0,0 +1,203 @@
10671N/A+#include <config.h>
10671N/A+#include <glibtop.h>
10671N/A+#include <glibtop/error.h>
10671N/A+
10671N/A+#include "glibtop_private.h"
10671N/A+
10671N/A+#include <glib.h>
10671N/A+
10671N/A+#include <string.h>
10671N/A+#include <stdlib.h>
10671N/A+#include <stdarg.h>
10671N/A+
10671N/A+#include <fcntl.h>
10671N/A+#include <unistd.h>
10671N/A+
10671N/A+#if 0
10671N/A+unsigned long long
10671N/A+get_scaled(const char *buffer, const char *key)
10671N/A+{
10671N/A+ const char *ptr;
10671N/A+ char *next;
10671N/A+ unsigned long long value = 0;
10671N/A+
10671N/A+ if (G_LIKELY((ptr = strstr(buffer, key))))
10671N/A+ {
10671N/A+ ptr += strlen(key);
10671N/A+ value = strtoull(ptr, &next, 0);
10671N/A+
10671N/A+ for ( ; *next; ++next) {
10671N/A+ if (*next == 'k') {
10671N/A+ value *= 1024;
10671N/A+ break;
10671N/A+ } else if (*next == 'M') {
10671N/A+ value *= 1024 * 1024;
10671N/A+ break;
10671N/A+ }
10671N/A+ }
10671N/A+ } else
10671N/A+ g_warning("Could not read key '%s' in buffer '%s'",
10671N/A+ key, buffer);
10671N/A+
10671N/A+ return value;
10671N/A+}
10671N/A+
10671N/A+
10671N/A+char *
10671N/A+skip_token (const char *p)
10671N/A+{
10671N/A+ p = next_token(p);
10671N/A+ while (*p && !isspace(*p)) p++;
10671N/A+ p = next_token(p);
10671N/A+ return (char *)p;
10671N/A+}
10671N/A+
10671N/A+
10671N/A+/*
10671N/A+ * Read functions
10671N/A+ */
10671N/A+enum TRY_FILE_TO_BUFFER
10671N/A+{
10671N/A+ TRY_FILE_TO_BUFFER_OK = 0,
10671N/A+ TRY_FILE_TO_BUFFER_OPEN = -1,
10671N/A+ TRY_FILE_TO_BUFFER_READ = -2
10671N/A+};
10671N/A+
10671N/A+int try_file_to_buffer(char *buffer, const char *format, ...)
10671N/A+{
10671N/A+ char path[4096];
10671N/A+ int fd;
10671N/A+ ssize_t len;
10671N/A+ va_list pa;
10671N/A+
10671N/A+ va_start(pa, format);
10671N/A+
10671N/A+ /* C99 also provides vsnprintf */
10671N/A+ g_vsnprintf(path, sizeof path, format, pa);
10671N/A+
10671N/A+ va_end(pa);
10671N/A+
10671N/A+ buffer [0] = '\0';
10671N/A+
10671N/A+ if((fd = open (path, O_RDONLY)) < 0)
10671N/A+ return TRY_FILE_TO_BUFFER_OPEN;
10671N/A+
10671N/A+ len = read (fd, buffer, BUFSIZ-1);
10671N/A+ close (fd);
10671N/A+
10671N/A+ if (len < 0)
10671N/A+ return TRY_FILE_TO_BUFFER_READ;
10671N/A+
10671N/A+ buffer [len] = '\0';
10671N/A+
10671N/A+ return TRY_FILE_TO_BUFFER_OK;
10671N/A+}
10671N/A+
10671N/A+
10671N/A+void
10671N/A+file_to_buffer(glibtop *server, char *buffer, const char *filename)
10671N/A+{
10671N/A+ switch(try_file_to_buffer(buffer, filename))
10671N/A+ {
10671N/A+ case TRY_FILE_TO_BUFFER_OPEN:
10671N/A+ glibtop_error_io_r (server, "open (%s)", filename);
10671N/A+ case TRY_FILE_TO_BUFFER_READ:
10671N/A+ glibtop_error_io_r (server, "read (%s)", filename);
10671N/A+ }
10671N/A+}
10671N/A+
10671N/A+
10671N/A+
10671N/A+
10671N/A+static unsigned long
10671N/A+read_boot_time(glibtop *server)
10671N/A+{
10671N/A+ char buffer[BUFSIZ];
10671N/A+ char *btime;
10671N/A+
10671N/A+ file_to_buffer(server, buffer, "/proc/stat");
10671N/A+
10671N/A+ btime = strstr(buffer, "btime");
10671N/A+
10671N/A+ if (!btime) {
10671N/A+ glibtop_warn_io_r(server, "cannot find btime in /proc/stat");
10671N/A+ return 0UL;
10671N/A+ }
10671N/A+
10671N/A+ btime = skip_token(btime);
10671N/A+ return strtoul(btime, NULL, 10);
10671N/A+}
10671N/A+
10671N/A+
10671N/A+
10671N/A+unsigned long
10671N/A+get_boot_time(glibtop *server)
10671N/A+{
10671N/A+ static unsigned long boot_time = 0UL;
10671N/A+
10671N/A+ if(G_UNLIKELY(!boot_time))
10671N/A+ {
10671N/A+ boot_time = read_boot_time(server);
10671N/A+ }
10671N/A+
10671N/A+ return boot_time;
10671N/A+}
10671N/A+
10671N/A+
10671N/A+size_t
10671N/A+get_page_size(void)
10671N/A+{
10671N/A+ static size_t pagesize = 0;
10671N/A+
10671N/A+ if(G_UNLIKELY(!pagesize))
10671N/A+ {
10671N/A+ pagesize = getpagesize();
10671N/A+ }
10671N/A+
10671N/A+ return pagesize;
10671N/A+}
10671N/A+
10671N/A+
10671N/A+
10671N/A+gboolean
10671N/A+check_cpu_line(glibtop *server, const char *line, unsigned i)
10671N/A+{
10671N/A+ char start[10];
10671N/A+
10671N/A+ g_snprintf(start, sizeof start, "cpu%u", i);
10671N/A+
10671N/A+ return g_str_has_prefix(line, start);
10671N/A+}
10671N/A+
10671N/A+
10671N/A+
10671N/A+gboolean
10671N/A+has_sysfs(void)
10671N/A+{
10671N/A+ static gboolean init;
10671N/A+ static gboolean sysfs;
10671N/A+
10671N/A+ if (G_UNLIKELY(!init)) {
10671N/A+ sysfs = g_file_test("/sys", G_FILE_TEST_IS_DIR);
10671N/A+ init = TRUE;
10671N/A+ }
10671N/A+
10671N/A+ return sysfs;
10671N/A+}
10671N/A+#endif
10671N/A+
10671N/A+
10671N/A+gboolean safe_readlink(const char *path, char *buf, size_t bufsiz)
10671N/A+{
10671N/A+ ssize_t ret;
10671N/A+
10671N/A+ ret = readlink(path, buf, bufsiz - 1);
10671N/A+
10671N/A+ if (ret == -1) {
10671N/A+ g_warning("Could not read link %s : %s", path, strerror(errno));
10671N/A+ return FALSE;
10671N/A+ }
10671N/A+
10671N/A+ buf[ret] = '\0';
10671N/A+ return TRUE;
10671N/A+}
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/glibtop_private.h ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_private.h
15978N/A--- libgtop-2.25.91/sysdeps/solaris/glibtop_private.h 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_private.h 2009-02-25 17:16:38.057019000 +0000
15978N/A@@ -60,6 +60,8 @@
10671N/A /* Reread kstat chains */
10671N/A void glibtop_get_kstats(glibtop *);
10671N/A
10671N/A+gboolean safe_readlink(const char *path, char *buf, size_t bufsiz);
10671N/A+
10671N/A G_END_DECLS
10671N/A
10671N/A #endif /* __GLIBTOP_PRIVATE_H__ */
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/glibtop_server.h ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_server.h
15978N/A--- libgtop-2.25.91/sysdeps/solaris/glibtop_server.h 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_server.h 2009-02-25 17:16:38.057265000 +0000
15978N/A@@ -29,9 +29,15 @@
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
15978N/A@@ -44,7 +50,10 @@
10671N/A #define GLIBTOP_SUID_PROC_MAP 0
10671N/A #define GLIBTOP_SUID_NETLOAD 0
10671N/A #define GLIBTOP_SUID_NETLIST 0
10671N/A+#define GLIBTOP_SUID_PROC_WD 0
10671N/A #define GLIBTOP_SUID_PPP 0
13939N/A+#define GLIBTOP_SUID_PROC_AFFINITY 0
13939N/A+
10671N/A
10671N/A G_END_DECLS
13939N/A
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/msg_limits.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/msg_limits.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/msg_limits.c 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/msg_limits.c 2009-02-25 17:16:38.058081000 +0000
15978N/A@@ -37,14 +37,24 @@
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;
13939N/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
10671N/A _glibtop_init_msg_limits_p (glibtop *server)
8922N/A+#else
8922N/A+void
10671N/A+_glibtop_init_msg_limits_s (glibtop *server)
8922N/A+#endif
8922N/A {
8922N/A #if GLIBTOP_SOLARIS_RELEASE < 51000
8922N/A
15978N/A@@ -59,8 +69,13 @@
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
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/netload.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/netload.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/netload.c 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/netload.c 2009-02-25 17:16:38.059013000 +0000
13939N/A@@ -37,6 +37,17 @@
8922N/A
13939N/A #include <net/if.h>
10671N/A
12236N/A+#ifdef HAVE_IFADDRS_H
12236N/A+/* needed for IPV6 support */
12236N/A+
12236N/A+#include <ifaddrs.h>
12236N/A+
12236N/A+#ifndef IN6_IS_ADDR_GLOBAL
12236N/A+#define IN6_IS_ADDR_GLOBAL(a) \
12236N/A+ (((((__const uint8_t *) (a))[0] & 0xff) == 0x3f \
12236N/A+ || (((__const uint8_t *) (a))[0] & 0xff) == 0x20))
12236N/A+#endif
12236N/A+#endif /* HAVE_IFADDRS_H */
12236N/A
13939N/A static const unsigned long _glibtop_sysdeps_netload =
13939N/A (1L << GLIBTOP_NETLOAD_ERRORS_IN) +
15978N/A@@ -89,6 +100,72 @@
13939N/A _glibtop_sysdeps_netload_packets;
13939N/A }
12236N/A
12236N/A+#ifdef HAVE_IFADDRS_H
12236N/A+
12236N/A+static void get_ipv6(glibtop *server, glibtop_netload *buf,
12236N/A+ const char *interface)
12236N/A+{
12236N/A+/*
12236N/A+ * remove this code, because they are not available at Solaris, but keep them here for reference.
12236N/A+ * in fact, the function will not be called at Solaris, because HAVE_IFADDRS_H don't def.
12236N/A+ *
12236N/A+*/
12236N/A+#if 0
12236N/A+ struct ifaddrs *ifa0, *ifr6;
12236N/A+
12236N/A+ if(getifaddrs (&ifa0) != 0)
12236N/A+ {
12236N/A+ glibtop_warn_r(server, "getifaddrs failed : %s", g_strerror(errno));
12236N/A+ return;
12236N/A+ }
12236N/A+
12236N/A+ for (ifr6 = ifa0; ifr6; ifr6 = ifr6->ifa_next) {
12236N/A+ if (strcmp (ifr6->ifa_name, interface) == 0
12236N/A+ && ifr6->ifa_addr != NULL
12236N/A+ && ifr6->ifa_addr->sa_family == AF_INET6)
12236N/A+ break;
12236N/A+ }
12236N/A+
12236N/A+ if(!ifr6) goto free_ipv6;
12236N/A+
12236N/A+ memcpy(buf->address6,
12236N/A+ &((struct sockaddr_in6 *) ifr6->ifa_addr)->sin6_addr,
12236N/A+ 16);
12236N/A+
12236N/A+ memcpy(buf->prefix6,
12236N/A+ &((struct sockaddr_in6 *) ifr6->ifa_netmask)->sin6_addr,
12236N/A+ 16);
12236N/A+
12236N/A+
12236N/A+ if (IN6_IS_ADDR_LINKLOCAL (buf->address6))
12236N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_LINK;
12236N/A+
12236N/A+ else if (IN6_IS_ADDR_SITELOCAL (buf->address6))
12236N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_SITE;
12236N/A+
12236N/A+ else if (IN6_IS_ADDR_GLOBAL (buf->address6)
12236N/A+ || IN6_IS_ADDR_MC_ORGLOCAL (buf->address6)
12236N/A+ || IN6_IS_ADDR_V4COMPAT (buf->address6)
12236N/A+ || IN6_IS_ADDR_MULTICAST (buf->address6)
12236N/A+ || IN6_IS_ADDR_UNSPECIFIED (buf->address6)
12236N/A+ )
12236N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_GLOBAL;
12236N/A+
12236N/A+ else if (IN6_IS_ADDR_LOOPBACK (buf->address6))
12236N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_HOST;
12236N/A+
12236N/A+ else
12236N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_UNKNOWN;
12236N/A+
12236N/A+ buf->flags |= _glibtop_sysdeps_netload_6;
12236N/A+
12236N/A+ free_ipv6:
12236N/A+ freeifaddrs(ifa0);
12236N/A+#endif
12236N/A+}
12236N/A+
12236N/A+#endif /* HAVE_IFADDRS_H */
12236N/A+
13939N/A static int
13939N/A solaris_stats(glibtop *server,
13939N/A glibtop_netload *buf,
15978N/A@@ -245,6 +322,13 @@
13939N/A buf->subnet = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr;
13939N/A buf->flags |= (1L << GLIBTOP_NETLOAD_SUBNET);
13939N/A }
12236N/A+
13939N/A+/* g_strlcpy (ifr.ifr_name, interface, sizeof ifr.ifr_name);
13939N/A+ if (!ioctl (skfd, SIOCGIFHWADDR, &ifr)) {
13939N/A+ memcpy(buf->hwaddress, &ifr.ifr_hwaddr.sa_data, 8);
13939N/A+ buf->flags |= (1L << GLIBTOP_NETLOAD_HWADDRESS);
13939N/A+ }*/
12236N/A+
13939N/A close (skfd);
13939N/A }
13939N/A
15978N/A@@ -254,4 +338,7 @@
13939N/A
13939N/A solaris_stats(server, buf, interface);
13939N/A
12236N/A+#ifdef HAVE_IFADDRS_H
12236N/A+ get_ipv6(server, buf, interface);
12236N/A+#endif /* HAVE_IFADDRS_H */
12236N/A }
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/open.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/open.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/open.c 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/open.c 2009-02-25 17:16:38.060014000 +0000
15978N/A@@ -209,34 +209,34 @@
8922N/A }
8922N/A }
8922N/A
8922N/A- /* Now let's have a bit of magic dust... */
13939N/A+// /* Now let's have a bit of magic dust... */
13939N/A
8922N/A-#if GLIBTOP_SOLARIS_RELEASE >= 50600
13939N/A+//#if GLIBTOP_SOLARIS_RELEASE >= 50600
13939N/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;
13939N/A+ // dl = dlopen("/usr/lib/libproc.so", RTLD_LAZY);
13939N/A+ // if(server->machine.libproc)
13939N/A+// // dlclose(server->machine.libproc);
13939N/A+ // server->machine.libproc = dl;
13939N/A+ // if(dl)
13939N/A+ // {
13939N/A+ // void *func;
13939N/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
13939N/A+ // func = dlsym(dl, "Pobjname"); /* Solaris 8 */
13939N/A+ // if(!func)
13939N/A+// func = dlsym(dl, "proc_objname"); /* Solaris 7 */
13939N/A+ // server->machine.objname = (void (*)
13939N/A+// (void *, uintptr_t, const char *, size_t))func;
13939N/A+ // server->machine.pgrab = (struct ps_prochandle *(*)(pid_t, int, int *))
13939N/A+// dlsym(dl, "Pgrab");
13939N/A+ // server->machine.pfree = (void (*)(void *))dlsym(dl, "Pfree");
13939N/A+ //
13939N/A+ // }
13939N/A+ // else
13939N/A+ // {
13939N/A+ // server->machine.objname = NULL;
13939N/A+ // server->machine.pgrab = NULL;
13939N/A+ // server->machine.pfree = NULL;
13939N/A+ // }
13939N/A+//#endif
8922N/A server->machine.me = getpid();
8922N/A }
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/procaffinity.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procaffinity.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/procaffinity.c 1970-01-01 00:00:00.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procaffinity.c 2009-02-25 17:16:38.060320000 +0000
13939N/A@@ -0,0 +1,84 @@
13939N/A+/* Copyright (C) 2007 Joe Marcus Clarke <marcus@FreeBSD.org>
13939N/A+ This file is part of LibGTop 2.
13939N/A+
13939N/A+ LibGTop is free software; you can redistribute it and/or modify it
13939N/A+ under the terms of the GNU General Public License as published by
13939N/A+ the Free Software Foundation; either version 2 of the License,
13939N/A+ or (at your option) any later version.
13939N/A+
13939N/A+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
13939N/A+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13939N/A+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13939N/A+ for more details.
13939N/A+
13939N/A+ You should have received a copy of the GNU General Public License
13939N/A+ along with LibGTop; see the file COPYING. If not, write to the
13939N/A+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
13939N/A+ Boston, MA 02111-1307, USA.
13939N/A+*/
13939N/A+
13939N/A+#include <config.h>
13939N/A+#include <glibtop/procaffinity.h>
13939N/A+#include <glibtop/error.h>
13939N/A+
13939N/A+#include <glibtop_private.h>
13939N/A+
13939N/A+#include <sys/param.h>
13939N/A+
13939N/A+void
13939N/A+_glibtop_init_proc_affinity_s(glibtop *server)
13939N/A+{
13939N/A+/*
13939N/A+ server->sysdeps.proc_affinity =
13939N/A+ (1 << GLIBTOP_PROC_AFFINITY_NUMBER) |
13939N/A+ (1 << GLIBTOP_PROC_AFFINITY_ALL);
13939N/A+*/
13939N/A+}
13939N/A+
13939N/A+
13939N/A+guint16 *
13939N/A+glibtop_get_proc_affinity_s(glibtop *server, glibtop_proc_affinity *buf, pid_t pid)
13939N/A+{
13939N/A+/*
13939N/A+#if __FreeBSD_version > 800024
13939N/A+ id_t id;
13939N/A+ cpulevel_t level;
13939N/A+ cpuwhich_t which;
13939N/A+ cpuset_t mask;
13939N/A+ size_t i;
13939N/A+ GArray* cpus;
13939N/A+
13939N/A+ memset(buf, 0, sizeof *buf);
13939N/A+
13939N/A+ which = CPU_WHICH_PID;
13939N/A+ level = CPU_LEVEL_WHICH;
13939N/A+ id = pid;
13939N/A+
13939N/A+ if (cpuset_getaffinity(level, which, id, sizeof(mask), &mask) != 0) {
13939N/A+ glibtop_error_r(server, "cpuset_getaffinity failed");
13939N/A+ return NULL;
13939N/A+ }
13939N/A+
13939N/A+ cpus = g_array_new(FALSE, FALSE, sizeof(guint16));
13939N/A+
13939N/A+ for (i = 0; i < MIN(CPU_SETSIZE, (size_t)(server->ncpu + 1)); i++) {
13939N/A+ if (CPU_ISSET(i, &mask)) {
13939N/A+ guint16 n = i;
13939N/A+ g_array_append_val(cpus, n);
13939N/A+ }
13939N/A+ }
13939N/A+
13939N/A+ buf->number = cpus->len;
13939N/A+ buf->all = (cpus->len == (size_t)(server->ncpu + 1));
13939N/A+ buf->flags = (1 << GLIBTOP_PROC_AFFINITY_NUMBER)
13939N/A+ | (1 << GLIBTOP_PROC_AFFINITY_ALL);
13939N/A+
13939N/A+ return (guint16*) g_array_free(cpus, FALSE);
13939N/A+#else
13939N/A+ memset(buf, 0, sizeof *buf);
13939N/A+
13939N/A+ return NULL;
13939N/A+#endif
13939N/A+*/
13939N/A+}
13939N/A+
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/procmap.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procmap.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/procmap.c 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procmap.c 2009-02-25 17:16:38.061314000 +0000
15978N/A@@ -54,9 +54,16 @@
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;
13939N/A+
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;
13939N/A+
8575N/A #if GLIBTOP_SOLARIS_RELEASE >= 50600
8402N/A prxmap_t *maps;
9869N/A- struct ps_prochandle *Pr = NULL;
13939N/A+// struct ps_prochandle *Pr = NULL;
9869N/A #else
9869N/A prmap_t *maps;
9869N/A #endif
15978N/A@@ -123,16 +130,44 @@
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
13939N/A+//#if GLIBTOP_SOLARIS_RELEASE >= 50600
13939N/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
13939N/A+// if(server->machine.objname && server->machine.pgrab &&
13939N/A+// server->machine.pfree)
13939N/A+// Pr = (server->machine.pgrab)(pid, 1, &pr_err);
13939N/A+//#endif
8402N/A for(heap = 0,i = 0; i < nmaps; ++i)
8402N/A {
13939N/A int len;
13939N/A
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+ }
10671N/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+ }
9869N/A+ else
9869N/A+ if (check == 2)
9869N/A+ {
9869N/A+ if(maps[i].pr_mflags & MA_SHARED){
9869N/A+ entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
9869N/A+ /* here use shared_clean to store Shared Memory */
9869N/A+ entry[i].shared_clean = maps[i].pr_size;
9869N/A+ }
9869N/A+ }
9311N/A+ else {
9311N/A+
8402N/A+ int len, rv;
13939N/A+
13939N/A+
8402N/A entry[i].start = maps[i].pr_vaddr;
8402N/A entry[i].end = maps[i].pr_vaddr + maps[i].pr_size;
13939N/A
15978N/A@@ -177,25 +212,40 @@
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- }
13939N/A-#endif
13939N/A- }
13939N/A-
13939N/A-#if GLIBTOP_SOLARIS_RELEASE >= 50600
13939N/A-
13939N/A- if(Pr)
13939N/A- server->machine.pfree(Pr);
13939N/A-#endif
13939N/A+// if(Pr)
13939N/A+// {
13939N/A+// server->machine.objname(Pr, maps[i].pr_vaddr, buffer,
13939N/A+// BUFSIZ);
13939N/A+// if((len = resolvepath(buffer, entry[i].filename,
13939N/A+// GLIBTOP_MAP_FILENAME_LEN)) > 0)
13939N/A+// {
13939N/A+// entry[i].filename[len] = 0;
13939N/A+// entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
13939N/A+// }
13939N/A+// }
13939N/A+ {
10671N/A+ g_strlcpy(buffer, maps[i].pr_mapname, sizeof buffer);
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+ }
13939N/A+#endif
10671N/A+ }
13939N/A+ }
13939N/A+
13939N/A+//#if GLIBTOP_SOLARIS_RELEASE >= 50600
13939N/A+
13939N/A+// if(Pr)
13939N/A+// server->machine.pfree(Pr);
13939N/A+//#endif
8402N/A buf->flags = _glibtop_sysdeps_proc_map;
8402N/A s_close(fd);
8402N/A return entry;
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/procmem.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procmem.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/procmem.c 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procmem.c 2009-02-25 17:16:38.061600000 +0000
10671N/A@@ -22,12 +22,14 @@
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
9869N/A static const unsigned long _glibtop_sysdeps_proc_mem =
9869N/A (1L << GLIBTOP_PROC_MEM_SIZE) + (1L << GLIBTOP_PROC_MEM_VSIZE) +
9869N/A-(1L << GLIBTOP_PROC_MEM_RESIDENT) + (1L << GLIBTOP_PROC_MEM_RSS);
9869N/A+(1L << GLIBTOP_PROC_MEM_RESIDENT) + (1L << GLIBTOP_PROC_MEM_RSS) +
9869N/A+(1L << GLIBTOP_PROC_MEM_SHARE);
9869N/A
9869N/A /* Init function. */
9869N/A
15978N/A@@ -61,5 +63,31 @@
8402N/A buf->size = buf->vsize = psinfo.pr_size << pagesize << 10;
8402N/A buf->resident = buf->rss = psinfo.pr_rssize << pagesize << 10;
8402N/A #endif
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 }
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/procstate.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procstate.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/procstate.c 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procstate.c 2009-02-25 17:16:38.062411000 +0000
15978N/A@@ -62,6 +62,26 @@
10671N/A buf->gid = psinfo.pr_egid;
9799N/A buf->ruid = psinfo.pr_uid;
9799N/A buf->rgid = psinfo.pr_gid;
13939N/A+ /* zhua: get some value here, so that we don't need run open/pread/close psinfo later,
9799N/A+ and can delete some other call for psinfo open/pread/close. it will save lots of time*/
9799N/A+#ifdef HAVE_PROCFS_H
9799N/A+ buf->nice = psinfo.pr_lwp.pr_nice - NZERO;
9799N/A+#else
9799N/A+ buf->nice = psinfo.pr_nice - NZERO;
9799N/A+#endif
13939N/A+ buf->start_time = psinfo.pr_start.tv_sec;
9799N/A+ buf->ppid = psinfo.pr_ppid;
9799N/A+
9799N/A+#ifdef HAVE_PROCFS_H
9799N/A+ buf->vsize = psinfo.pr_size << 10;
9799N/A+ buf->resident= psinfo.pr_rssize << 10;
10671N/A+ buf->load = (guint) psinfo.pr_lwp.pr_pctcpu * 100 / (guint) 0x8000;
9799N/A+#else
9799N/A+ buf->vsize = psinfo.pr_size << pagesize << 10;
9799N/A+ buf->resident = psinfo.pr_rssize << pagesize << 10;
9799N/A+ buf->load = (guint) psinfo.pr_lwp.pr_pctcpu * 100 / (guint) 0x8000;
9799N/A+#endif
10671N/A+
10671N/A
9799N/A #ifdef HAVE_PROCFS_H
9799N/A switch(psinfo.pr_lwp.pr_state)
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/proctime.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/proctime.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/proctime.c 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/proctime.c 2009-02-25 17:16:38.062715000 +0000
15978N/A@@ -43,6 +43,11 @@
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;
13939N/A GTimeVal time;
8922N/A
15978N/A@@ -52,19 +57,27 @@
8922N/A
8922N/A if(pid)
8922N/A {
10671N/A+ /* zhua remove this function call, because we can change to get start_time in
13939N/A+ glibtop_get_proc_state(), it don't need open psinfo again here */
9799N/A+
8922N/A+ if (glibtop_get_proc_data_psinfo_s(server, &pinfo, pid))
8922N/A+ return;
13939N/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;
13939N/A+// g_get_current_time (&time);
13939N/A+// /* prusage.pr_rtime.tv_sec is the during that the process existed */
13939N/A+ // buf->start_time = time.tv_sec - prusage.pr_rtime.tv_sec;
13939N/A
8922N/A- buf->rtime = prusage.pr_rtime.tv_sec * 1E+6 +
8922N/A- prusage.pr_rtime.tv_nsec / 1E+3;
13939N/A+// buf->rtime = prusage.pr_rtime.tv_sec * 1E+6 +
13939N/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;
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/procwd.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procwd.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/procwd.c 1970-01-01 00:00:00.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procwd.c 2009-02-25 17:16:38.062977000 +0000
10671N/A@@ -0,0 +1,98 @@
10671N/A+/* Copyright (C) 2007 Benoît Dejean
10671N/A+ This file is part of LibGTop 2.
10671N/A+
10671N/A+ LibGTop is free software; you can redistribute it and/or modify it
10671N/A+ under the terms of the GNU General Public License as published by
10671N/A+ the Free Software Foundation; either version 2 of the License,
10671N/A+ or (at your option) any later version.
10671N/A+
10671N/A+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
10671N/A+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10671N/A+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
10671N/A+ for more details.
10671N/A+
10671N/A+ You should have received a copy of the GNU General Public License
10671N/A+ along with LibGTop; see the file COPYING. If not, write to the
10671N/A+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
10671N/A+ Boston, MA 02111-1307, USA.
10671N/A+*/
10671N/A+
10671N/A+#include <config.h>
10671N/A+#include <glibtop/procwd.h>
10671N/A+#include <glibtop/error.h>
10671N/A+
10671N/A+#include <glibtop_private.h>
10671N/A+
10671N/A+#include <unistd.h>
10671N/A+#include <dirent.h>
10671N/A+#include <sys/types.h>
10671N/A+
10671N/A+
10671N/A+void
10671N/A+_glibtop_init_proc_wd_s(glibtop *server)
10671N/A+{
10671N/A+ server->sysdeps.proc_wd =
10671N/A+ (1 << GLIBTOP_PROC_WD_EXE) +
10671N/A+ (1 << GLIBTOP_PROC_WD_ROOT) +
10671N/A+ (1 << GLIBTOP_PROC_WD_NUMBER);
10671N/A+
10671N/A+}
10671N/A+
10671N/A+static gboolean is_in(GPtrArray *array, const char *str)
10671N/A+{
10671N/A+ guint i;
10671N/A+
10671N/A+ for (i = 0; i != array->len; ++i) {
10671N/A+ if (strcmp(g_ptr_array_index(array, i), str) == 0)
10671N/A+ return TRUE;
10671N/A+ }
10671N/A+
10671N/A+ return FALSE;
10671N/A+}
10671N/A+
10671N/A+
10671N/A+char**
10671N/A+glibtop_get_proc_wd_s(glibtop *server, glibtop_proc_wd *buf, pid_t pid)
10671N/A+{
10671N/A+ GPtrArray *dirs;
10671N/A+ char path[80];
10671N/A+ char dir[256];
10671N/A+ DIR *task;
10671N/A+
10671N/A+ glibtop_init_s(&server, GLIBTOP_SYSDEPS_PROC_WD, 0);
10671N/A+
10671N/A+ memset(buf, 0, sizeof(glibtop_proc_wd));
10671N/A+
10671N/A+ g_snprintf(path, sizeof path, "/proc/%u/root", pid);
10671N/A+ if (safe_readlink(path, buf->root, sizeof buf->root))
10671N/A+ buf->flags |= (1 << GLIBTOP_PROC_WD_ROOT);
10671N/A+
10671N/A+ g_snprintf(path, sizeof path, "/proc/%u/exe", pid);
10671N/A+ if (safe_readlink(path, buf->exe, sizeof buf->exe))
10671N/A+ buf->flags |= (1 << GLIBTOP_PROC_WD_EXE);
10671N/A+
10671N/A+ dirs = g_ptr_array_sized_new(2);
10671N/A+
10671N/A+ g_snprintf(path, sizeof path, "/proc/%u/cwd", pid);
10671N/A+ if (safe_readlink(path, dir, sizeof dir))
10671N/A+ g_ptr_array_add(dirs, g_strdup(dir));
10671N/A+
10671N/A+ g_snprintf(path, sizeof path, "/proc/%u/task", pid);
10671N/A+ if ((task = opendir(path)) != NULL) {
10671N/A+ struct dirent *sub;
10671N/A+ while ((sub = readdir(task)) != NULL) {
10671N/A+ g_snprintf(path, sizeof path, "/proc/%u/task/%s/cwd", pid, sub->d_name);
10671N/A+ if (safe_readlink(path, dir, sizeof dir) && !is_in(dirs, dir))
10671N/A+ g_ptr_array_add(dirs, g_strdup(dir));
10671N/A+ }
10671N/A+ closedir(task);
10671N/A+ }
10671N/A+
10671N/A+ buf->number = dirs->len;
10671N/A+ buf->flags |= (1 << GLIBTOP_PROC_WD_NUMBER);
10671N/A+
10671N/A+ g_ptr_array_add(dirs, NULL);
10671N/A+
10671N/A+ return (char**) g_ptr_array_free(dirs, FALSE);
10671N/A+}
10671N/A+
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/sem_limits.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/sem_limits.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/sem_limits.c 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/sem_limits.c 2009-02-25 17:16:38.063802000 +0000
15978N/A@@ -39,14 +39,22 @@
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;
13939N/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
10671N/A _glibtop_init_sem_limits_p (glibtop *server)
8922N/A+#else
8922N/A+void
10671N/A+_glibtop_init_sem_limits_s (glibtop *server)
10671N/A+#endif
8922N/A {
8922N/A #if GLIBTOP_SOLARIS_RELEASE < 51000
8922N/A
15978N/A@@ -61,8 +69,13 @@
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;
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/shm_limits.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/shm_limits.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/shm_limits.c 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/shm_limits.c 2009-02-25 17:16:38.064069000 +0000
10671N/A@@ -30,7 +30,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;
13939N/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 =
15978N/A@@ -45,8 +47,13 @@
8922N/A
8922N/A /* Init function. */
8922N/A
8922N/A+#if GLIBTOP_SUID_SHM_LIMITS
8922N/A void
10671N/A _glibtop_init_shm_limits_p (glibtop *server)
8922N/A+#else
8922N/A+void
10671N/A+_glibtop_init_shm_limits_s (glibtop *server)
8922N/A+#endif
8922N/A {
8922N/A #if GLIBTOP_SOLARIS_RELEASE < 51000
8922N/A
15978N/A@@ -61,8 +68,13 @@
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
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/siglist.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/siglist.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/siglist.c 2008-05-23 22:13:24.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/siglist.c 2009-02-25 17:16:38.064867000 +0000
15978N/A@@ -61,6 +61,7 @@
8402N/A { 35, "SIGTHAW", "Checkpoint Thaw" },
8402N/A { 36, "SIGCANCEL","Thread Cancelation" },
8402N/A { 37, "SIGLOST", "Resource Lost" },
10671N/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" },
15978N/A@@ -69,5 +70,30 @@
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 };
15978N/Adiff -urN libgtop-2.25.91/sysdeps/solaris/sysinfo.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/sysinfo.c
15978N/A--- libgtop-2.25.91/sysdeps/solaris/sysinfo.c 1970-01-01 00:00:00.000000000 +0000
15978N/A+++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/sysinfo.c 2009-02-25 17:16:38.065095000 +0000
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+}