Home | History | Annotate | Download | only in patches
      1  17586     gheet diff -urN libgtop-2.25.91/include/glibtop/procstate.h ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/include/glibtop/procstate.h
      2  17586     gheet --- libgtop-2.25.91/include/glibtop/procstate.h	2008-05-23 22:13:20.000000000 +0000
      3  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/include/glibtop/procstate.h	2009-02-25 17:16:38.052247000 +0000
      4  17586     gheet @@ -69,6 +69,13 @@
      5  15005    henryz      int has_cpu;
      6  15005    henryz      int processor;
      7  15005    henryz      int last_processor;
      8  15005    henryz +
      9  10312    henryz +        gint32  nice;           /*zhua: used to store nice */
     10  10312    henryz +        guint64 start_time;     /* start time of process -- */
     11  10312    henryz +        guint64 vsize;          /* number of pages of virtual memory ... */
     12  10312    henryz +        guint64 resident;       /* number of resident set */
     13  10312    henryz +        guint   load;           /* cpu load for process */
     14  10312    henryz +        gint32  ppid;           /* pid of parent process */
     15  10312    henryz  };
     16  10312    henryz  
     17  10312    henryz  void glibtop_get_proc_state(glibtop_proc_state *buf, pid_t pid);
     18  17586     gheet diff -urN libgtop-2.25.91/procmap.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/procmap.c
     19  17586     gheet --- libgtop-2.25.91/procmap.c	1970-01-01 00:00:00.000000000 +0000
     20  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/procmap.c	2009-02-25 17:16:38.053079000 +0000
     21  15005    henryz @@ -0,0 +1,252 @@
     22  15005    henryz +/* Copyright (C) 1998-99 Martin Baulig
     23  15005    henryz +   This file is part of LibGTop 1.0.
     24  12848  dcarbery +
     25  15005    henryz +   Contributed by Martin Baulig <martin (a] home-of-linux.org>, April 1998.
     26  15005    henryz +
     27  15005    henryz +   LibGTop is free software; you can redistribute it and/or modify it
     28  15005    henryz +   under the terms of the GNU General Public License as published by
     29  15005    henryz +   the Free Software Foundation; either version 2 of the License,
     30  15005    henryz +   or (at your option) any later version.
     31  15005    henryz +
     32  15005    henryz +   LibGTop is distributed in the hope that it will be useful, but WITHOUT
     33  15005    henryz +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     34  15005    henryz +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     35  15005    henryz +   for more details.
     36  15005    henryz +
     37  15005    henryz +   You should have received a copy of the GNU General Public License
     38  15005    henryz +   along with LibGTop; see the file COPYING. If not, write to the
     39  15005    henryz +   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     40  15005    henryz +   Boston, MA 02111-1307, USA.
     41  15005    henryz +*/
     42  15005    henryz +
     43  15005    henryz +
     44  15005    henryz +#include <config.h>
     45  15005    henryz +#include <glibtop.h>
     46  15005    henryz +#include <glibtop/error.h>
     47  15005    henryz +#include <glibtop/procmap.h>
     48  15005    henryz +
     49  15005    henryz +#include <errno.h>
     50  15005    henryz +
     51  15005    henryz +#include "safeio.h"
     52  15005    henryz +
     53  15005    henryz +
     54  15005    henryz +static const unsigned long _glibtop_sysdeps_proc_map =
     55  15005    henryz +(1L << GLIBTOP_PROC_MAP_NUMBER) + (1L << GLIBTOP_PROC_MAP_TOTAL) +
     56  15005    henryz +(1L << GLIBTOP_PROC_MAP_SIZE);
     57  15005    henryz +static const unsigned long _glibtop_sysdeps_map_entry =
     58  15005    henryz +(1L << GLIBTOP_MAP_ENTRY_START) + (1L << GLIBTOP_MAP_ENTRY_END) +
     59  15005    henryz +(1L << GLIBTOP_MAP_ENTRY_OFFSET) + (1L << GLIBTOP_MAP_ENTRY_PERM);
     60  15005    henryz +static const unsigned long _glibtop_sysdeps_map_device =
     61  15005    henryz +(1L << GLIBTOP_MAP_ENTRY_DEVICE) + (1L << GLIBTOP_MAP_ENTRY_INODE);
     62  15005    henryz +
     63  15005    henryz +
     64  15005    henryz +/* Init function. */
     65  15005    henryz +
     66  15005    henryz +void
     67  15005    henryz +_glibtop_init_proc_map_s (glibtop *server)
     68  15005    henryz +{
     69  15005    henryz +	server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
     70  15005    henryz +}
     71  15005    henryz +
     72  15005    henryz +/* Provides detailed information about a process. */
     73  15005    henryz +
     74  15005    henryz +glibtop_map_entry *
     75  15005    henryz +glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf,	pid_t pid)
     76  15005    henryz +{
     77  15005    henryz +   	int fd, i, nmaps, pr_err, heap;
     78  15005    henryz +
     79  15005    henryz +        char filename [BUFSIZ];
     80  15005    henryz +	/* use flags as a check condition, if it is 1, check, or, not check... zhua */
     81  15005    henryz +	int check = buf->flags;
     82  15005    henryz +	/* set flags back to 0 */
     83  15005    henryz +	buf->flags = 0;
     84  15005    henryz +
     85  15005    henryz +#if GLIBTOP_SOLARIS_RELEASE >= 50600
     86  15005    henryz +	prxmap_t *maps;
     87  15005    henryz +//	struct ps_prochandle *Pr = NULL;
     88  15005    henryz +#else
     89  15005    henryz +	prmap_t *maps;
     90  15005    henryz +#endif
     91  15005    henryz +
     92  15005    henryz +	/* A few defines, to make it shorter down there */
     93  15005    henryz +
     94  15005    henryz +#ifdef HAVE_PROCFS_H
     95  15005    henryz +# define OFFSET  pr_offset
     96  15005    henryz +#else
     97  15005    henryz +# define OFFSET  pr_off
     98  15005    henryz +#endif
     99  15005    henryz +
    100  15005    henryz +	glibtop_map_entry *entry;
    101  15005    henryz +	struct stat inode;
    102  15005    henryz +	char buffer[BUFSIZ];
    103  15005    henryz +
    104  15005    henryz +	memset (buf, 0, sizeof (glibtop_proc_map));
    105  15005    henryz +
    106  15005    henryz +#ifdef HAVE_PROCFS_H
    107  15005    henryz +	sprintf(buffer, "/proc/%d/xmap", (int)pid);
    108  15005    henryz +#else
    109  15005    henryz +	sprintf(buffer, "/proc/%d", (int)pid);
    110  15005    henryz +#endif
    111  15005    henryz +	if((fd = s_open(buffer, O_RDONLY)) < 0)
    112  15005    henryz +	{
    113  15005    henryz +	   	if (errno != EPERM && errno != EACCES)
    114  15005    henryz +		   	glibtop_warn_io_r(server, "open (%s)", buffer);
    115  15005    henryz +		return NULL;
    116  15005    henryz +	}
    117  15005    henryz +#ifdef HAVE_PROCFS_H
    118  15005    henryz +	if(fstat(fd, &inode) < 0)
    119  15005    henryz +	{
    120  15005    henryz +	   	if(errno != EOVERFLOW)
    121  15005    henryz +		   	glibtop_warn_io_r(server, "fstat (%s)", buffer);
    122  15005    henryz +		/* else call daemon for 64-bit support */
    123  15005    henryz +		s_close(fd);
    124  15005    henryz +		return NULL;
    125  15005    henryz +	}
    126  15005    henryz +	maps = g_alloca(inode.st_size);
    127  15005    henryz +	nmaps = inode.st_size / sizeof(prxmap_t);
    128  15005    henryz +	if(s_pread(fd, maps, inode.st_size, 0) != inode.st_size)
    129  15005    henryz +	{
    130  15005    henryz +	   	glibtop_warn_io_r(server, "pread (%s)", buffer);
    131  15005    henryz +		s_close(fd);
    132  15005    henryz +		return NULL;
    133  15005    henryz +	}
    134  15005    henryz +#else
    135  15005    henryz +	if(ioctl(fd, PIOCNMAP, &nmaps) < 0)
    136  15005    henryz +	{
    137  15005    henryz +	   	glibtop_warn_io_r(server, "ioctl(%s, PIOCNMAP)", buffer);
    138  15005    henryz +		s_close(fd);
    139  15005    henryz +		return NULL;
    140  15005    henryz +	}
    141  15005    henryz +	maps = g_alloca((nmaps + 1) * sizeof(prmap_t));
    142  15005    henryz +	if(ioctl(fd, PIOCMAP, maps) < 0)
    143  15005    henryz +	{
    144  15005    henryz +	   	glibtop_warn_io_r(server, "ioctl(%s, PIOCMAP)", buffer);
    145  15005    henryz +		s_close(fd);
    146  15005    henryz +		return NULL;
    147  15005    henryz +	}
    148  15005    henryz +#endif
    149  15005    henryz +	buf->number = nmaps;
    150  15005    henryz +	buf->size = sizeof(glibtop_map_entry);
    151  15005    henryz +	buf->total = nmaps * sizeof(glibtop_map_entry);
    152  15005    henryz +	entry = g_malloc0(buf->total);
    153  15005    henryz +
    154  15005    henryz +//#if GLIBTOP_SOLARIS_RELEASE >= 50600
    155  15005    henryz +
    156  15005    henryz +//	if(server->machine.objname && server->machine.pgrab &&
    157  15005    henryz +//	   server->machine.pfree)
    158  15005    henryz +//	   Pr = (server->machine.pgrab)(pid, 1, &pr_err);
    159  15005    henryz +//#endif
    160  15005    henryz +	for(heap = 0,i = 0; i < nmaps; ++i)
    161  15005    henryz +	{
    162  15005    henryz +	   	int len;
    163  15005    henryz +
    164  15005    henryz +		/* take a check to see if we need all information, if not, just get what we need.. 
    165  15005    henryz +		   Also please see comments in get_process_memory_writable() of gnome-system-monitor zhua */
    166  15005    henryz +		if (check == 1)
    167  15005    henryz +		{
    168  15005    henryz +			if(maps[i].pr_mflags & MA_WRITE){
    169  15005    henryz +		   	entry[i].perm |= GLIBTOP_MAP_PERM_WRITE;
    170  15005    henryz +		   	entry[i].size = maps[i].pr_size;
    171  15005    henryz +			}
    172  15005    henryz +                if(maps[i].pr_mflags & MA_SHARED){
    173  15005    henryz +                        entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
    174  15005    henryz +			/* here use shared_clean to store Shared Memory */
    175  15005    henryz +                        entry[i].shared_clean = maps[i].pr_size; 
    176  15005    henryz +                	}
    177  15005    henryz +		}
    178  15005    henryz +                else
    179  15005    henryz +                if (check == 2)
    180  15005    henryz +                {
    181  15005    henryz +                       if(maps[i].pr_mflags & MA_SHARED){
    182  15005    henryz +                        entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
    183  15005    henryz +                       /* here use shared_clean to store Shared Memory */
    184  15005    henryz +                        entry[i].shared_clean = maps[i].pr_size;
    185  15005    henryz +                       }
    186  15005    henryz +                }
    187  15005    henryz +		else {
    188  15005    henryz +		
    189  15005    henryz +	   	int len, rv;
    190  15005    henryz + 
    191  15005    henryz +
    192  15005    henryz +	   	entry[i].start = maps[i].pr_vaddr;
    193  15005    henryz +		entry[i].end = maps[i].pr_vaddr + maps[i].pr_size;
    194  15005    henryz +
    195  15005    henryz +#if GLIBTOP_SOLARIS_RELEASE >= 50600
    196  15005    henryz +
    197  15005    henryz +		if(maps[i].pr_dev != PRNODEV)
    198  15005    henryz +		{
    199  15005    henryz +		   entry[i].device = maps[i].pr_dev;
    200  15005    henryz +		   entry[i].inode = maps[i].pr_ino;
    201  15005    henryz +		   entry[i].flags |= _glibtop_sysdeps_map_device;
    202  15005    henryz +		}
    203  15005    henryz +#endif
    204  15005    henryz +		entry[i].offset = maps[i].OFFSET;
    205  15005    henryz +		if(maps[i].pr_mflags & MA_READ)
    206  15005    henryz +		   	entry[i].perm |= GLIBTOP_MAP_PERM_READ;
    207  15005    henryz +		if(maps[i].pr_mflags & MA_WRITE){
    208  15005    henryz +		   	entry[i].perm |= GLIBTOP_MAP_PERM_WRITE;
    209  15005    henryz +		   	entry[i].size = maps[i].pr_size;
    210  15005    henryz +		}
    211  15005    henryz +		if(maps[i].pr_mflags & MA_EXEC)
    212  15005    henryz +		   	entry[i].perm |= GLIBTOP_MAP_PERM_EXECUTE;
    213  15005    henryz +		if(maps[i].pr_mflags & MA_SHARED)
    214  15005    henryz +		   	entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
    215  15005    henryz +		else
    216  15005    henryz +		   	entry[i].perm |= GLIBTOP_MAP_PERM_PRIVATE;
    217  15005    henryz +		entry[i].flags = _glibtop_sysdeps_map_entry;
    218  15005    henryz +
    219  15005    henryz +#if GLIBTOP_SOLARIS_RELEASE >= 50600
    220  15005    henryz +
    221  15005    henryz +		if(maps[i].pr_mflags & MA_ANON)
    222  15005    henryz +		{
    223  15005    henryz +		   if(!heap)
    224  15005    henryz +		   {
    225  15005    henryz +		      ++heap;
    226  15005    henryz +		      strcpy(entry[i].filename, "[ heap ]");
    227  15005    henryz +		   }
    228  15005    henryz +		   else
    229  15005    henryz +		      if(i == nmaps - 1)
    230  15005    henryz +			 strcpy(entry[i].filename, "[ stack ]");
    231  15005    henryz +		      else
    232  15005    henryz +			 strcpy(entry[i].filename, "[ anon ]");
    233  15005    henryz +		   entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
    234  15005    henryz +		}
    235  15005    henryz +		else
    236  15005    henryz +//		   if(Pr)
    237  15005    henryz +//		   {
    238  15005    henryz +//		      server->machine.objname(Pr, maps[i].pr_vaddr, buffer,
    239  15005    henryz +//					      BUFSIZ);
    240  15005    henryz +//		      if((len = resolvepath(buffer, entry[i].filename,
    241  15005    henryz +//					    GLIBTOP_MAP_FILENAME_LEN)) > 0)
    242  15005    henryz +//		      {
    243  15005    henryz +//			 entry[i].filename[len] = 0;
    244  15005    henryz +//			 entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
    245  15005    henryz +//		      }
    246  15005    henryz +//		   }
    247  15005    henryz +               {
    248  15005    henryz +                        g_strlcpy(buffer, maps[i].pr_mapname,  sizeof buffer);
    249  15005    henryz +                        /* from /path get file name */
    250  15005    henryz +                        g_snprintf(filename, sizeof filename, "/proc/%d/path/%s",
    251  15005    henryz +                                pid, buffer);
    252  15005    henryz + 
    253  15005    henryz +                        rv = readlink(filename, entry[i].filename, sizeof(entry[i].filename) - 1);
    254  15005    henryz +                        /* read object, if have not, set it as NULL */
    255  15005    henryz +                        if(rv < 0)
    256  15005    henryz +                                rv = 0;
    257  15005    henryz +                        entry[i].filename[rv] = '\0';
    258  15005    henryz +                        /* now set the flags */
    259  15005    henryz +                        entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
    260  15005    henryz +                }
    261  15005    henryz +#endif
    262  15005    henryz +	}
    263  15005    henryz +	}
    264  15005    henryz +
    265  15005    henryz +//#if GLIBTOP_SOLARIS_RELEASE >= 50600
    266  15005    henryz +
    267  15005    henryz +//	if(Pr)
    268  15005    henryz +//	   	server->machine.pfree(Pr);
    269  15005    henryz +//#endif
    270  15005    henryz +	buf->flags = _glibtop_sysdeps_proc_map;
    271  15005    henryz +	s_close(fd);
    272  15005    henryz +	return entry;
    273  15005    henryz +}
    274  17586     gheet diff -urN libgtop-2.25.91/sysdeps/common/fsusage.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/common/fsusage.c
    275  17586     gheet --- libgtop-2.25.91/sysdeps/common/fsusage.c	2008-05-23 22:13:22.000000000 +0000
    276  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/common/fsusage.c	2009-02-25 17:25:57.183257000 +0000
    277  17586     gheet @@ -149,6 +149,15 @@
    278  17586     gheet  #define _glibtop_get_fsusage_read_write(S, B, P) \
    279  17586     gheet  	_glibtop_freebsd_get_fsusage_read_write(S, B, P)
    280  12848  dcarbery  
    281  17586     gheet +#elif (defined(sun) || defined(__sun))
    282  17586     gheet +G_GNUC_INTERNAL void
    283  17586     gheet +_glibtop_sun_get_fsusage_read_write(glibtop *server,
    284  17586     gheet +					glibtop_fsusage *buf,
    285  17586     gheet +					const char *path);
    286  17586     gheet +
    287  17586     gheet +#define _glibtop_get_fsusage_read_write(S, B, P) \
    288  17586     gheet +	_glibtop_sun_get_fsusage_read_write(S, B, P)
    289  17586     gheet +
    290  17586     gheet  #else /* default fallback */
    291  17586     gheet  #warning glibtop_get_fsusage .read .write are not implemented.
    292  17586     gheet  static inline void
    293  17586     gheet diff -urN libgtop-2.25.91/sysdeps/common/mountlist.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/common/mountlist.c
    294  17586     gheet --- libgtop-2.25.91/sysdeps/common/mountlist.c	2008-05-23 22:13:22.000000000 +0000
    295  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/common/mountlist.c	2009-02-25 17:16:38.053543000 +0000
    296  17586     gheet @@ -591,6 +591,17 @@
    297  17586     gheet  
    298  12848  dcarbery  	for (cur = &entries[0]; cur != NULL; cur = next) {
    299  12848  dcarbery  
    300  12848  dcarbery +                /*zhua: delete these 2 type of fs: objfs,ctfs */
    301  12848  dcarbery +                if (!strcmp(cur->me_type, "objfs") || !strcmp(cur->me_type,"ctfs")){
    302  12848  dcarbery +                /* free current mount_entry and move to the next */
    303  12848  dcarbery +                        next = cur->me_next;
    304  12848  dcarbery +                        g_free(cur->me_devname);
    305  12848  dcarbery +                        g_free(cur->me_mountdir);
    306  12848  dcarbery +                        g_free(cur->me_type);
    307  12848  dcarbery +                        g_free(cur);
    308  12848  dcarbery +                        continue;
    309  12848  dcarbery +                }
    310  12848  dcarbery +
    311  12848  dcarbery  		if(all_fs || !ignore_mount_entry(cur)) {
    312  12848  dcarbery  			/* add a new glibtop_mountentry */
    313  12848  dcarbery  			glibtop_mountentry e;
    314  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/Makefile.am ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/Makefile.am
    315  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/Makefile.am	2008-05-23 22:13:24.000000000 +0000
    316  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/Makefile.am	2009-02-25 17:27:23.462319000 +0000
    317  17586     gheet @@ -8,7 +8,8 @@
    318  17586     gheet  				  proclist.c procstate.c procuid.c \
    319   8649  hz159841  				  proctime.c procmem.c procsignal.c \
    320   8649  hz159841  				  prockernel.c procsegment.c procargs.c \
    321  17586     gheet -				  procopenfiles.c \
    322  17586     gheet +				  procopenfiles.c sysinfo.c fsusage.c procwd.c \
    323  17586     gheet +				  glibtop_private.c procaffinity.c \
    324   8649  hz159841  				  procmap.c netload.c ppp.c procdata.c netlist.c
    325   8649  hz159841  
    326   8649  hz159841  libgtop_sysdeps_2_0_la_LDFLAGS	= $(LT_VERSION_INFO)
    327  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/cpu.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/cpu.c
    328  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/cpu.c	2008-05-23 22:13:24.000000000 +0000
    329  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/cpu.c	2009-02-25 17:16:38.055204000 +0000
    330  17586     gheet @@ -34,6 +34,7 @@
    331   8649  hz159841  
    332   8649  hz159841  static const unsigned long _glibtop_sysdeps_cpu_all =
    333   8649  hz159841  (1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
    334  15005    henryz +(1L << GLIBTOP_CPU_NICE) + /* this value is needed by multiload */
    335   8649  hz159841  (1L << GLIBTOP_CPU_SYS) + (1L << GLIBTOP_CPU_IDLE) +
    336   8649  hz159841  (1L << GLIBTOP_XCPU_TOTAL) + (1L << GLIBTOP_XCPU_USER) +
    337   8649  hz159841  (1L << GLIBTOP_XCPU_SYS) + (1L << GLIBTOP_XCPU_IDLE) +
    338  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/fsusage.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/fsusage.c
    339  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/fsusage.c	1970-01-01 00:00:00.000000000 +0000
    340  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/fsusage.c	2009-02-25 17:20:33.608888000 +0000
    341  17586     gheet @@ -0,0 +1,99 @@
    342  17586     gheet +#include <config.h>
    343  17586     gheet +#include <glibtop.h>
    344  17586     gheet +#include <glibtop/error.h>
    345  17586     gheet +#include <glibtop/fsusage.h>
    346  17586     gheet +#include <glibtop/union.h>
    347  17586     gheet +
    348  17586     gheet +#include "glibtop_private.h"
    349  17586     gheet +
    350  17586     gheet +#include <glib.h>
    351  17586     gheet +
    352  17586     gheet +#include <unistd.h>
    353  17586     gheet +#include <kstat.h>
    354  17586     gheet +#include <sys/types.h>
    355  17586     gheet +#include <sys/stat.h>
    356  17586     gheet +#include <sys/statvfs.h>
    357  17586     gheet +
    358  17586     gheet +#include <stdio.h>
    359  17586     gheet +#include <string.h>
    360  17586     gheet +#include <stdlib.h>
    361  17586     gheet +
    362  17586     gheet +G_GNUC_INTERNAL void 
    363  17586     gheet +_glibtop_sun_get_fsusage_read_write(glibtop *server,
    364  17586     gheet +				      glibtop_fsusage *buf,
    365  17586     gheet +				      const char *path)
    366  17586     gheet +{
    367  17586     gheet +        struct statvfs64       statvfsbuf;
    368  17586     gheet +        char            ksname[KSTAT_STRLEN + 1];
    369  17586     gheet +    	kstat_ctl_t * const kctl = server->machine.kc;
    370  17586     gheet +	kstat_t		*ksp;
    371  17586     gheet +     	kstat_io_t     	kio;
    372  17586     gheet +	kstat_named_t   *kread, *kwrite;
    373  17586     gheet +	int i;
    374  17586     gheet +	
    375  17586     gheet +        /*
    376  17586     gheet +         *  get a kstat handle and update the user's kstat chain
    377  17586     gheet +         */
    378  17586     gheet +        if( kctl == NULL ){ 
    379  17586     gheet +                glibtop_warn_io_r (server, "kstat_open ()");
    380  17586     gheet +                return;
    381  17586     gheet +        }
    382  17586     gheet +	
    383  17586     gheet +        /* make sure we have current data */  
    384  17586     gheet +	while( kstat_chain_update( kctl ) != 0 )
    385  17586     gheet +                ;
    386  17586     gheet +		
    387  17586     gheet +         for (ksp = kctl->kc_chain, i =0; ksp != NULL; ksp = ksp->ks_next, i++) {  
    388  17586     gheet +		if (ksp->ks_type == KSTAT_TYPE_IO && strcmp(ksp->ks_class,"disk") == 0) { 
    389  17586     gheet +              		kstat_read(kctl, ksp, &kio);  
    390  17586     gheet +               		buf->read +=  kio.nread;       
    391  17586     gheet +			buf->write +=  kio.nwritten;
    392  17586     gheet +		}  
    393  17586     gheet +	}
    394  17586     gheet +#if 0
    395  17586     gheet +	/* these codes keep here, because they are a good way to get the 
    396  17586     gheet +	   fsusage information, but at the moment, the interfaces used 
    397  17586     gheet +	   are not public or stable. so let's use them when public...
    398  17586     gheet +	  */
    399  17586     gheet +        /*
    400  17586     gheet +         *  get a kstat handle and update the user's kstat chain
    401  17586     gheet +         */
    402  17586     gheet +        if( kctl == NULL ){
    403  17586     gheet +                glibtop_warn_io_r (server, "kstat_open ()");
    404  17586     gheet +                return;
    405  17586     gheet +        }
    406  17586     gheet +	   
    407  17586     gheet +	while( kstat_chain_update( kctl ) != 0 )
    408  17586     gheet +                ;
    409  17586     gheet +
    410  17586     gheet +	if (statvfs64(path, &statvfsbuf) != 0) {
    411  17586     gheet +                glibtop_warn_io_r (server, "kstat_open ()");
    412  17586     gheet +		return;
    413  17586     gheet +	}        
    414  17586     gheet +	snprintf(ksname, KSTAT_STRLEN, "%s%lx", VOPSTATS_STR,
    415  17586     gheet +                        	statvfsbuf.f_fsid);
    416  17586     gheet +
    417  17586     gheet +       	/*
    418  17586     gheet +         *  traverse the kstat chain
    419  17586     gheet +         *  to find the appropriate statistics
    420  17586     gheet +         */
    421  17586     gheet +        if( (ksp = kstat_lookup( kctl,
    422  17586     gheet +                       "unix", 0, ksname )) == NULL ) {
    423  17586     gheet +               	return;
    424  17586     gheet +        }
    425  17586     gheet +        if( kstat_read( kctl, ksp, NULL ) == -1 ) {
    426  17586     gheet +               	return;
    427  17586     gheet +        }
    428  17586     gheet +
    429  17586     gheet +	kread = (kstat_named_t *)kstat_data_lookup(ksp,"read_bytes");
    430  17586     gheet +        if( kread != NULL ) {
    431  17586     gheet +               	buf->read = kread->value.ull;
    432  17586     gheet +        }
    433  17586     gheet +
    434  17586     gheet +        kwrite = (kstat_named_t *)kstat_data_lookup(ksp,"write_bytes");
    435  17586     gheet +        if( kwrite != NULL ) {
    436  17586     gheet +               	buf->write = kwrite->value.ull;
    437  17586     gheet +        }
    438  17586     gheet +#endif
    439  17586     gheet +        buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
    440  17586     gheet +}
    441  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/glibtop_machine.h ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_machine.h
    442  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/glibtop_machine.h	2008-05-23 22:13:24.000000000 +0000
    443  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_machine.h	2009-02-25 17:16:38.055426000 +0000
    444  17586     gheet @@ -61,14 +61,14 @@
    445   8649  hz159841      int pagesize;		/* in bits to shift, ie. 2^pagesize gives Kb */
    446   8649  hz159841      int ticks;			/* clock ticks, as returned by sysconf() */
    447   8649  hz159841      unsigned long long boot;	/* boot time, although it's ui32 in kstat */
    448   8649  hz159841 -    void *libproc;		/* libproc handle */
    449   8857  dc144907 -#if GLIBTOP_SOLARIS_RELEASE >= 50600
    450   8649  hz159841 -    void (*objname)(void *, uintptr_t, const char *, size_t);
    451   8649  hz159841 -    struct ps_prochandle *(*pgrab)(pid_t, int, int *);
    452   8649  hz159841 -    void (*pfree)(void *);
    453   8649  hz159841 -#else
    454  15005    henryz +//    void *libproc;		/* libproc handle */
    455  15005    henryz +//#if GLIBTOP_SOLARIS_RELEASE >= 50600
    456  15005    henryz +//    void (*objname)(void *, uintptr_t, const char *, size_t);
    457  15005    henryz +//    struct ps_prochandle *(*pgrab)(pid_t, int, int *);
    458  15005    henryz +//    void (*pfree)(void *);
    459  15005    henryz +//#else
    460   8649  hz159841      void *filler[3];
    461   8649  hz159841 -#endif
    462  15005    henryz +//#endif
    463   8649  hz159841  };
    464   8649  hz159841  
    465   8649  hz159841  G_END_DECLS
    466  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/glibtop_private.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_private.c
    467  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/glibtop_private.c	1970-01-01 00:00:00.000000000 +0000
    468  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_private.c	2009-02-25 17:16:38.055744000 +0000
    469  11362    henryz @@ -0,0 +1,203 @@
    470  11362    henryz +#include <config.h>
    471  11362    henryz +#include <glibtop.h>
    472  11362    henryz +#include <glibtop/error.h>
    473  11362    henryz +
    474  11362    henryz +#include "glibtop_private.h"
    475  11362    henryz +
    476  11362    henryz +#include <glib.h>
    477  11362    henryz +
    478  11362    henryz +#include <string.h>
    479  11362    henryz +#include <stdlib.h>
    480  11362    henryz +#include <stdarg.h>
    481  11362    henryz +
    482  11362    henryz +#include <fcntl.h>
    483  11362    henryz +#include <unistd.h>
    484  11362    henryz +
    485  11362    henryz +#if 0
    486  11362    henryz +unsigned long long
    487  11362    henryz +get_scaled(const char *buffer, const char *key)
    488  11362    henryz +{
    489  11362    henryz +	const char    *ptr;
    490  11362    henryz +	char	      *next;
    491  11362    henryz +	unsigned long long value = 0;
    492  11362    henryz +
    493  11362    henryz +	if (G_LIKELY((ptr = strstr(buffer, key))))
    494  11362    henryz +	{
    495  11362    henryz +		ptr += strlen(key);
    496  11362    henryz +		value = strtoull(ptr, &next, 0);
    497  11362    henryz +
    498  11362    henryz +		for ( ; *next; ++next) {
    499  11362    henryz +			if (*next == 'k') {
    500  11362    henryz +				value *= 1024;
    501  11362    henryz +				break;
    502  11362    henryz +			} else if (*next == 'M') {
    503  11362    henryz +				value *= 1024 * 1024;
    504  11362    henryz +				break;
    505  11362    henryz +			}
    506  11362    henryz +		}
    507  11362    henryz +	} else
    508  11362    henryz +		g_warning("Could not read key '%s' in buffer '%s'",
    509  11362    henryz +			  key, buffer);
    510  11362    henryz +
    511  11362    henryz +	return value;
    512  11362    henryz +}
    513  11362    henryz +
    514  11362    henryz +
    515  11362    henryz +char *
    516  11362    henryz +skip_token (const char *p)
    517  11362    henryz +{
    518  11362    henryz +	p = next_token(p);
    519  11362    henryz +	while (*p && !isspace(*p)) p++;
    520  11362    henryz +	p = next_token(p);
    521  11362    henryz +	return (char *)p;
    522  11362    henryz +}
    523  11362    henryz +
    524  11362    henryz +
    525  11362    henryz +/*
    526  11362    henryz + * Read functions
    527  11362    henryz + */
    528  11362    henryz +enum TRY_FILE_TO_BUFFER
    529  11362    henryz +{
    530  11362    henryz +	TRY_FILE_TO_BUFFER_OK = 0,
    531  11362    henryz +	TRY_FILE_TO_BUFFER_OPEN = -1,
    532  11362    henryz +	TRY_FILE_TO_BUFFER_READ = -2
    533  11362    henryz +};
    534  11362    henryz +
    535  11362    henryz +int try_file_to_buffer(char *buffer, const char *format, ...)
    536  11362    henryz +{
    537  11362    henryz +	char path[4096];
    538  11362    henryz +	int fd;
    539  11362    henryz +	ssize_t len;
    540  11362    henryz +	va_list pa;
    541  11362    henryz +
    542  11362    henryz +	va_start(pa, format);
    543  11362    henryz +
    544  11362    henryz +	/* C99 also provides vsnprintf */
    545  11362    henryz +	g_vsnprintf(path, sizeof path, format, pa);
    546  11362    henryz +
    547  11362    henryz +	va_end(pa);
    548  11362    henryz +
    549  11362    henryz +	buffer [0] = '\0';
    550  11362    henryz +
    551  11362    henryz +	if((fd = open (path, O_RDONLY)) < 0)
    552  11362    henryz +		return TRY_FILE_TO_BUFFER_OPEN;
    553  11362    henryz +
    554  11362    henryz +	len = read (fd, buffer, BUFSIZ-1);
    555  11362    henryz +	close (fd);
    556  11362    henryz +
    557  11362    henryz +	if (len < 0)
    558  11362    henryz +		return TRY_FILE_TO_BUFFER_READ;
    559  11362    henryz +
    560  11362    henryz +	buffer [len] = '\0';
    561  11362    henryz +
    562  11362    henryz +	return TRY_FILE_TO_BUFFER_OK;
    563  11362    henryz +}
    564  11362    henryz +
    565  11362    henryz +
    566  11362    henryz +void
    567  11362    henryz +file_to_buffer(glibtop *server, char *buffer, const char *filename)
    568  11362    henryz +{
    569  11362    henryz +	switch(try_file_to_buffer(buffer, filename))
    570  11362    henryz +	{
    571  11362    henryz +	case TRY_FILE_TO_BUFFER_OPEN:
    572  11362    henryz +		glibtop_error_io_r (server, "open (%s)", filename);
    573  11362    henryz +	case TRY_FILE_TO_BUFFER_READ:
    574  11362    henryz +		glibtop_error_io_r (server, "read (%s)", filename);
    575  11362    henryz +	}
    576  11362    henryz +}
    577  11362    henryz +
    578  11362    henryz +
    579  11362    henryz +
    580  11362    henryz +
    581  11362    henryz +static unsigned long
    582  11362    henryz +read_boot_time(glibtop *server)
    583  11362    henryz +{
    584  11362    henryz +	char buffer[BUFSIZ];
    585  11362    henryz +	char *btime;
    586  11362    henryz +
    587  11362    henryz +	file_to_buffer(server, buffer, "/proc/stat");
    588  11362    henryz +
    589  11362    henryz +	btime = strstr(buffer, "btime");
    590  11362    henryz +
    591  11362    henryz +	if (!btime) {
    592  11362    henryz +		glibtop_warn_io_r(server, "cannot find btime in /proc/stat");
    593  11362    henryz +		return 0UL;
    594  11362    henryz +	}
    595  11362    henryz +
    596  11362    henryz +	btime = skip_token(btime);
    597  11362    henryz +	return strtoul(btime, NULL, 10);
    598  11362    henryz +}
    599  11362    henryz +
    600  11362    henryz +
    601  11362    henryz +
    602  11362    henryz +unsigned long
    603  11362    henryz +get_boot_time(glibtop *server)
    604  11362    henryz +{
    605  11362    henryz +	static unsigned long boot_time = 0UL;
    606  11362    henryz +
    607  11362    henryz +	if(G_UNLIKELY(!boot_time))
    608  11362    henryz +	{
    609  11362    henryz +		boot_time = read_boot_time(server);
    610  11362    henryz +	}
    611  11362    henryz +
    612  11362    henryz +	return boot_time;
    613  11362    henryz +}
    614  11362    henryz +
    615  11362    henryz +
    616  11362    henryz +size_t
    617  11362    henryz +get_page_size(void)
    618  11362    henryz +{
    619  11362    henryz +	static size_t pagesize = 0;
    620  11362    henryz +
    621  11362    henryz +	if(G_UNLIKELY(!pagesize))
    622  11362    henryz +	{
    623  11362    henryz +		pagesize = getpagesize();
    624  11362    henryz +	}
    625  11362    henryz +
    626  11362    henryz +	return pagesize;
    627  11362    henryz +}
    628  11362    henryz +
    629  11362    henryz +
    630  11362    henryz +
    631  11362    henryz +gboolean
    632  11362    henryz +check_cpu_line(glibtop *server, const char *line, unsigned i)
    633  11362    henryz +{
    634  11362    henryz +	char start[10];
    635  11362    henryz +
    636  11362    henryz +	g_snprintf(start, sizeof start, "cpu%u", i);
    637  11362    henryz +
    638  11362    henryz +	return g_str_has_prefix(line, start);
    639  11362    henryz +}
    640  11362    henryz +
    641  11362    henryz +
    642  11362    henryz +
    643  11362    henryz +gboolean
    644  11362    henryz +has_sysfs(void)
    645  11362    henryz +{
    646  11362    henryz +	static gboolean init;
    647  11362    henryz +	static gboolean sysfs;
    648  11362    henryz +
    649  11362    henryz +	if (G_UNLIKELY(!init)) {
    650  11362    henryz +		sysfs = g_file_test("/sys", G_FILE_TEST_IS_DIR);
    651  11362    henryz +		init = TRUE;
    652  11362    henryz +	}
    653  11362    henryz +
    654  11362    henryz +	return sysfs;
    655  11362    henryz +}
    656  11362    henryz +#endif
    657  11362    henryz +
    658  11362    henryz +
    659  11362    henryz +gboolean safe_readlink(const char *path, char *buf, size_t bufsiz)
    660  11362    henryz +{
    661  11362    henryz +	ssize_t ret;
    662  11362    henryz +
    663  11362    henryz +	ret = readlink(path, buf, bufsiz - 1);
    664  11362    henryz +
    665  11362    henryz +	if (ret == -1) {
    666  11362    henryz +		g_warning("Could not read link %s : %s", path, strerror(errno));
    667  11362    henryz +		return FALSE;
    668  11362    henryz +	}
    669  11362    henryz +
    670  11362    henryz +	buf[ret] = '\0';
    671  11362    henryz +	return TRUE;
    672  11362    henryz +}
    673  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/glibtop_private.h ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_private.h
    674  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/glibtop_private.h	2008-05-23 22:13:24.000000000 +0000
    675  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_private.h	2009-02-25 17:16:38.057019000 +0000
    676  17586     gheet @@ -60,6 +60,8 @@
    677  11362    henryz  /* Reread kstat chains */
    678  11362    henryz  void glibtop_get_kstats(glibtop *);
    679  11362    henryz  
    680  11362    henryz +gboolean safe_readlink(const char *path, char *buf, size_t bufsiz);
    681  11362    henryz +
    682  11362    henryz  G_END_DECLS
    683  11362    henryz  
    684  11362    henryz  #endif /* __GLIBTOP_PRIVATE_H__ */
    685  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/glibtop_server.h ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_server.h
    686  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/glibtop_server.h	2008-05-23 22:13:24.000000000 +0000
    687  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_server.h	2009-02-25 17:16:38.057265000 +0000
    688  17586     gheet @@ -29,9 +29,15 @@
    689   9302  hz159841  #define GLIBTOP_SUID_SWAP		0
    690   9302  hz159841  #define GLIBTOP_SUID_UPTIME		0
    691   9302  hz159841  #define GLIBTOP_SUID_LOADAVG		0
    692   9302  hz159841 +#if GLIBTOP_SOLARIS_RELEASE < 51000
    693   9302  hz159841  #define GLIBTOP_SUID_SHM_LIMITS		(1L << GLIBTOP_SYSDEPS_SHM_LIMITS)
    694   9302  hz159841  #define GLIBTOP_SUID_MSG_LIMITS		(1L << GLIBTOP_SYSDEPS_MSG_LIMITS)
    695   9302  hz159841  #define GLIBTOP_SUID_SEM_LIMITS		(1L << GLIBTOP_SYSDEPS_SEM_LIMITS)
    696   9302  hz159841 +#else
    697   9302  hz159841 +#define GLIBTOP_SUID_SHM_LIMITS         0
    698   9302  hz159841 +#define GLIBTOP_SUID_MSG_LIMITS         0
    699   9302  hz159841 +#define GLIBTOP_SUID_SEM_LIMITS         0
    700   9302  hz159841 +#endif
    701   9302  hz159841  #define GLIBTOP_SUID_PROCLIST		0
    702   9302  hz159841  #define GLIBTOP_SUID_PROC_STATE		0
    703   9302  hz159841  #define GLIBTOP_SUID_PROC_UID		0
    704  17586     gheet @@ -44,7 +50,10 @@
    705  11362    henryz  #define GLIBTOP_SUID_PROC_MAP		0
    706  11362    henryz  #define GLIBTOP_SUID_NETLOAD		0
    707  11362    henryz  #define GLIBTOP_SUID_NETLIST		0
    708  11362    henryz +#define GLIBTOP_SUID_PROC_WD		0
    709  11362    henryz  #define GLIBTOP_SUID_PPP		0
    710  15005    henryz +#define GLIBTOP_SUID_PROC_AFFINITY	0
    711  15005    henryz +
    712  11362    henryz  
    713  11362    henryz  G_END_DECLS
    714  15005    henryz  
    715  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/msg_limits.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/msg_limits.c
    716  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/msg_limits.c	2008-05-23 22:13:24.000000000 +0000
    717  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/msg_limits.c	2009-02-25 17:16:38.058081000 +0000
    718  17586     gheet @@ -37,14 +37,24 @@
    719   9302  hz159841  (1L << GLIBTOP_IPC_MSGMNB) + (1L << GLIBTOP_IPC_MSGMNI) +
    720   9302  hz159841  (1L << GLIBTOP_IPC_MSGTQL);
    721   9302  hz159841  #else
    722   9302  hz159841 -static const unsigned long _glibtop_sysdeps_msg_limits = 0;
    723  15005    henryz +static const unsigned long _glibtop_sysdeps_msg_limits = 
    724   9302  hz159841 +(1L << GLIBTOP_IPC_MSGMNB) +
    725   9302  hz159841 +(1L << GLIBTOP_IPC_MSGMNI) +
    726   9302  hz159841 +(1L << GLIBTOP_IPC_MSGMAX) +
    727   9302  hz159841 +(1L << GLIBTOP_IPC_MSGPOOL) +
    728   9302  hz159841 +(1L << GLIBTOP_IPC_MSGTQL);
    729   9302  hz159841  #endif
    730   9302  hz159841  
    731   9302  hz159841  
    732   9302  hz159841  /* Init function. */
    733   9302  hz159841  
    734   9302  hz159841 +#if GLIBTOP_SUID_MSG_LIMITS
    735   9302  hz159841  void
    736  11362    henryz  _glibtop_init_msg_limits_p (glibtop *server)
    737   9302  hz159841 +#else
    738   9302  hz159841 +void
    739  11362    henryz +_glibtop_init_msg_limits_s (glibtop *server)
    740   9302  hz159841 +#endif
    741   9302  hz159841  {
    742   9302  hz159841  #if GLIBTOP_SOLARIS_RELEASE < 51000
    743   9302  hz159841  
    744  17586     gheet @@ -59,8 +69,13 @@
    745   9302  hz159841  
    746   9302  hz159841  /* Provides information about sysv ipc limits. */
    747   9302  hz159841  
    748   9302  hz159841 +#if GLIBTOP_SUID_MSG_LIMITS
    749   9302  hz159841  void
    750   9302  hz159841  glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
    751   9302  hz159841 +#else
    752   9302  hz159841 +void
    753   9302  hz159841 +glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
    754   9302  hz159841 +#endif
    755   9302  hz159841  {
    756   9302  hz159841  #if GLIBTOP_SOLARIS_RELEASE < 51000
    757   9302  hz159841  
    758  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/netload.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/netload.c
    759  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/netload.c	2008-05-23 22:13:24.000000000 +0000
    760  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/netload.c	2009-02-25 17:16:38.059013000 +0000
    761  15005    henryz @@ -37,6 +37,17 @@
    762   9302  hz159841  
    763  15005    henryz  #include <net/if.h>
    764   9302  hz159841  
    765  12848  dcarbery +#ifdef HAVE_IFADDRS_H
    766  12848  dcarbery +/* needed for IPV6 support */
    767  12848  dcarbery +
    768  12848  dcarbery +#include <ifaddrs.h>
    769  12848  dcarbery +
    770  12848  dcarbery +#ifndef IN6_IS_ADDR_GLOBAL
    771  12848  dcarbery +#define IN6_IS_ADDR_GLOBAL(a) \
    772  12848  dcarbery +   (((((__const uint8_t *) (a))[0] & 0xff) == 0x3f   \
    773  12848  dcarbery +     || (((__const uint8_t *) (a))[0] & 0xff) == 0x20))
    774  12848  dcarbery +#endif
    775  12848  dcarbery +#endif /* HAVE_IFADDRS_H */
    776  12848  dcarbery  
    777  15005    henryz  static const unsigned long _glibtop_sysdeps_netload =
    778  15005    henryz  (1L << GLIBTOP_NETLOAD_ERRORS_IN) +
    779  17586     gheet @@ -89,6 +100,72 @@
    780  15005    henryz  	_glibtop_sysdeps_netload_packets;
    781  15005    henryz  }
    782  12848  dcarbery  
    783  12848  dcarbery +#ifdef HAVE_IFADDRS_H
    784  12848  dcarbery +
    785  12848  dcarbery +static void get_ipv6(glibtop *server, glibtop_netload *buf,
    786  12848  dcarbery +		     const char *interface)
    787  12848  dcarbery +{
    788  12848  dcarbery +/* 
    789  12848  dcarbery +  * remove this code, because they are not available at Solaris, but keep them here for reference.
    790  12848  dcarbery +  * in fact, the function will not be called at Solaris, because HAVE_IFADDRS_H don't def.
    791  12848  dcarbery +  *
    792  12848  dcarbery +*/
    793  12848  dcarbery +#if 0
    794  12848  dcarbery +	struct ifaddrs *ifa0, *ifr6;
    795  12848  dcarbery +
    796  12848  dcarbery +	if(getifaddrs (&ifa0) != 0)
    797  12848  dcarbery +	{
    798  12848  dcarbery +		glibtop_warn_r(server, "getifaddrs failed : %s", g_strerror(errno));
    799  12848  dcarbery +		return;
    800  12848  dcarbery +	}
    801  12848  dcarbery +
    802  12848  dcarbery +	for (ifr6 = ifa0; ifr6; ifr6 = ifr6->ifa_next) {
    803  12848  dcarbery +		if (strcmp (ifr6->ifa_name, interface) == 0
    804  12848  dcarbery +		    && ifr6->ifa_addr != NULL
    805  12848  dcarbery +		    && ifr6->ifa_addr->sa_family == AF_INET6)
    806  12848  dcarbery +			break;
    807  12848  dcarbery +	}
    808  12848  dcarbery +
    809  12848  dcarbery +	if(!ifr6) goto free_ipv6;
    810  12848  dcarbery +
    811  12848  dcarbery +	memcpy(buf->address6,
    812  12848  dcarbery +	       &((struct sockaddr_in6 *) ifr6->ifa_addr)->sin6_addr,
    813  12848  dcarbery +	       16);
    814  12848  dcarbery +
    815  12848  dcarbery +	memcpy(buf->prefix6,
    816  12848  dcarbery +	       &((struct sockaddr_in6 *) ifr6->ifa_netmask)->sin6_addr,
    817  12848  dcarbery +	       16);
    818  12848  dcarbery +
    819  12848  dcarbery +
    820  12848  dcarbery +	if (IN6_IS_ADDR_LINKLOCAL (buf->address6))
    821  12848  dcarbery +		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_LINK;
    822  12848  dcarbery +
    823  12848  dcarbery +	else if (IN6_IS_ADDR_SITELOCAL (buf->address6))
    824  12848  dcarbery +		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_SITE;
    825  12848  dcarbery +
    826  12848  dcarbery +	else if (IN6_IS_ADDR_GLOBAL (buf->address6)
    827  12848  dcarbery +		 || IN6_IS_ADDR_MC_ORGLOCAL (buf->address6)
    828  12848  dcarbery +		 || IN6_IS_ADDR_V4COMPAT (buf->address6)
    829  12848  dcarbery +		 || IN6_IS_ADDR_MULTICAST (buf->address6)
    830  12848  dcarbery +		 || IN6_IS_ADDR_UNSPECIFIED (buf->address6)
    831  12848  dcarbery +		)
    832  12848  dcarbery +		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_GLOBAL;
    833  12848  dcarbery +
    834  12848  dcarbery +	else if (IN6_IS_ADDR_LOOPBACK (buf->address6))
    835  12848  dcarbery +		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_HOST;
    836  12848  dcarbery +
    837  12848  dcarbery +	else
    838  12848  dcarbery +		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_UNKNOWN;
    839  12848  dcarbery +
    840  12848  dcarbery +	buf->flags |= _glibtop_sysdeps_netload_6;
    841  12848  dcarbery +
    842  12848  dcarbery + free_ipv6:
    843  12848  dcarbery +	freeifaddrs(ifa0);
    844  12848  dcarbery +#endif
    845  12848  dcarbery +}
    846  12848  dcarbery +
    847  12848  dcarbery +#endif /* HAVE_IFADDRS_H */
    848  12848  dcarbery +
    849  15005    henryz  static int
    850  15005    henryz  solaris_stats(glibtop *server,
    851  15005    henryz  		glibtop_netload *buf,
    852  17586     gheet @@ -245,6 +322,13 @@
    853  15005    henryz  	    buf->subnet = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr;
    854  15005    henryz  	    buf->flags |= (1L << GLIBTOP_NETLOAD_SUBNET);
    855  15005    henryz  	}
    856  12848  dcarbery +
    857  15005    henryz +/*	g_strlcpy (ifr.ifr_name, interface, sizeof ifr.ifr_name);
    858  15005    henryz +	if (!ioctl (skfd, SIOCGIFHWADDR, &ifr)) {
    859  15005    henryz +	    memcpy(buf->hwaddress, &ifr.ifr_hwaddr.sa_data, 8);
    860  15005    henryz +	    buf->flags |= (1L << GLIBTOP_NETLOAD_HWADDRESS);
    861  15005    henryz +	}*/
    862  12848  dcarbery +
    863  15005    henryz  	close (skfd);
    864  15005    henryz      }
    865  12848  dcarbery  
    866  17586     gheet @@ -254,4 +338,7 @@
    867  15005    henryz       
    868  15005    henryz      solaris_stats(server, buf, interface);
    869  15005    henryz  
    870  12848  dcarbery +#ifdef HAVE_IFADDRS_H
    871  12848  dcarbery +    get_ipv6(server, buf, interface);
    872  12848  dcarbery +#endif /* HAVE_IFADDRS_H */
    873  12848  dcarbery  }
    874  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/open.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/open.c
    875  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/open.c	2008-05-23 22:13:24.000000000 +0000
    876  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/open.c	2009-02-25 17:16:38.060014000 +0000
    877  17586     gheet @@ -209,34 +209,34 @@
    878   9302  hz159841  	    }
    879   9302  hz159841      }
    880   9302  hz159841  
    881   9302  hz159841 -    /* Now let's have a bit of magic dust... */
    882  15005    henryz +// /* Now let's have a bit of magic dust... */
    883  15005    henryz  
    884   9302  hz159841 -#if GLIBTOP_SOLARIS_RELEASE >= 50600
    885  15005    henryz +//#if GLIBTOP_SOLARIS_RELEASE >= 50600
    886  15005    henryz  
    887   9302  hz159841 -    dl = dlopen("/usr/lib/libproc.so", RTLD_LAZY);
    888   9302  hz159841 -    if(server->machine.libproc)
    889   9302  hz159841 -    	dlclose(server->machine.libproc);
    890   9302  hz159841 -    server->machine.libproc = dl;
    891   9302  hz159841 -    if(dl)
    892   9302  hz159841 -    {
    893   9302  hz159841 -       void *func;
    894  15005    henryz + //   dl = dlopen("/usr/lib/libproc.so", RTLD_LAZY);
    895  15005    henryz +  //  if(server->machine.libproc)
    896  15005    henryz +//   // 	dlclose(server->machine.libproc);
    897  15005    henryz + //   server->machine.libproc = dl;
    898  15005    henryz +  //  if(dl)
    899  15005    henryz +   // {
    900  15005    henryz +    //   void *func;
    901  15005    henryz  
    902   9302  hz159841 -       func = dlsym(dl, "Pobjname");		/* Solaris 8 */
    903   9302  hz159841 -       if(!func)
    904   9302  hz159841 -	  func = dlsym(dl, "proc_objname");	/* Solaris 7 */
    905   9302  hz159841 -       server->machine.objname = (void (*)
    906   9302  hz159841 -				 (void *, uintptr_t, const char *, size_t))func;
    907   9302  hz159841 -       server->machine.pgrab = (struct ps_prochandle *(*)(pid_t, int, int *))
    908   9302  hz159841 -	  		       dlsym(dl, "Pgrab");
    909   9302  hz159841 -       server->machine.pfree = (void (*)(void *))dlsym(dl, "Pfree");
    910   9302  hz159841 -       
    911   9302  hz159841 -    }
    912   9302  hz159841 -    else
    913   9302  hz159841 -    {
    914   9302  hz159841 -       server->machine.objname = NULL;
    915   9302  hz159841 -       server->machine.pgrab = NULL;
    916   9302  hz159841 -       server->machine.pfree = NULL;
    917   9302  hz159841 -    }
    918   9302  hz159841 -#endif
    919  15005    henryz +     //  func = dlsym(dl, "Pobjname");		/* Solaris 8 */
    920  15005    henryz +      // if(!func)
    921  15005    henryz +//	  func = dlsym(dl, "proc_objname");	/* Solaris 7 */
    922  15005    henryz + //      server->machine.objname = (void (*)
    923  15005    henryz +//				 (void *, uintptr_t, const char *, size_t))func;
    924  15005    henryz + //      server->machine.pgrab = (struct ps_prochandle *(*)(pid_t, int, int *))
    925  15005    henryz +//	  		       dlsym(dl, "Pgrab");
    926  15005    henryz + //      server->machine.pfree = (void (*)(void *))dlsym(dl, "Pfree");
    927  15005    henryz +  //     
    928  15005    henryz +   // }
    929  15005    henryz +   // else
    930  15005    henryz +   // {
    931  15005    henryz +   //    server->machine.objname = NULL;
    932  15005    henryz +   //    server->machine.pgrab = NULL;
    933  15005    henryz +   //    server->machine.pfree = NULL;
    934  15005    henryz +   // }
    935  15005    henryz +//#endif
    936   9302  hz159841      server->machine.me = getpid();
    937   9302  hz159841  }
    938  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/procaffinity.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procaffinity.c
    939  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/procaffinity.c	1970-01-01 00:00:00.000000000 +0000
    940  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procaffinity.c	2009-02-25 17:16:38.060320000 +0000
    941  15005    henryz @@ -0,0 +1,84 @@
    942  15005    henryz +/* Copyright (C) 2007 Joe Marcus Clarke <marcus (a] FreeBSD.org>
    943  15005    henryz +   This file is part of LibGTop 2.
    944  15005    henryz +
    945  15005    henryz +   LibGTop is free software; you can redistribute it and/or modify it
    946  15005    henryz +   under the terms of the GNU General Public License as published by
    947  15005    henryz +   the Free Software Foundation; either version 2 of the License,
    948  15005    henryz +   or (at your option) any later version.
    949  15005    henryz +
    950  15005    henryz +   LibGTop is distributed in the hope that it will be useful, but WITHOUT
    951  15005    henryz +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    952  15005    henryz +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    953  15005    henryz +   for more details.
    954  15005    henryz +
    955  15005    henryz +   You should have received a copy of the GNU General Public License
    956  15005    henryz +   along with LibGTop; see the file COPYING. If not, write to the
    957  15005    henryz +   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    958  15005    henryz +   Boston, MA 02111-1307, USA.
    959  15005    henryz +*/
    960  15005    henryz +
    961  15005    henryz +#include <config.h>
    962  15005    henryz +#include <glibtop/procaffinity.h>
    963  15005    henryz +#include <glibtop/error.h>
    964  15005    henryz +
    965  15005    henryz +#include <glibtop_private.h>
    966  15005    henryz +
    967  15005    henryz +#include <sys/param.h>
    968  15005    henryz +
    969  15005    henryz +void
    970  15005    henryz +_glibtop_init_proc_affinity_s(glibtop *server)
    971  15005    henryz +{
    972  15005    henryz +/* 
    973  15005    henryz +  server->sysdeps.proc_affinity =
    974  15005    henryz +    (1 << GLIBTOP_PROC_AFFINITY_NUMBER) |
    975  15005    henryz +    (1 << GLIBTOP_PROC_AFFINITY_ALL);
    976  15005    henryz +*/
    977  15005    henryz +}
    978  15005    henryz +
    979  15005    henryz +
    980  15005    henryz +guint16 *
    981  15005    henryz +glibtop_get_proc_affinity_s(glibtop *server, glibtop_proc_affinity *buf, pid_t pid)
    982  15005    henryz +{
    983  15005    henryz +/*
    984  15005    henryz +#if __FreeBSD_version > 800024
    985  15005    henryz +  id_t id;
    986  15005    henryz +  cpulevel_t level;
    987  15005    henryz +  cpuwhich_t which;
    988  15005    henryz +  cpuset_t mask;
    989  15005    henryz +  size_t i;
    990  15005    henryz +  GArray* cpus;
    991  15005    henryz +
    992  15005    henryz +  memset(buf, 0, sizeof *buf);
    993  15005    henryz +
    994  15005    henryz +  which = CPU_WHICH_PID;
    995  15005    henryz +  level = CPU_LEVEL_WHICH;
    996  15005    henryz +  id = pid;
    997  15005    henryz +
    998  15005    henryz +  if (cpuset_getaffinity(level, which, id, sizeof(mask), &mask) != 0) {
    999  15005    henryz +    glibtop_error_r(server, "cpuset_getaffinity failed");
   1000  15005    henryz +    return NULL;
   1001  15005    henryz +  }
   1002  15005    henryz +
   1003  15005    henryz +  cpus = g_array_new(FALSE, FALSE, sizeof(guint16));
   1004  15005    henryz +
   1005  15005    henryz +  for (i = 0; i < MIN(CPU_SETSIZE, (size_t)(server->ncpu + 1)); i++) {
   1006  15005    henryz +    if (CPU_ISSET(i, &mask)) {
   1007  15005    henryz +      guint16 n = i;
   1008  15005    henryz +      g_array_append_val(cpus, n);
   1009  15005    henryz +    }
   1010  15005    henryz +  }
   1011  15005    henryz +
   1012  15005    henryz +  buf->number = cpus->len;
   1013  15005    henryz +  buf->all = (cpus->len == (size_t)(server->ncpu + 1));
   1014  15005    henryz +  buf->flags = (1 << GLIBTOP_PROC_AFFINITY_NUMBER)
   1015  15005    henryz +    | (1 << GLIBTOP_PROC_AFFINITY_ALL);
   1016  15005    henryz +
   1017  15005    henryz +  return (guint16*) g_array_free(cpus, FALSE);
   1018  15005    henryz +#else
   1019  15005    henryz +  memset(buf, 0, sizeof *buf);
   1020  15005    henryz +
   1021  15005    henryz +  return NULL;
   1022  15005    henryz +#endif
   1023  15005    henryz +*/
   1024  15005    henryz +}
   1025  15005    henryz +
   1026  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/procmap.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procmap.c
   1027  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/procmap.c	2008-05-23 22:13:24.000000000 +0000
   1028  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procmap.c	2009-02-25 17:16:38.061314000 +0000
   1029  17586     gheet @@ -54,9 +54,16 @@
   1030   8649  hz159841  glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf,	pid_t pid)
   1031   8649  hz159841  {
   1032   8649  hz159841     	int fd, i, nmaps, pr_err, heap;
   1033  15005    henryz +
   1034   9302  hz159841 +        char filename [BUFSIZ];
   1035   9731    henryz +	/* use flags as a check condition, if it is 1, check, or, not check... zhua */
   1036   9731    henryz +	int check = buf->flags;
   1037   9731    henryz +	/* set flags back to 0 */
   1038   9731    henryz +	buf->flags = 0;
   1039  15005    henryz +
   1040   8857  dc144907  #if GLIBTOP_SOLARIS_RELEASE >= 50600
   1041   8649  hz159841  	prxmap_t *maps;
   1042  10389    henryz -	struct ps_prochandle *Pr = NULL;
   1043  15005    henryz +//	struct ps_prochandle *Pr = NULL;
   1044  10389    henryz  #else
   1045  10389    henryz  	prmap_t *maps;
   1046  10389    henryz  #endif
   1047  17586     gheet @@ -123,16 +130,44 @@
   1048   8649  hz159841  	buf->total = nmaps * sizeof(glibtop_map_entry);
   1049   8649  hz159841  	entry = g_malloc0(buf->total);
   1050   8649  hz159841  
   1051   8857  dc144907 -#if GLIBTOP_SOLARIS_RELEASE >= 50600
   1052  15005    henryz +//#if GLIBTOP_SOLARIS_RELEASE >= 50600
   1053  15005    henryz  
   1054   8649  hz159841 -	if(server->machine.objname && server->machine.pgrab &&
   1055   8649  hz159841 -	   server->machine.pfree)
   1056   8649  hz159841 -	   Pr = (server->machine.pgrab)(pid, 1, &pr_err);
   1057   8649  hz159841 -#endif
   1058  15005    henryz +//	if(server->machine.objname && server->machine.pgrab &&
   1059  15005    henryz +//	   server->machine.pfree)
   1060  15005    henryz +//	   Pr = (server->machine.pgrab)(pid, 1, &pr_err);
   1061  15005    henryz +//#endif
   1062   8649  hz159841  	for(heap = 0,i = 0; i < nmaps; ++i)
   1063   8649  hz159841  	{
   1064  15005    henryz  	   	int len;
   1065  15005    henryz  
   1066   9731    henryz +		/* take a check to see if we need all information, if not, just get what we need.. 
   1067   9731    henryz +		   Also please see comments in get_process_memory_writable() of gnome-system-monitor zhua */
   1068   9731    henryz +		if (check == 1)
   1069   9731    henryz +		{
   1070   9731    henryz +			if(maps[i].pr_mflags & MA_WRITE){
   1071   9731    henryz +		   	entry[i].perm |= GLIBTOP_MAP_PERM_WRITE;
   1072   9731    henryz +		   	entry[i].size = maps[i].pr_size;
   1073   9731    henryz +			}
   1074  11362    henryz +                if(maps[i].pr_mflags & MA_SHARED){
   1075   9731    henryz +                        entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
   1076   9731    henryz +			/* here use shared_clean to store Shared Memory */
   1077   9731    henryz +                        entry[i].shared_clean = maps[i].pr_size; 
   1078   9731    henryz +                	}
   1079   9731    henryz +		}
   1080  10389    henryz +                else
   1081  10389    henryz +                if (check == 2)
   1082  10389    henryz +                {
   1083  10389    henryz +                       if(maps[i].pr_mflags & MA_SHARED){
   1084  10389    henryz +                        entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
   1085  10389    henryz +                       /* here use shared_clean to store Shared Memory */
   1086  10389    henryz +                        entry[i].shared_clean = maps[i].pr_size;
   1087  10389    henryz +                       }
   1088  10389    henryz +                }
   1089   9731    henryz +		else {
   1090   9731    henryz +		
   1091   8649  hz159841 +	   	int len, rv;
   1092  15005    henryz + 
   1093  15005    henryz +
   1094   8649  hz159841  	   	entry[i].start = maps[i].pr_vaddr;
   1095   8649  hz159841  		entry[i].end = maps[i].pr_vaddr + maps[i].pr_size;
   1096  15005    henryz  
   1097  17586     gheet @@ -177,25 +212,40 @@
   1098   8649  hz159841  		   entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
   1099   8649  hz159841  		}
   1100   8649  hz159841  		else
   1101   8649  hz159841 -		   if(Pr)
   1102   8649  hz159841 -		   {
   1103   8649  hz159841 -		      server->machine.objname(Pr, maps[i].pr_vaddr, buffer,
   1104   8649  hz159841 -					      BUFSIZ);
   1105   8649  hz159841 -		      if((len = resolvepath(buffer, entry[i].filename,
   1106   8649  hz159841 -					    GLIBTOP_MAP_FILENAME_LEN)) > 0)
   1107   8649  hz159841 -		      {
   1108   8649  hz159841 -			 entry[i].filename[len] = 0;
   1109   8649  hz159841 -			 entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
   1110   8649  hz159841 -		      }
   1111   8649  hz159841 -		   }
   1112  15005    henryz -#endif
   1113  15005    henryz -	}
   1114  15005    henryz -
   1115  15005    henryz -#if GLIBTOP_SOLARIS_RELEASE >= 50600
   1116  15005    henryz -
   1117  15005    henryz -	if(Pr)
   1118  15005    henryz -	   	server->machine.pfree(Pr);
   1119  15005    henryz -#endif
   1120  15005    henryz +//		   if(Pr)
   1121  15005    henryz +//		   {
   1122  15005    henryz +//		      server->machine.objname(Pr, maps[i].pr_vaddr, buffer,
   1123  15005    henryz +//					      BUFSIZ);
   1124  15005    henryz +//		      if((len = resolvepath(buffer, entry[i].filename,
   1125  15005    henryz +//					    GLIBTOP_MAP_FILENAME_LEN)) > 0)
   1126  15005    henryz +//		      {
   1127  15005    henryz +//			 entry[i].filename[len] = 0;
   1128  15005    henryz +//			 entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
   1129  15005    henryz +//		      }
   1130  15005    henryz +//		   }
   1131  15005    henryz +               {
   1132  11362    henryz +                        g_strlcpy(buffer, maps[i].pr_mapname,  sizeof buffer);
   1133   9302  hz159841 +                        /* from /path get file name */
   1134   9302  hz159841 +                        g_snprintf(filename, sizeof filename, "/proc/%d/path/%s",
   1135   9302  hz159841 +                                pid, buffer);
   1136   9302  hz159841 + 
   1137   9302  hz159841 +                        rv = readlink(filename, entry[i].filename, sizeof(entry[i].filename) - 1);
   1138   9302  hz159841 +                        /* read object, if have not, set it as NULL */
   1139   9302  hz159841 +                        if(rv < 0)
   1140   9302  hz159841 +                                rv = 0;
   1141   9302  hz159841 +                        entry[i].filename[rv] = '\0';
   1142   9302  hz159841 +                        /* now set the flags */
   1143   9302  hz159841 +                        entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
   1144   9302  hz159841 +                }
   1145  15005    henryz +#endif
   1146  11362    henryz +	}
   1147  15005    henryz +        }
   1148  15005    henryz +
   1149  15005    henryz +//#if GLIBTOP_SOLARIS_RELEASE >= 50600
   1150  15005    henryz +
   1151  15005    henryz +//	if(Pr)
   1152  15005    henryz +//	   	server->machine.pfree(Pr);
   1153  15005    henryz +//#endif
   1154   8649  hz159841  	buf->flags = _glibtop_sysdeps_proc_map;
   1155   8649  hz159841  	s_close(fd);
   1156   8649  hz159841  	return entry;
   1157  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/procmem.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procmem.c
   1158  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/procmem.c	2008-05-23 22:13:24.000000000 +0000
   1159  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procmem.c	2009-02-25 17:16:38.061600000 +0000
   1160  11362    henryz @@ -22,12 +22,14 @@
   1161   8649  hz159841  #include <config.h>
   1162   8649  hz159841  #include <glibtop.h>
   1163   8649  hz159841  #include <glibtop/procmem.h>
   1164   8649  hz159841 +#include <glibtop/procmap.h>
   1165   8649  hz159841  
   1166   8649  hz159841  #include "glibtop_private.h"
   1167   8649  hz159841  
   1168  10389    henryz  static const unsigned long _glibtop_sysdeps_proc_mem =
   1169  10389    henryz  (1L << GLIBTOP_PROC_MEM_SIZE) + (1L << GLIBTOP_PROC_MEM_VSIZE) +
   1170  10389    henryz -(1L << GLIBTOP_PROC_MEM_RESIDENT) + (1L << GLIBTOP_PROC_MEM_RSS);
   1171  10389    henryz +(1L << GLIBTOP_PROC_MEM_RESIDENT) + (1L << GLIBTOP_PROC_MEM_RSS) +
   1172  10389    henryz +(1L << GLIBTOP_PROC_MEM_SHARE);
   1173  10389    henryz  
   1174  10389    henryz  /* Init function. */
   1175  10389    henryz  
   1176  17586     gheet @@ -61,5 +63,31 @@
   1177   8649  hz159841  	buf->size = buf->vsize = psinfo.pr_size << pagesize << 10;
   1178   8649  hz159841  	buf->resident = buf->rss = psinfo.pr_rssize << pagesize << 10;
   1179   8649  hz159841  #endif
   1180   8649  hz159841 +/* get Shared Memory  */
   1181   9302  hz159841 +        glibtop_proc_map mapbuf;
   1182   9302  hz159841 +        glibtop_map_entry *maps;
   1183   9302  hz159841 +        unsigned i;
   1184   9302  hz159841 +        buf->share = 0;
   1185   9731    henryz +	
   1186   9731    henryz +	/* we have to optimize the performance of libgtop, because update the information will occupy too much cpu.
   1187   9302  hz159841 + 
   1188   9731    henryz +           here I would like to make a little update:set glibtop_proc_map.flags=1,so as to let glibtop_get_proc_map_s()
   1189   9731    henryz +           only return the ones this function need: memwritable
   1190   9731    henryz + 
   1191   9731    henryz +           we do the check in glibtop_get_proc_map_s(), don't run the others part which don't need by this function,
   1192   9731    henryz +	   I think this will accelerate the transaction lots,
   1193   9731    henryz +           Also this will not affect the existing codes, because when nobody set glibtop_proc_map.flags,
   1194   9731    henryz +           glibtop_get_proc_map() will return all as before. zhua
   1195   9731    henryz +	*/
   1196   9731    henryz +	mapbuf.flags = 2;
   1197   9731    henryz + 
   1198   9302  hz159841 +        maps = glibtop_get_proc_map_s(server, &mapbuf, pid);
   1199   9302  hz159841 + 
   1200   9302  hz159841 +        for (i = 0; i < mapbuf.number; ++i) {
   1201   9302  hz159841 +                if (maps[i].perm & GLIBTOP_MAP_PERM_SHARED)
   1202   9302  hz159841 +                        buf->share += maps[i].shared_clean;
   1203   9302  hz159841 +        }
   1204   9302  hz159841 +        g_free(maps);
   1205   9302  hz159841 + 
   1206   8649  hz159841  	buf->flags = _glibtop_sysdeps_proc_mem;
   1207   8649  hz159841  }
   1208  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/procstate.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procstate.c
   1209  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/procstate.c	2008-05-23 22:13:24.000000000 +0000
   1210  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procstate.c	2009-02-25 17:16:38.062411000 +0000
   1211  17586     gheet @@ -62,6 +62,26 @@
   1212  11362    henryz  	buf->gid = psinfo.pr_egid;
   1213  10312    henryz  	buf->ruid = psinfo.pr_uid;
   1214  10312    henryz  	buf->rgid = psinfo.pr_gid;
   1215  15005    henryz +       /* zhua: get some value here, so that we don't need run open/pread/close psinfo later,
   1216  10312    henryz +                 and can delete some other call for psinfo open/pread/close. it will save lots of time*/
   1217  10312    henryz +#ifdef HAVE_PROCFS_H
   1218  10312    henryz +        buf->nice = psinfo.pr_lwp.pr_nice - NZERO;
   1219  10312    henryz +#else
   1220  10312    henryz +        buf->nice = psinfo.pr_nice - NZERO;
   1221  10312    henryz +#endif
   1222  15005    henryz +        buf->start_time = psinfo.pr_start.tv_sec; 
   1223  10312    henryz +        buf->ppid = psinfo.pr_ppid;
   1224  10312    henryz +   
   1225  10312    henryz +#ifdef HAVE_PROCFS_H
   1226  10312    henryz +        buf->vsize = psinfo.pr_size << 10;
   1227  10312    henryz +        buf->resident= psinfo.pr_rssize << 10;
   1228  11362    henryz +        buf->load = (guint) psinfo.pr_lwp.pr_pctcpu * 100 / (guint) 0x8000;
   1229  10312    henryz +#else
   1230  10312    henryz +        buf->vsize = psinfo.pr_size << pagesize << 10;
   1231  10312    henryz +        buf->resident = psinfo.pr_rssize << pagesize << 10;
   1232  10312    henryz +        buf->load = (guint) psinfo.pr_lwp.pr_pctcpu * 100 / (guint) 0x8000;
   1233  10312    henryz +#endif
   1234  11362    henryz +	
   1235  11362    henryz  
   1236  10312    henryz  #ifdef HAVE_PROCFS_H
   1237  10312    henryz  	switch(psinfo.pr_lwp.pr_state)
   1238  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/proctime.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/proctime.c
   1239  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/proctime.c	2008-05-23 22:13:24.000000000 +0000
   1240  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/proctime.c	2009-02-25 17:16:38.062715000 +0000
   1241  17586     gheet @@ -43,6 +43,11 @@
   1242   9302  hz159841  glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf,
   1243   9302  hz159841  			 pid_t pid)
   1244   9302  hz159841  {
   1245   9302  hz159841 +#ifdef HAVE_PROCFS_H
   1246   9302  hz159841 +       struct psinfo pinfo;
   1247   9302  hz159841 +#else
   1248   9302  hz159841 +       struct prpsinfo pinfo;
   1249   9302  hz159841 +#endif
   1250   9302  hz159841  	struct prusage prusage;
   1251  15005    henryz          GTimeVal time;
   1252   9302  hz159841  
   1253  17586     gheet @@ -52,19 +57,27 @@
   1254   9302  hz159841  
   1255   9302  hz159841  	if(pid)
   1256   9302  hz159841  	{
   1257  11362    henryz +  /* zhua remove this function call, because we can change to get start_time in
   1258  15005    henryz +        glibtop_get_proc_state(), it don't need open psinfo again here */
   1259  10312    henryz +
   1260   9302  hz159841 +                if (glibtop_get_proc_data_psinfo_s(server, &pinfo, pid))
   1261   9302  hz159841 +                        return;
   1262  15005    henryz +                buf->start_time = pinfo.pr_start.tv_sec; 
   1263   9302  hz159841 +
   1264   9302  hz159841  		if (glibtop_get_proc_data_usage_s (server, &prusage, pid))
   1265   9302  hz159841  			return;
   1266   9302  hz159841  
   1267   9302  hz159841 -                g_get_current_time (&time);
   1268   9302  hz159841 -		/* prusage.pr_rtime.tv_sec is the during that the process existed */
   1269   9302  hz159841 -                buf->start_time = time.tv_sec - prusage.pr_rtime.tv_sec;
   1270  15005    henryz +//                g_get_current_time (&time);
   1271  15005    henryz +//		/* prusage.pr_rtime.tv_sec is the during that the process existed */
   1272  15005    henryz + //               buf->start_time = time.tv_sec - prusage.pr_rtime.tv_sec;
   1273  15005    henryz  
   1274   9302  hz159841 -		buf->rtime = prusage.pr_rtime.tv_sec * 1E+6 +
   1275   9302  hz159841 -			prusage.pr_rtime.tv_nsec / 1E+3;
   1276  15005    henryz +//		buf->rtime = prusage.pr_rtime.tv_sec * 1E+6 +
   1277  15005    henryz +//			prusage.pr_rtime.tv_nsec / 1E+3;
   1278   9302  hz159841  		buf->utime = prusage.pr_utime.tv_sec * 1E+6 +
   1279   9302  hz159841  			prusage.pr_utime.tv_nsec / 1E+3;
   1280   9302  hz159841  		buf->stime = prusage.pr_stime.tv_sec * 1E+6 +
   1281   9302  hz159841  			prusage.pr_stime.tv_nsec / 1E+3;
   1282   9302  hz159841 +		buf->rtime = (buf->utime + buf->stime) / 10000;
   1283   9302  hz159841  	}
   1284   9302  hz159841  
   1285   9302  hz159841  	buf->flags = _glibtop_sysdeps_proc_time;
   1286  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/procwd.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procwd.c
   1287  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/procwd.c	1970-01-01 00:00:00.000000000 +0000
   1288  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procwd.c	2009-02-25 17:16:38.062977000 +0000
   1289  11362    henryz @@ -0,0 +1,98 @@
   1290  11362    henryz +/* Copyright (C) 2007 Benot Dejean
   1291  11362    henryz +   This file is part of LibGTop 2.
   1292  11362    henryz +
   1293  11362    henryz +   LibGTop is free software; you can redistribute it and/or modify it
   1294  11362    henryz +   under the terms of the GNU General Public License as published by
   1295  11362    henryz +   the Free Software Foundation; either version 2 of the License,
   1296  11362    henryz +   or (at your option) any later version.
   1297  11362    henryz +
   1298  11362    henryz +   LibGTop is distributed in the hope that it will be useful, but WITHOUT
   1299  11362    henryz +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   1300  11362    henryz +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   1301  11362    henryz +   for more details.
   1302  11362    henryz +
   1303  11362    henryz +   You should have received a copy of the GNU General Public License
   1304  11362    henryz +   along with LibGTop; see the file COPYING. If not, write to the
   1305  11362    henryz +   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   1306  11362    henryz +   Boston, MA 02111-1307, USA.
   1307  11362    henryz +*/
   1308  11362    henryz +
   1309  11362    henryz +#include <config.h>
   1310  11362    henryz +#include <glibtop/procwd.h>
   1311  11362    henryz +#include <glibtop/error.h>
   1312  11362    henryz +
   1313  11362    henryz +#include <glibtop_private.h>
   1314  11362    henryz +
   1315  11362    henryz +#include <unistd.h>
   1316  11362    henryz +#include <dirent.h>
   1317  11362    henryz +#include <sys/types.h>
   1318  11362    henryz +
   1319  11362    henryz +
   1320  11362    henryz +void
   1321  11362    henryz +_glibtop_init_proc_wd_s(glibtop *server)
   1322  11362    henryz +{
   1323  11362    henryz +	server->sysdeps.proc_wd =
   1324  11362    henryz +	(1 << GLIBTOP_PROC_WD_EXE) +
   1325  11362    henryz +	(1 << GLIBTOP_PROC_WD_ROOT) +
   1326  11362    henryz +	(1 << GLIBTOP_PROC_WD_NUMBER);
   1327  11362    henryz +
   1328  11362    henryz +}
   1329  11362    henryz +
   1330  11362    henryz +static gboolean is_in(GPtrArray *array, const char *str)
   1331  11362    henryz +{
   1332  11362    henryz +	guint i;
   1333  11362    henryz +
   1334  11362    henryz +	for (i = 0; i != array->len; ++i) {
   1335  11362    henryz +		if (strcmp(g_ptr_array_index(array, i), str) == 0)
   1336  11362    henryz +			return TRUE;
   1337  11362    henryz +	}
   1338  11362    henryz +
   1339  11362    henryz +	return FALSE;
   1340  11362    henryz +}
   1341  11362    henryz +
   1342  11362    henryz +
   1343  11362    henryz +char**
   1344  11362    henryz +glibtop_get_proc_wd_s(glibtop *server, glibtop_proc_wd *buf, pid_t pid)
   1345  11362    henryz +{
   1346  11362    henryz +	GPtrArray *dirs;
   1347  11362    henryz +	char path[80];
   1348  11362    henryz +	char dir[256];
   1349  11362    henryz +	DIR *task;
   1350  11362    henryz +
   1351  11362    henryz +	glibtop_init_s(&server, GLIBTOP_SYSDEPS_PROC_WD, 0);
   1352  11362    henryz +
   1353  11362    henryz +	memset(buf, 0, sizeof(glibtop_proc_wd));
   1354  11362    henryz +
   1355  11362    henryz +	g_snprintf(path, sizeof path, "/proc/%u/root", pid);
   1356  11362    henryz +	if (safe_readlink(path, buf->root, sizeof buf->root))
   1357  11362    henryz +		buf->flags |= (1 << GLIBTOP_PROC_WD_ROOT);
   1358  11362    henryz +
   1359  11362    henryz +	g_snprintf(path, sizeof path, "/proc/%u/exe", pid);
   1360  11362    henryz +	if (safe_readlink(path, buf->exe, sizeof buf->exe))
   1361  11362    henryz +		buf->flags |= (1 << GLIBTOP_PROC_WD_EXE);
   1362  11362    henryz +
   1363  11362    henryz +	dirs = g_ptr_array_sized_new(2);
   1364  11362    henryz +
   1365  11362    henryz +	g_snprintf(path, sizeof path, "/proc/%u/cwd", pid);
   1366  11362    henryz +	if (safe_readlink(path, dir, sizeof dir))
   1367  11362    henryz +		g_ptr_array_add(dirs, g_strdup(dir));
   1368  11362    henryz +
   1369  11362    henryz +	g_snprintf(path, sizeof path, "/proc/%u/task", pid);
   1370  11362    henryz +	if ((task = opendir(path)) != NULL) {
   1371  11362    henryz +		struct dirent *sub;
   1372  11362    henryz +		while ((sub = readdir(task)) != NULL) {
   1373  11362    henryz +			g_snprintf(path, sizeof path, "/proc/%u/task/%s/cwd", pid, sub->d_name);
   1374  11362    henryz +			if (safe_readlink(path, dir, sizeof dir) && !is_in(dirs, dir))
   1375  11362    henryz +				g_ptr_array_add(dirs, g_strdup(dir));
   1376  11362    henryz +		}
   1377  11362    henryz +		closedir(task);
   1378  11362    henryz +	}
   1379  11362    henryz +
   1380  11362    henryz +	buf->number = dirs->len;
   1381  11362    henryz +	buf->flags |= (1 << GLIBTOP_PROC_WD_NUMBER);
   1382  11362    henryz +
   1383  11362    henryz +	g_ptr_array_add(dirs, NULL);
   1384  11362    henryz +
   1385  11362    henryz +	return (char**) g_ptr_array_free(dirs, FALSE);
   1386  11362    henryz +}
   1387  11362    henryz +
   1388  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/sem_limits.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/sem_limits.c
   1389  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/sem_limits.c	2008-05-23 22:13:24.000000000 +0000
   1390  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/sem_limits.c	2009-02-25 17:16:38.063802000 +0000
   1391  17586     gheet @@ -39,14 +39,22 @@
   1392   9302  hz159841  (1L << GLIBTOP_IPC_SEMUSZ) + (1L << GLIBTOP_IPC_SEMVMX) +
   1393   9302  hz159841  (1L << GLIBTOP_IPC_SEMAEM);
   1394   9302  hz159841  #else
   1395   9302  hz159841 -static const unsigned long _glibtop_sysdeps_sem_limits = 0;
   1396  15005    henryz +static const unsigned long _glibtop_sysdeps_sem_limits = 
   1397   9302  hz159841 +(1L << GLIBTOP_IPC_SEMMNI) +
   1398   9302  hz159841 +(1L << GLIBTOP_IPC_SEMMSL) +
   1399   9302  hz159841 +(1L << GLIBTOP_IPC_SEMOPM);
   1400   9302  hz159841  #endif
   1401   9302  hz159841  
   1402   9302  hz159841  
   1403   9302  hz159841  /* Init function. */
   1404   9302  hz159841  
   1405   9302  hz159841 +#if GLIBTOP_SUID_SEM_LIMITS
   1406   9302  hz159841  void
   1407  11362    henryz  _glibtop_init_sem_limits_p (glibtop *server)
   1408   9302  hz159841 +#else
   1409   9302  hz159841 +void
   1410  11362    henryz +_glibtop_init_sem_limits_s (glibtop *server)
   1411  11362    henryz +#endif
   1412   9302  hz159841  {
   1413   9302  hz159841  #if GLIBTOP_SOLARIS_RELEASE < 51000
   1414   9302  hz159841  
   1415  17586     gheet @@ -61,8 +69,13 @@
   1416   9302  hz159841  
   1417   9302  hz159841  /* Provides information about sysv sem limits. */
   1418   9302  hz159841  
   1419   9302  hz159841 +#if GLIBTOP_SUID_SEM_LIMITS
   1420   9302  hz159841  void
   1421   9302  hz159841  glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
   1422   9302  hz159841 +#else
   1423   9302  hz159841 +void
   1424   9302  hz159841 +glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
   1425   9302  hz159841 +#endif
   1426   9302  hz159841  {
   1427   9302  hz159841  #if GLIBTOP_SOLARIS_RELEASE < 51000
   1428   9302  hz159841     	kvm_t *kd = server->machine.kd;
   1429  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/shm_limits.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/shm_limits.c
   1430  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/shm_limits.c	2008-05-23 22:13:24.000000000 +0000
   1431  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/shm_limits.c	2009-02-25 17:16:38.064069000 +0000
   1432  11362    henryz @@ -30,7 +30,9 @@
   1433   9302  hz159841  static const struct nlist nlst[] = { {"glibtop_shm_limits"}, {NULL} };
   1434   9302  hz159841  
   1435   9302  hz159841  #if GLIBTOP_SOLARIS_RELEASE >=51000
   1436   9302  hz159841 -static const unsigned long _glibtop_sysdeps_shm_limits = 0;
   1437  15005    henryz +static const unsigned long _glibtop_sysdeps_shm_limits = 
   1438   9302  hz159841 +(1L << GLIBTOP_IPC_SHMMAX) +
   1439   9302  hz159841 +(1L << GLIBTOP_IPC_SHMMIN);
   1440   9302  hz159841  #else
   1441   9302  hz159841  # if GLIBTOP_SOLARIS_RELEASE < 50900
   1442   9302  hz159841  static const unsigned long _glibtop_sysdeps_shm_limits =
   1443  17586     gheet @@ -45,8 +47,13 @@
   1444   9302  hz159841  
   1445   9302  hz159841  /* Init function. */
   1446   9302  hz159841  
   1447   9302  hz159841 +#if GLIBTOP_SUID_SHM_LIMITS
   1448   9302  hz159841  void
   1449  11362    henryz  _glibtop_init_shm_limits_p (glibtop *server)
   1450   9302  hz159841 +#else
   1451   9302  hz159841 +void
   1452  11362    henryz +_glibtop_init_shm_limits_s (glibtop *server)
   1453   9302  hz159841 +#endif
   1454   9302  hz159841  {
   1455   9302  hz159841  #if GLIBTOP_SOLARIS_RELEASE < 51000
   1456   9302  hz159841  
   1457  17586     gheet @@ -61,8 +68,13 @@
   1458   9302  hz159841  
   1459   9302  hz159841  /* Provides information about sysv ipc limits. */
   1460   9302  hz159841  
   1461   9302  hz159841 +#if GLIBTOP_SUID_SHM_LIMITS
   1462   9302  hz159841  void
   1463   9302  hz159841  glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
   1464   9302  hz159841 +#else
   1465   9302  hz159841 +void
   1466   9302  hz159841 +glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
   1467   9302  hz159841 +#endif
   1468   9302  hz159841  {
   1469   9302  hz159841  #if GLIBTOP_SOLARIS_RELEASE < 51000
   1470   9302  hz159841  
   1471  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/siglist.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/siglist.c
   1472  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/siglist.c	2008-05-23 22:13:24.000000000 +0000
   1473  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/siglist.c	2009-02-25 17:16:38.064867000 +0000
   1474  17586     gheet @@ -61,6 +61,7 @@
   1475   8649  hz159841     { 35, "SIGTHAW", "Checkpoint Thaw" },
   1476   8649  hz159841     { 36, "SIGCANCEL","Thread Cancelation" },
   1477   8649  hz159841     { 37, "SIGLOST", "Resource Lost" },
   1478  11362    henryz +#if GLIBTOP_SOLARIS_RELEASE < 50900    /* S8 */   
   1479   8649  hz159841     { 38, "SIGRTMIN","First Realtime Signal" },
   1480   8649  hz159841     { 39, "SIGRTMIN+1", "Second Realtime Signal" },
   1481   8649  hz159841     { 40, "SIGRTMIN+2", "Third Realtime Signal" },
   1482  17586     gheet @@ -69,5 +70,30 @@
   1483   8649  hz159841     { 43, "SIGRTMAX-2", "Third Last Realtime Signal" },
   1484   8649  hz159841     { 44, "SIGRTMAX-1", "Second Last Realtime Signal" },
   1485   8649  hz159841     { 45, "SIGRTMAX", "Last Realtime Signal" },
   1486   8649  hz159841 +#endif
   1487   8649  hz159841 +#if GLIBTOP_SOLARIS_RELEASE >= 50900
   1488   8649  hz159841 +   { 38, "SIGXRES","Resource Control Exceeded" },
   1489   8649  hz159841 +#if GLIBTOP_SOLARIS_RELEASE <51000	/* signal here existed in s9 */
   1490   8649  hz159841 +   { 39, "SIGRTMIN","First Realtime Signal" },
   1491   8649  hz159841 +   { 40, "SIGRTMIN+1", "Second Realtime Signal" },
   1492   8649  hz159841 +   { 41, "SIGRTMIN+2", "Third Realtime Signal" },
   1493   8649  hz159841 +   { 42, "SIGRTMIN+3", "Fourth Realtime Signal" },
   1494   8649  hz159841 +   { 43, "SIGRTMAX-3", "Fourth Last Realtime Signal" },
   1495   8649  hz159841 +   { 44, "SIGRTMAX-2", "Third Last Realtime Signal" },
   1496   8649  hz159841 +   { 45, "SIGRTMAX-1", "Second Last Realtime Signal" },
   1497   8649  hz159841 +   { 46, "SIGRTMAX", "Last Realtime Signal" },
   1498   8649  hz159841 +#else /*  signal here existed in s10 and s11 */
   1499   8649  hz159841 +   { 39, "SIGJVM1","Reserved signal for Java Virtual Machine" },
   1500   8649  hz159841 +   { 40, "SIGJVM1","Reserved signal for Java Virtual Machine" },
   1501   8649  hz159841 +   { 41, "SIGRTMIN","First Realtime Signal" },
   1502   8649  hz159841 +   { 42, "SIGRTMIN+1", "Second Realtime Signal" },
   1503   8649  hz159841 +   { 43, "SIGRTMIN+2", "Third Realtime Signal" },
   1504   8649  hz159841 +   { 44, "SIGRTMIN+3", "Fourth Realtime Signal" },
   1505   8649  hz159841 +   { 45, "SIGRTMAX-3", "Fourth Last Realtime Signal" },
   1506   8649  hz159841 +   { 46, "SIGRTMAX-2", "Third Last Realtime Signal" },
   1507   8649  hz159841 +   { 47, "SIGRTMAX-1", "Second Last Realtime Signal" },
   1508   8649  hz159841 +   { 48, "SIGRTMAX", "Last Realtime Signal" },
   1509   8649  hz159841 +#endif
   1510   8649  hz159841 +#endif
   1511   8649  hz159841     {  0, NULL, NULL }
   1512   8649  hz159841  };
   1513  17586     gheet diff -urN libgtop-2.25.91/sysdeps/solaris/sysinfo.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/sysinfo.c
   1514  17586     gheet --- libgtop-2.25.91/sysdeps/solaris/sysinfo.c	1970-01-01 00:00:00.000000000 +0000
   1515  17586     gheet +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/sysinfo.c	2009-02-25 17:16:38.065095000 +0000
   1516   8649  hz159841 @@ -0,0 +1,48 @@
   1517   8649  hz159841 +/* $Id: sysinfo.c,v 1.22 2004/11/28 01:32:55 bdejean Exp $ */
   1518   8649  hz159841 +
   1519   8649  hz159841 +/* Copyright (C) 1998-99 Martin Baulig
   1520   8649  hz159841 +   This file is part of LibGTop 1.0.
   1521   8649  hz159841 +
   1522   8649  hz159841 +   Contributed by Martin Baulig <martin (a] home-of-linux.org>, April 1998.
   1523   8649  hz159841 +
   1524   8649  hz159841 +   LibGTop is free software; you can redistribute it and/or modify it
   1525   8649  hz159841 +   under the terms of the GNU General Public License as published by
   1526   8649  hz159841 +   the Free Software Foundation; either version 2 of the License,
   1527   8649  hz159841 +   or (at your option) any later version.
   1528   8649  hz159841 +
   1529   8649  hz159841 +   LibGTop is distributed in the hope that it will be useful, but WITHOUT
   1530   8649  hz159841 +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   1531   8649  hz159841 +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   1532   8649  hz159841 +   for more details.
   1533   8649  hz159841 +
   1534   8649  hz159841 +   You should have received a copy of the GNU General Public License
   1535   8649  hz159841 +   along with LibGTop; see the file COPYING. If not, write to the
   1536   8649  hz159841 +   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   1537   8649  hz159841 +   Boston, MA 02111-1307, USA.
   1538   8649  hz159841 +*/
   1539   8649  hz159841 +
   1540   8649  hz159841 +#include <config.h>
   1541   8649  hz159841 +#include <glibtop/error.h>
   1542   8649  hz159841 +#include <glibtop/cpu.h>
   1543   8649  hz159841 +#include <glibtop/sysinfo.h>
   1544   8649  hz159841 +
   1545   8649  hz159841 +#include "glibtop_private.h"
   1546   8649  hz159841 +
   1547   8649  hz159841 +
   1548   8649  hz159841 +static const unsigned long _glibtop_sysdeps_sysinfo =
   1549   8649  hz159841 +(1L << GLIBTOP_SYSINFO_CPUINFO);
   1550   8649  hz159841 +
   1551   8649  hz159841 +static glibtop_sysinfo sysinfo = { .flags = 0 };
   1552   8649  hz159841 +
   1553   8649  hz159841 +static void
   1554   8649  hz159841 +init_sysinfo (glibtop *server)
   1555   8649  hz159841 +{
   1556   8649  hz159841 +
   1557   8649  hz159841 +}
   1558   8649  hz159841 +
   1559   8649  hz159841 +const glibtop_sysinfo *
   1560   8649  hz159841 +glibtop_get_sysinfo_s (glibtop *server)
   1561   8649  hz159841 +{
   1562   8649  hz159841 +	init_sysinfo (server);
   1563   8649  hz159841 +	return &sysinfo;
   1564   8649  hz159841 +}
   1565