1 Existing patch from desktop for building on Solaris - Needs reworking and cleanup so this can be contributed upstream.
3 XXX file upstream enhancement
5 diff -urN libgtop-2.25.91/include/glibtop/procstate.h ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/include/glibtop/procstate.h
6 --- libgtop-2.25.91/include/glibtop/procstate.h 2008-05-23 22:13:20.000000000 +0000
7 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/include/glibtop/procstate.h 2009-02-25 17:16:38.052247000 +0000
13 + gint32 nice; /*zhua: used to store nice */
14 + guint64 start_time; /* start time of process -- */
15 + guint64 vsize; /* number of pages of virtual memory ... */
16 + guint64 resident; /* number of resident set */
17 + guint load; /* cpu load for process */
18 + gint32 ppid; /* pid of parent process */
21 void glibtop_get_proc_state(glibtop_proc_state *buf, pid_t pid);
22 diff -urN libgtop-2.25.91/procmap.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/procmap.c
23 --- libgtop-2.25.91/procmap.c 1970-01-01 00:00:00.000000000 +0000
24 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/procmap.c 2009-02-25 17:16:38.053079000 +0000
26 +/* Copyright (C) 1998-99 Martin Baulig
27 + This file is part of LibGTop 1.0.
29 + Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
31 + LibGTop is free software; you can redistribute it and/or modify it
32 + under the terms of the GNU General Public License as published by
33 + the Free Software Foundation; either version 2 of the License,
34 + or (at your option) any later version.
36 + LibGTop is distributed in the hope that it will be useful, but WITHOUT
37 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
38 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
41 + You should have received a copy of the GNU General Public License
42 + along with LibGTop; see the file COPYING. If not, write to the
43 + Free Software Foundation, Inc., 59 Temple Place - Suite 330,
44 + Boston, MA 02111-1307, USA.
50 +#include <glibtop/error.h>
51 +#include <glibtop/procmap.h>
58 +static const unsigned long _glibtop_sysdeps_proc_map =
59 +(1L << GLIBTOP_PROC_MAP_NUMBER) + (1L << GLIBTOP_PROC_MAP_TOTAL) +
60 +(1L << GLIBTOP_PROC_MAP_SIZE);
61 +static const unsigned long _glibtop_sysdeps_map_entry =
62 +(1L << GLIBTOP_MAP_ENTRY_START) + (1L << GLIBTOP_MAP_ENTRY_END) +
63 +(1L << GLIBTOP_MAP_ENTRY_OFFSET) + (1L << GLIBTOP_MAP_ENTRY_PERM);
64 +static const unsigned long _glibtop_sysdeps_map_device =
65 +(1L << GLIBTOP_MAP_ENTRY_DEVICE) + (1L << GLIBTOP_MAP_ENTRY_INODE);
71 +_glibtop_init_proc_map_s (glibtop *server)
73 + server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
76 +/* Provides detailed information about a process. */
79 +glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
81 + int fd, i, nmaps, pr_err, heap;
83 + char filename [BUFSIZ];
84 + /* use flags as a check condition, if it is 1, check, or, not check... zhua */
85 + int check = buf->flags;
86 + /* set flags back to 0 */
89 +#if GLIBTOP_SOLARIS_RELEASE >= 50600
91 +// struct ps_prochandle *Pr = NULL;
96 + /* A few defines, to make it shorter down there */
99 +# define OFFSET pr_offset
101 +# define OFFSET pr_off
104 + glibtop_map_entry *entry;
106 + char buffer[BUFSIZ];
108 + memset (buf, 0, sizeof (glibtop_proc_map));
110 +#ifdef HAVE_PROCFS_H
111 + sprintf(buffer, "/proc/%d/xmap", (int)pid);
113 + sprintf(buffer, "/proc/%d", (int)pid);
115 + if((fd = s_open(buffer, O_RDONLY)) < 0)
117 + if (errno != EPERM && errno != EACCES)
118 + glibtop_warn_io_r(server, "open (%s)", buffer);
121 +#ifdef HAVE_PROCFS_H
122 + if(fstat(fd, &inode) < 0)
124 + if(errno != EOVERFLOW)
125 + glibtop_warn_io_r(server, "fstat (%s)", buffer);
126 + /* else call daemon for 64-bit support */
130 + maps = g_alloca(inode.st_size);
131 + nmaps = inode.st_size / sizeof(prxmap_t);
132 + if(s_pread(fd, maps, inode.st_size, 0) != inode.st_size)
134 + glibtop_warn_io_r(server, "pread (%s)", buffer);
139 + if(ioctl(fd, PIOCNMAP, &nmaps) < 0)
141 + glibtop_warn_io_r(server, "ioctl(%s, PIOCNMAP)", buffer);
145 + maps = g_alloca((nmaps + 1) * sizeof(prmap_t));
146 + if(ioctl(fd, PIOCMAP, maps) < 0)
148 + glibtop_warn_io_r(server, "ioctl(%s, PIOCMAP)", buffer);
153 + buf->number = nmaps;
154 + buf->size = sizeof(glibtop_map_entry);
155 + buf->total = nmaps * sizeof(glibtop_map_entry);
156 + entry = g_malloc0(buf->total);
158 +//#if GLIBTOP_SOLARIS_RELEASE >= 50600
160 +// if(server->machine.objname && server->machine.pgrab &&
161 +// server->machine.pfree)
162 +// Pr = (server->machine.pgrab)(pid, 1, &pr_err);
164 + for(heap = 0,i = 0; i < nmaps; ++i)
168 + /* take a check to see if we need all information, if not, just get what we need..
169 + Also please see comments in get_process_memory_writable() of gnome-system-monitor zhua */
172 + if(maps[i].pr_mflags & MA_WRITE){
173 + entry[i].perm |= GLIBTOP_MAP_PERM_WRITE;
174 + entry[i].size = maps[i].pr_size;
176 + if(maps[i].pr_mflags & MA_SHARED){
177 + entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
178 + /* here use shared_clean to store Shared Memory */
179 + entry[i].shared_clean = maps[i].pr_size;
185 + if(maps[i].pr_mflags & MA_SHARED){
186 + entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
187 + /* here use shared_clean to store Shared Memory */
188 + entry[i].shared_clean = maps[i].pr_size;
196 + entry[i].start = maps[i].pr_vaddr;
197 + entry[i].end = maps[i].pr_vaddr + maps[i].pr_size;
199 +#if GLIBTOP_SOLARIS_RELEASE >= 50600
201 + if(maps[i].pr_dev != PRNODEV)
203 + entry[i].device = maps[i].pr_dev;
204 + entry[i].inode = maps[i].pr_ino;
205 + entry[i].flags |= _glibtop_sysdeps_map_device;
208 + entry[i].offset = maps[i].OFFSET;
209 + if(maps[i].pr_mflags & MA_READ)
210 + entry[i].perm |= GLIBTOP_MAP_PERM_READ;
211 + if(maps[i].pr_mflags & MA_WRITE){
212 + entry[i].perm |= GLIBTOP_MAP_PERM_WRITE;
213 + entry[i].size = maps[i].pr_size;
215 + if(maps[i].pr_mflags & MA_EXEC)
216 + entry[i].perm |= GLIBTOP_MAP_PERM_EXECUTE;
217 + if(maps[i].pr_mflags & MA_SHARED)
218 + entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
220 + entry[i].perm |= GLIBTOP_MAP_PERM_PRIVATE;
221 + entry[i].flags = _glibtop_sysdeps_map_entry;
223 +#if GLIBTOP_SOLARIS_RELEASE >= 50600
225 + if(maps[i].pr_mflags & MA_ANON)
230 + strcpy(entry[i].filename, "[ heap ]");
234 + strcpy(entry[i].filename, "[ stack ]");
236 + strcpy(entry[i].filename, "[ anon ]");
237 + entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
242 +// server->machine.objname(Pr, maps[i].pr_vaddr, buffer,
244 +// if((len = resolvepath(buffer, entry[i].filename,
245 +// GLIBTOP_MAP_FILENAME_LEN)) > 0)
247 +// entry[i].filename[len] = 0;
248 +// entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
252 + g_strlcpy(buffer, maps[i].pr_mapname, sizeof buffer);
253 + /* from /path get file name */
254 + g_snprintf(filename, sizeof filename, "/proc/%d/path/%s",
257 + rv = readlink(filename, entry[i].filename, sizeof(entry[i].filename) - 1);
258 + /* read object, if have not, set it as NULL */
261 + entry[i].filename[rv] = '\0';
262 + /* now set the flags */
263 + entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
269 +//#if GLIBTOP_SOLARIS_RELEASE >= 50600
272 +// server->machine.pfree(Pr);
274 + buf->flags = _glibtop_sysdeps_proc_map;
278 diff -urN libgtop-2.25.91/sysdeps/common/fsusage.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/common/fsusage.c
279 --- libgtop-2.25.91/sysdeps/common/fsusage.c 2008-05-23 22:13:22.000000000 +0000
280 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/common/fsusage.c 2009-02-25 17:25:57.183257000 +0000
282 #define _glibtop_get_fsusage_read_write(S, B, P) \
283 _glibtop_freebsd_get_fsusage_read_write(S, B, P)
285 +#elif (defined(sun) || defined(__sun))
286 +G_GNUC_INTERNAL void
287 +_glibtop_sun_get_fsusage_read_write(glibtop *server,
288 + glibtop_fsusage *buf,
291 +#define _glibtop_get_fsusage_read_write(S, B, P) \
292 + _glibtop_sun_get_fsusage_read_write(S, B, P)
294 #else /* default fallback */
295 #warning glibtop_get_fsusage .read .write are not implemented.
297 diff -urN libgtop-2.25.91/sysdeps/common/mountlist.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/common/mountlist.c
298 --- libgtop-2.25.91/sysdeps/common/mountlist.c 2008-05-23 22:13:22.000000000 +0000
299 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/common/mountlist.c 2009-02-25 17:16:38.053543000 +0000
302 for (cur = &entries[0]; cur != NULL; cur = next) {
304 + /*zhua: delete these 2 type of fs: objfs,ctfs */
305 + if (!strcmp(cur->me_type, "objfs") || !strcmp(cur->me_type,"ctfs")){
306 + /* free current mount_entry and move to the next */
307 + next = cur->me_next;
308 + g_free(cur->me_devname);
309 + g_free(cur->me_mountdir);
310 + g_free(cur->me_type);
315 if(all_fs || !ignore_mount_entry(cur)) {
316 /* add a new glibtop_mountentry */
317 glibtop_mountentry e;
318 diff -urN libgtop-2.25.91/sysdeps/solaris/Makefile.am ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/Makefile.am
319 --- libgtop-2.25.91/sysdeps/solaris/Makefile.am 2008-05-23 22:13:24.000000000 +0000
320 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/Makefile.am 2009-02-25 17:27:23.462319000 +0000
322 proclist.c procstate.c procuid.c \
323 proctime.c procmem.c procsignal.c \
324 prockernel.c procsegment.c procargs.c \
326 + procopenfiles.c sysinfo.c fsusage.c procwd.c \
327 + glibtop_private.c procaffinity.c \
328 procmap.c netload.c ppp.c procdata.c netlist.c
330 libgtop_sysdeps_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
331 diff -urN libgtop-2.25.91/sysdeps/solaris/cpu.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/cpu.c
332 --- libgtop-2.25.91/sysdeps/solaris/cpu.c 2008-05-23 22:13:24.000000000 +0000
333 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/cpu.c 2009-02-25 17:16:38.055204000 +0000
336 static const unsigned long _glibtop_sysdeps_cpu_all =
337 (1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
338 +(1L << GLIBTOP_CPU_NICE) + /* this value is needed by multiload */
339 (1L << GLIBTOP_CPU_SYS) + (1L << GLIBTOP_CPU_IDLE) +
340 (1L << GLIBTOP_XCPU_TOTAL) + (1L << GLIBTOP_XCPU_USER) +
341 (1L << GLIBTOP_XCPU_SYS) + (1L << GLIBTOP_XCPU_IDLE) +
342 diff -urN libgtop-2.25.91/sysdeps/solaris/fsusage.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/fsusage.c
343 --- libgtop-2.25.91/sysdeps/solaris/fsusage.c 1970-01-01 00:00:00.000000000 +0000
344 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/fsusage.c 2009-02-25 17:20:33.608888000 +0000
347 +#include <glibtop.h>
348 +#include <glibtop/error.h>
349 +#include <glibtop/fsusage.h>
350 +#include <glibtop/union.h>
352 +#include "glibtop_private.h"
358 +#include <sys/types.h>
359 +#include <sys/stat.h>
360 +#include <sys/statvfs.h>
366 +G_GNUC_INTERNAL void
367 +_glibtop_sun_get_fsusage_read_write(glibtop *server,
368 + glibtop_fsusage *buf,
371 + struct statvfs64 statvfsbuf;
372 + char ksname[KSTAT_STRLEN + 1];
373 + kstat_ctl_t * const kctl = server->machine->kc;
376 + kstat_named_t *kread, *kwrite;
380 + * get a kstat handle and update the user's kstat chain
382 + if( kctl == NULL ){
383 + glibtop_warn_io_r (server, "kstat_open ()");
387 + /* make sure we have current data */
388 + while( kstat_chain_update( kctl ) != 0 )
391 + for (ksp = kctl->kc_chain, i =0; ksp != NULL; ksp = ksp->ks_next, i++) {
392 + if (ksp->ks_type == KSTAT_TYPE_IO && strcmp(ksp->ks_class,"disk") == 0) {
393 + kstat_read(kctl, ksp, &kio);
394 + buf->read += kio.nread;
395 + buf->write += kio.nwritten;
399 + /* these codes keep here, because they are a good way to get the
400 + fsusage information, but at the moment, the interfaces used
401 + are not public or stable. so let's use them when public...
404 + * get a kstat handle and update the user's kstat chain
406 + if( kctl == NULL ){
407 + glibtop_warn_io_r (server, "kstat_open ()");
411 + while( kstat_chain_update( kctl ) != 0 )
414 + if (statvfs64(path, &statvfsbuf) != 0) {
415 + glibtop_warn_io_r (server, "kstat_open ()");
418 + snprintf(ksname, KSTAT_STRLEN, "%s%lx", VOPSTATS_STR,
419 + statvfsbuf.f_fsid);
422 + * traverse the kstat chain
423 + * to find the appropriate statistics
425 + if( (ksp = kstat_lookup( kctl,
426 + "unix", 0, ksname )) == NULL ) {
429 + if( kstat_read( kctl, ksp, NULL ) == -1 ) {
433 + kread = (kstat_named_t *)kstat_data_lookup(ksp,"read_bytes");
434 + if( kread != NULL ) {
435 + buf->read = kread->value.ull;
438 + kwrite = (kstat_named_t *)kstat_data_lookup(ksp,"write_bytes");
439 + if( kwrite != NULL ) {
440 + buf->write = kwrite->value.ull;
443 + buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
445 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
446 --- libgtop-2.25.91/sysdeps/solaris/glibtop_machine.h 2008-05-23 22:13:24.000000000 +0000
447 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_machine.h 2009-02-25 17:16:38.055426000 +0000
449 int pagesize; /* in bits to shift, ie. 2^pagesize gives Kb */
450 int ticks; /* clock ticks, as returned by sysconf() */
451 unsigned long long boot; /* boot time, although it's ui32 in kstat */
452 - void *libproc; /* libproc handle */
453 -#if GLIBTOP_SOLARIS_RELEASE >= 50600
454 - void (*objname)(void *, uintptr_t, const char *, size_t);
455 - struct ps_prochandle *(*pgrab)(pid_t, int, int *);
456 - void (*pfree)(void *);
458 +// void *libproc; /* libproc handle */
459 +//#if GLIBTOP_SOLARIS_RELEASE >= 50600
460 +// void (*objname)(void *, uintptr_t, const char *, size_t);
461 +// struct ps_prochandle *(*pgrab)(pid_t, int, int *);
462 +// void (*pfree)(void *);
470 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
471 --- libgtop-2.25.91/sysdeps/solaris/glibtop_private.c 1970-01-01 00:00:00.000000000 +0000
472 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_private.c 2009-02-25 17:16:38.055744000 +0000
475 +#include <glibtop.h>
476 +#include <glibtop/error.h>
478 +#include "glibtop_private.h"
491 +get_scaled(const char *buffer, const char *key)
495 + unsigned long long value = 0;
497 + if (G_LIKELY((ptr = strstr(buffer, key))))
499 + ptr += strlen(key);
500 + value = strtoull(ptr, &next, 0);
502 + for ( ; *next; ++next) {
503 + if (*next == 'k') {
506 + } else if (*next == 'M') {
507 + value *= 1024 * 1024;
512 + g_warning("Could not read key '%s' in buffer '%s'",
520 +skip_token (const char *p)
523 + while (*p && !isspace(*p)) p++;
532 +enum TRY_FILE_TO_BUFFER
534 + TRY_FILE_TO_BUFFER_OK = 0,
535 + TRY_FILE_TO_BUFFER_OPEN = -1,
536 + TRY_FILE_TO_BUFFER_READ = -2
539 +int try_file_to_buffer(char *buffer, const char *format, ...)
546 + va_start(pa, format);
548 + /* C99 also provides vsnprintf */
549 + g_vsnprintf(path, sizeof path, format, pa);
555 + if((fd = open (path, O_RDONLY)) < 0)
556 + return TRY_FILE_TO_BUFFER_OPEN;
558 + len = read (fd, buffer, BUFSIZ-1);
562 + return TRY_FILE_TO_BUFFER_READ;
564 + buffer [len] = '\0';
566 + return TRY_FILE_TO_BUFFER_OK;
571 +file_to_buffer(glibtop *server, char *buffer, const char *filename)
573 + switch(try_file_to_buffer(buffer, filename))
575 + case TRY_FILE_TO_BUFFER_OPEN:
576 + glibtop_error_io_r (server, "open (%s)", filename);
577 + case TRY_FILE_TO_BUFFER_READ:
578 + glibtop_error_io_r (server, "read (%s)", filename);
585 +static unsigned long
586 +read_boot_time(glibtop *server)
588 + char buffer[BUFSIZ];
591 + file_to_buffer(server, buffer, "/proc/stat");
593 + btime = strstr(buffer, "btime");
596 + glibtop_warn_io_r(server, "cannot find btime in /proc/stat");
600 + btime = skip_token(btime);
601 + return strtoul(btime, NULL, 10);
607 +get_boot_time(glibtop *server)
609 + static unsigned long boot_time = 0UL;
611 + if(G_UNLIKELY(!boot_time))
613 + boot_time = read_boot_time(server);
623 + static size_t pagesize = 0;
625 + if(G_UNLIKELY(!pagesize))
627 + pagesize = getpagesize();
636 +check_cpu_line(glibtop *server, const char *line, unsigned i)
640 + g_snprintf(start, sizeof start, "cpu%u", i);
642 + return g_str_has_prefix(line, start);
650 + static gboolean init;
651 + static gboolean sysfs;
653 + if (G_UNLIKELY(!init)) {
654 + sysfs = g_file_test("/sys", G_FILE_TEST_IS_DIR);
663 +gboolean safe_readlink(const char *path, char *buf, size_t bufsiz)
667 + ret = readlink(path, buf, bufsiz - 1);
670 + g_warning("Could not read link %s : %s", path, strerror(errno));
677 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
678 --- libgtop-2.25.91/sysdeps/solaris/glibtop_private.h 2008-05-23 22:13:24.000000000 +0000
679 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_private.h 2009-02-25 17:16:38.057019000 +0000
681 /* Reread kstat chains */
682 void glibtop_get_kstats(glibtop *);
684 +gboolean safe_readlink(const char *path, char *buf, size_t bufsiz);
688 #endif /* __GLIBTOP_PRIVATE_H__ */
689 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
690 --- libgtop-2.25.91/sysdeps/solaris/glibtop_server.h 2008-05-23 22:13:24.000000000 +0000
691 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/glibtop_server.h 2009-02-25 17:16:38.057265000 +0000
693 #define GLIBTOP_SUID_SWAP 0
694 #define GLIBTOP_SUID_UPTIME 0
695 #define GLIBTOP_SUID_LOADAVG 0
696 +#if GLIBTOP_SOLARIS_RELEASE < 51000
697 #define GLIBTOP_SUID_SHM_LIMITS (1L << GLIBTOP_SYSDEPS_SHM_LIMITS)
698 #define GLIBTOP_SUID_MSG_LIMITS (1L << GLIBTOP_SYSDEPS_MSG_LIMITS)
699 #define GLIBTOP_SUID_SEM_LIMITS (1L << GLIBTOP_SYSDEPS_SEM_LIMITS)
701 +#define GLIBTOP_SUID_SHM_LIMITS 0
702 +#define GLIBTOP_SUID_MSG_LIMITS 0
703 +#define GLIBTOP_SUID_SEM_LIMITS 0
705 #define GLIBTOP_SUID_PROCLIST 0
706 #define GLIBTOP_SUID_PROC_STATE 0
707 #define GLIBTOP_SUID_PROC_UID 0
709 #define GLIBTOP_SUID_PROC_MAP 0
710 #define GLIBTOP_SUID_NETLOAD 0
711 #define GLIBTOP_SUID_NETLIST 0
712 +#define GLIBTOP_SUID_PROC_WD 0
713 #define GLIBTOP_SUID_PPP 0
714 +#define GLIBTOP_SUID_PROC_AFFINITY 0
719 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
720 --- libgtop-2.25.91/sysdeps/solaris/msg_limits.c 2008-05-23 22:13:24.000000000 +0000
721 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/msg_limits.c 2009-02-25 17:16:38.058081000 +0000
723 (1L << GLIBTOP_IPC_MSGMNB) + (1L << GLIBTOP_IPC_MSGMNI) +
724 (1L << GLIBTOP_IPC_MSGTQL);
726 -static const unsigned long _glibtop_sysdeps_msg_limits = 0;
727 +static const unsigned long _glibtop_sysdeps_msg_limits =
728 +(1L << GLIBTOP_IPC_MSGMNB) +
729 +(1L << GLIBTOP_IPC_MSGMNI) +
730 +(1L << GLIBTOP_IPC_MSGMAX) +
731 +(1L << GLIBTOP_IPC_MSGPOOL) +
732 +(1L << GLIBTOP_IPC_MSGTQL);
738 +#if GLIBTOP_SUID_MSG_LIMITS
740 _glibtop_init_msg_limits_p (glibtop *server)
743 +_glibtop_init_msg_limits_s (glibtop *server)
746 #if GLIBTOP_SOLARIS_RELEASE < 51000
750 /* Provides information about sysv ipc limits. */
752 +#if GLIBTOP_SUID_MSG_LIMITS
754 glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
757 +glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
760 #if GLIBTOP_SOLARIS_RELEASE < 51000
762 diff -urN libgtop-2.25.91/sysdeps/solaris/netload.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/netload.c
763 --- libgtop-2.25.91/sysdeps/solaris/netload.c 2008-05-23 22:13:24.000000000 +0000
764 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/netload.c 2009-02-25 17:16:38.059013000 +0000
769 +#ifdef HAVE_IFADDRS_H
770 +/* needed for IPV6 support */
772 +#include <ifaddrs.h>
774 +#ifndef IN6_IS_ADDR_GLOBAL
775 +#define IN6_IS_ADDR_GLOBAL(a) \
776 + (((((__const uint8_t *) (a))[0] & 0xff) == 0x3f \
777 + || (((__const uint8_t *) (a))[0] & 0xff) == 0x20))
779 +#endif /* HAVE_IFADDRS_H */
781 static const unsigned long _glibtop_sysdeps_netload =
782 (1L << GLIBTOP_NETLOAD_ERRORS_IN) +
784 _glibtop_sysdeps_netload_packets;
787 +#ifdef HAVE_IFADDRS_H
789 +static void get_ipv6(glibtop *server, glibtop_netload *buf,
790 + const char *interface)
793 + * remove this code, because they are not available at Solaris, but keep them here for reference.
794 + * in fact, the function will not be called at Solaris, because HAVE_IFADDRS_H don't def.
798 + struct ifaddrs *ifa0, *ifr6;
800 + if(getifaddrs (&ifa0) != 0)
802 + glibtop_warn_r(server, "getifaddrs failed : %s", g_strerror(errno));
806 + for (ifr6 = ifa0; ifr6; ifr6 = ifr6->ifa_next) {
807 + if (strcmp (ifr6->ifa_name, interface) == 0
808 + && ifr6->ifa_addr != NULL
809 + && ifr6->ifa_addr->sa_family == AF_INET6)
813 + if(!ifr6) goto free_ipv6;
815 + memcpy(buf->address6,
816 + &((struct sockaddr_in6 *) ifr6->ifa_addr)->sin6_addr,
819 + memcpy(buf->prefix6,
820 + &((struct sockaddr_in6 *) ifr6->ifa_netmask)->sin6_addr,
824 + if (IN6_IS_ADDR_LINKLOCAL (buf->address6))
825 + buf->scope6 = GLIBTOP_IF_IN6_SCOPE_LINK;
827 + else if (IN6_IS_ADDR_SITELOCAL (buf->address6))
828 + buf->scope6 = GLIBTOP_IF_IN6_SCOPE_SITE;
830 + else if (IN6_IS_ADDR_GLOBAL (buf->address6)
831 + || IN6_IS_ADDR_MC_ORGLOCAL (buf->address6)
832 + || IN6_IS_ADDR_V4COMPAT (buf->address6)
833 + || IN6_IS_ADDR_MULTICAST (buf->address6)
834 + || IN6_IS_ADDR_UNSPECIFIED (buf->address6)
836 + buf->scope6 = GLIBTOP_IF_IN6_SCOPE_GLOBAL;
838 + else if (IN6_IS_ADDR_LOOPBACK (buf->address6))
839 + buf->scope6 = GLIBTOP_IF_IN6_SCOPE_HOST;
842 + buf->scope6 = GLIBTOP_IF_IN6_SCOPE_UNKNOWN;
844 + buf->flags |= _glibtop_sysdeps_netload_6;
851 +#endif /* HAVE_IFADDRS_H */
854 solaris_stats(glibtop *server,
855 glibtop_netload *buf,
857 buf->subnet = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr;
858 buf->flags |= (1L << GLIBTOP_NETLOAD_SUBNET);
861 +/* g_strlcpy (ifr.ifr_name, interface, sizeof ifr.ifr_name);
862 + if (!ioctl (skfd, SIOCGIFHWADDR, &ifr)) {
863 + memcpy(buf->hwaddress, &ifr.ifr_hwaddr.sa_data, 8);
864 + buf->flags |= (1L << GLIBTOP_NETLOAD_HWADDRESS);
872 solaris_stats(server, buf, interface);
874 +#ifdef HAVE_IFADDRS_H
875 + get_ipv6(server, buf, interface);
876 +#endif /* HAVE_IFADDRS_H */
878 diff -urN libgtop-2.25.91/sysdeps/solaris/procaffinity.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procaffinity.c
879 --- libgtop-2.25.91/sysdeps/solaris/procaffinity.c 1970-01-01 00:00:00.000000000 +0000
880 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procaffinity.c 2009-02-25 17:16:38.060320000 +0000
882 +/* Copyright (C) 2007 Joe Marcus Clarke <marcus@FreeBSD.org>
883 + This file is part of LibGTop 2.
885 + LibGTop is free software; you can redistribute it and/or modify it
886 + under the terms of the GNU General Public License as published by
887 + the Free Software Foundation; either version 2 of the License,
888 + or (at your option) any later version.
890 + LibGTop is distributed in the hope that it will be useful, but WITHOUT
891 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
892 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
895 + You should have received a copy of the GNU General Public License
896 + along with LibGTop; see the file COPYING. If not, write to the
897 + Free Software Foundation, Inc., 59 Temple Place - Suite 330,
898 + Boston, MA 02111-1307, USA.
902 +#include <glibtop/procaffinity.h>
903 +#include <glibtop/error.h>
905 +#include <glibtop_private.h>
907 +#include <sys/param.h>
910 +_glibtop_init_proc_affinity_s(glibtop *server)
913 + server->sysdeps.proc_affinity =
914 + (1 << GLIBTOP_PROC_AFFINITY_NUMBER) |
915 + (1 << GLIBTOP_PROC_AFFINITY_ALL);
921 +glibtop_get_proc_affinity_s(glibtop *server, glibtop_proc_affinity *buf, pid_t pid)
924 +#if __FreeBSD_version > 800024
932 + memset(buf, 0, sizeof *buf);
934 + which = CPU_WHICH_PID;
935 + level = CPU_LEVEL_WHICH;
938 + if (cpuset_getaffinity(level, which, id, sizeof(mask), &mask) != 0) {
939 + glibtop_error_r(server, "cpuset_getaffinity failed");
943 + cpus = g_array_new(FALSE, FALSE, sizeof(guint16));
945 + for (i = 0; i < MIN(CPU_SETSIZE, (size_t)(server->ncpu + 1)); i++) {
946 + if (CPU_ISSET(i, &mask)) {
948 + g_array_append_val(cpus, n);
952 + buf->number = cpus->len;
953 + buf->all = (cpus->len == (size_t)(server->ncpu + 1));
954 + buf->flags = (1 << GLIBTOP_PROC_AFFINITY_NUMBER)
955 + | (1 << GLIBTOP_PROC_AFFINITY_ALL);
957 + return (guint16*) g_array_free(cpus, FALSE);
959 + memset(buf, 0, sizeof *buf);
966 diff -urN libgtop-2.25.91/sysdeps/solaris/procmem.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procmem.c
967 --- libgtop-2.25.91/sysdeps/solaris/procmem.c 2008-05-23 22:13:24.000000000 +0000
968 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procmem.c 2009-02-25 17:16:38.061600000 +0000
972 #include <glibtop/procmem.h>
973 +#include <glibtop/procmap.h>
975 #include "glibtop_private.h"
977 static const unsigned long _glibtop_sysdeps_proc_mem =
978 (1L << GLIBTOP_PROC_MEM_SIZE) + (1L << GLIBTOP_PROC_MEM_VSIZE) +
979 -(1L << GLIBTOP_PROC_MEM_RESIDENT) + (1L << GLIBTOP_PROC_MEM_RSS);
980 +(1L << GLIBTOP_PROC_MEM_RESIDENT) + (1L << GLIBTOP_PROC_MEM_RSS) +
981 +(1L << GLIBTOP_PROC_MEM_SHARE);
986 buf->size = buf->vsize = psinfo.pr_size << pagesize << 10;
987 buf->resident = buf->rss = psinfo.pr_rssize << pagesize << 10;
989 +/* get Shared Memory */
990 + glibtop_proc_map mapbuf;
991 + glibtop_map_entry *maps;
995 + /* we have to optimize the performance of libgtop, because update the information will occupy too much cpu.
997 + here I would like to make a little update:set glibtop_proc_map.flags=1,so as to let glibtop_get_proc_map_s()
998 + only return the ones this function need: memwritable
1000 + we do the check in glibtop_get_proc_map_s(), don't run the others part which don't need by this function,
1001 + I think this will accelerate the transaction lots,
1002 + Also this will not affect the existing codes, because when nobody set glibtop_proc_map.flags,
1003 + glibtop_get_proc_map() will return all as before. zhua
1007 + maps = glibtop_get_proc_map_s(server, &mapbuf, pid);
1009 + for (i = 0; i < mapbuf.number; ++i) {
1010 + if (maps[i].perm & GLIBTOP_MAP_PERM_SHARED)
1011 + buf->share += maps[i].shared_clean;
1015 buf->flags = _glibtop_sysdeps_proc_mem;
1017 diff -urN libgtop-2.25.91/sysdeps/solaris/procstate.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procstate.c
1018 --- libgtop-2.25.91/sysdeps/solaris/procstate.c 2008-05-23 22:13:24.000000000 +0000
1019 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procstate.c 2009-02-25 17:16:38.062411000 +0000
1021 buf->gid = psinfo.pr_egid;
1022 buf->ruid = psinfo.pr_uid;
1023 buf->rgid = psinfo.pr_gid;
1024 + /* zhua: get some value here, so that we don't need run open/pread/close psinfo later,
1025 + and can delete some other call for psinfo open/pread/close. it will save lots of time*/
1026 +#ifdef HAVE_PROCFS_H
1027 + buf->nice = psinfo.pr_lwp.pr_nice - NZERO;
1029 + buf->nice = psinfo.pr_nice - NZERO;
1031 + buf->start_time = psinfo.pr_start.tv_sec;
1032 + buf->ppid = psinfo.pr_ppid;
1034 +#ifdef HAVE_PROCFS_H
1035 + buf->vsize = psinfo.pr_size << 10;
1036 + buf->resident= psinfo.pr_rssize << 10;
1037 + buf->load = (guint) psinfo.pr_lwp.pr_pctcpu * 100 / (guint) 0x8000;
1039 + buf->vsize = psinfo.pr_size << pagesize << 10;
1040 + buf->resident = psinfo.pr_rssize << pagesize << 10;
1041 + buf->load = (guint) psinfo.pr_lwp.pr_pctcpu * 100 / (guint) 0x8000;
1045 #ifdef HAVE_PROCFS_H
1046 switch(psinfo.pr_lwp.pr_state)
1047 diff -urN libgtop-2.25.91/sysdeps/solaris/proctime.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/proctime.c
1048 --- libgtop-2.25.91/sysdeps/solaris/proctime.c 2008-05-23 22:13:24.000000000 +0000
1049 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/proctime.c 2009-02-25 17:16:38.062715000 +0000
1051 glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf,
1054 +#ifdef HAVE_PROCFS_H
1055 + struct psinfo pinfo;
1057 + struct prpsinfo pinfo;
1059 struct prusage prusage;
1066 + /* zhua remove this function call, because we can change to get start_time in
1067 + glibtop_get_proc_state(), it don't need open psinfo again here */
1069 + if (glibtop_get_proc_data_psinfo_s(server, &pinfo, pid))
1071 + buf->start_time = pinfo.pr_start.tv_sec;
1073 if (glibtop_get_proc_data_usage_s (server, &prusage, pid))
1076 - g_get_current_time (&time);
1077 - /* prusage.pr_rtime.tv_sec is the during that the process existed */
1078 - buf->start_time = time.tv_sec - prusage.pr_rtime.tv_sec;
1079 +// g_get_current_time (&time);
1080 +// /* prusage.pr_rtime.tv_sec is the during that the process existed */
1081 + // buf->start_time = time.tv_sec - prusage.pr_rtime.tv_sec;
1083 - buf->rtime = prusage.pr_rtime.tv_sec * 1E+6 +
1084 - prusage.pr_rtime.tv_nsec / 1E+3;
1085 +// buf->rtime = prusage.pr_rtime.tv_sec * 1E+6 +
1086 +// prusage.pr_rtime.tv_nsec / 1E+3;
1087 buf->utime = prusage.pr_utime.tv_sec * 1E+6 +
1088 prusage.pr_utime.tv_nsec / 1E+3;
1089 buf->stime = prusage.pr_stime.tv_sec * 1E+6 +
1090 prusage.pr_stime.tv_nsec / 1E+3;
1091 + buf->rtime = (buf->utime + buf->stime) / 10000;
1094 buf->flags = _glibtop_sysdeps_proc_time;
1095 diff -urN libgtop-2.25.91/sysdeps/solaris/procwd.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procwd.c
1096 --- libgtop-2.25.91/sysdeps/solaris/procwd.c 1970-01-01 00:00:00.000000000 +0000
1097 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/procwd.c 2009-02-25 17:16:38.062977000 +0000
1099 +/* Copyright (C) 2007 Benoît Dejean
1100 + This file is part of LibGTop 2.
1102 + LibGTop is free software; you can redistribute it and/or modify it
1103 + under the terms of the GNU General Public License as published by
1104 + the Free Software Foundation; either version 2 of the License,
1105 + or (at your option) any later version.
1107 + LibGTop is distributed in the hope that it will be useful, but WITHOUT
1108 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1109 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1112 + You should have received a copy of the GNU General Public License
1113 + along with LibGTop; see the file COPYING. If not, write to the
1114 + Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1115 + Boston, MA 02111-1307, USA.
1118 +#include <config.h>
1119 +#include <glibtop/procwd.h>
1120 +#include <glibtop/error.h>
1122 +#include <glibtop_private.h>
1124 +#include <unistd.h>
1125 +#include <dirent.h>
1126 +#include <sys/types.h>
1130 +_glibtop_init_proc_wd_s(glibtop *server)
1132 + server->sysdeps.proc_wd =
1133 + (1 << GLIBTOP_PROC_WD_EXE) +
1134 + (1 << GLIBTOP_PROC_WD_ROOT) +
1135 + (1 << GLIBTOP_PROC_WD_NUMBER);
1139 +static gboolean is_in(GPtrArray *array, const char *str)
1143 + for (i = 0; i != array->len; ++i) {
1144 + if (strcmp(g_ptr_array_index(array, i), str) == 0)
1153 +glibtop_get_proc_wd_s(glibtop *server, glibtop_proc_wd *buf, pid_t pid)
1160 + glibtop_init_s(&server, GLIBTOP_SYSDEPS_PROC_WD, 0);
1162 + memset(buf, 0, sizeof(glibtop_proc_wd));
1164 + g_snprintf(path, sizeof path, "/proc/%u/root", pid);
1165 + if (safe_readlink(path, buf->root, sizeof buf->root))
1166 + buf->flags |= (1 << GLIBTOP_PROC_WD_ROOT);
1168 + g_snprintf(path, sizeof path, "/proc/%u/exe", pid);
1169 + if (safe_readlink(path, buf->exe, sizeof buf->exe))
1170 + buf->flags |= (1 << GLIBTOP_PROC_WD_EXE);
1172 + dirs = g_ptr_array_sized_new(2);
1174 + g_snprintf(path, sizeof path, "/proc/%u/cwd", pid);
1175 + if (safe_readlink(path, dir, sizeof dir))
1176 + g_ptr_array_add(dirs, g_strdup(dir));
1178 + g_snprintf(path, sizeof path, "/proc/%u/task", pid);
1179 + if ((task = opendir(path)) != NULL) {
1180 + struct dirent *sub;
1181 + while ((sub = readdir(task)) != NULL) {
1182 + g_snprintf(path, sizeof path, "/proc/%u/task/%s/cwd", pid, sub->d_name);
1183 + if (safe_readlink(path, dir, sizeof dir) && !is_in(dirs, dir))
1184 + g_ptr_array_add(dirs, g_strdup(dir));
1189 + buf->number = dirs->len;
1190 + buf->flags |= (1 << GLIBTOP_PROC_WD_NUMBER);
1192 + g_ptr_array_add(dirs, NULL);
1194 + return (char**) g_ptr_array_free(dirs, FALSE);
1197 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
1198 --- libgtop-2.25.91/sysdeps/solaris/sem_limits.c 2008-05-23 22:13:24.000000000 +0000
1199 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/sem_limits.c 2009-02-25 17:16:38.063802000 +0000
1201 (1L << GLIBTOP_IPC_SEMUSZ) + (1L << GLIBTOP_IPC_SEMVMX) +
1202 (1L << GLIBTOP_IPC_SEMAEM);
1204 -static const unsigned long _glibtop_sysdeps_sem_limits = 0;
1205 +static const unsigned long _glibtop_sysdeps_sem_limits =
1206 +(1L << GLIBTOP_IPC_SEMMNI) +
1207 +(1L << GLIBTOP_IPC_SEMMSL) +
1208 +(1L << GLIBTOP_IPC_SEMOPM);
1212 /* Init function. */
1214 +#if GLIBTOP_SUID_SEM_LIMITS
1216 _glibtop_init_sem_limits_p (glibtop *server)
1219 +_glibtop_init_sem_limits_s (glibtop *server)
1222 #if GLIBTOP_SOLARIS_RELEASE < 51000
1226 /* Provides information about sysv sem limits. */
1228 +#if GLIBTOP_SUID_SEM_LIMITS
1230 glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
1233 +glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
1236 #if GLIBTOP_SOLARIS_RELEASE < 51000
1237 kvm_t *kd = server->machine.kd;
1238 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
1239 --- libgtop-2.25.91/sysdeps/solaris/shm_limits.c 2008-05-23 22:13:24.000000000 +0000
1240 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/shm_limits.c 2009-02-25 17:16:38.064069000 +0000
1242 static const struct nlist nlst[] = { {"glibtop_shm_limits"}, {NULL} };
1244 #if GLIBTOP_SOLARIS_RELEASE >=51000
1245 -static const unsigned long _glibtop_sysdeps_shm_limits = 0;
1246 +static const unsigned long _glibtop_sysdeps_shm_limits =
1247 +(1L << GLIBTOP_IPC_SHMMAX) +
1248 +(1L << GLIBTOP_IPC_SHMMIN);
1250 # if GLIBTOP_SOLARIS_RELEASE < 50900
1251 static const unsigned long _glibtop_sysdeps_shm_limits =
1254 /* Init function. */
1256 +#if GLIBTOP_SUID_SHM_LIMITS
1258 _glibtop_init_shm_limits_p (glibtop *server)
1261 +_glibtop_init_shm_limits_s (glibtop *server)
1264 #if GLIBTOP_SOLARIS_RELEASE < 51000
1268 /* Provides information about sysv ipc limits. */
1270 +#if GLIBTOP_SUID_SHM_LIMITS
1272 glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
1275 +glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
1278 #if GLIBTOP_SOLARIS_RELEASE < 51000
1280 diff -urN libgtop-2.25.91/sysdeps/solaris/siglist.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/siglist.c
1281 --- libgtop-2.25.91/sysdeps/solaris/siglist.c 2008-05-23 22:13:24.000000000 +0000
1282 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/siglist.c 2009-02-25 17:16:38.064867000 +0000
1284 { 35, "SIGTHAW", "Checkpoint Thaw" },
1285 { 36, "SIGCANCEL","Thread Cancelation" },
1286 { 37, "SIGLOST", "Resource Lost" },
1287 +#if GLIBTOP_SOLARIS_RELEASE < 50900 /* S8 */
1288 { 38, "SIGRTMIN","First Realtime Signal" },
1289 { 39, "SIGRTMIN+1", "Second Realtime Signal" },
1290 { 40, "SIGRTMIN+2", "Third Realtime Signal" },
1292 { 43, "SIGRTMAX-2", "Third Last Realtime Signal" },
1293 { 44, "SIGRTMAX-1", "Second Last Realtime Signal" },
1294 { 45, "SIGRTMAX", "Last Realtime Signal" },
1296 +#if GLIBTOP_SOLARIS_RELEASE >= 50900
1297 + { 38, "SIGXRES","Resource Control Exceeded" },
1298 +#if GLIBTOP_SOLARIS_RELEASE <51000 /* signal here existed in s9 */
1299 + { 39, "SIGRTMIN","First Realtime Signal" },
1300 + { 40, "SIGRTMIN+1", "Second Realtime Signal" },
1301 + { 41, "SIGRTMIN+2", "Third Realtime Signal" },
1302 + { 42, "SIGRTMIN+3", "Fourth Realtime Signal" },
1303 + { 43, "SIGRTMAX-3", "Fourth Last Realtime Signal" },
1304 + { 44, "SIGRTMAX-2", "Third Last Realtime Signal" },
1305 + { 45, "SIGRTMAX-1", "Second Last Realtime Signal" },
1306 + { 46, "SIGRTMAX", "Last Realtime Signal" },
1307 +#else /* signal here existed in s10 and s11 */
1308 + { 39, "SIGJVM1","Reserved signal for Java Virtual Machine" },
1309 + { 40, "SIGJVM1","Reserved signal for Java Virtual Machine" },
1310 + { 41, "SIGRTMIN","First Realtime Signal" },
1311 + { 42, "SIGRTMIN+1", "Second Realtime Signal" },
1312 + { 43, "SIGRTMIN+2", "Third Realtime Signal" },
1313 + { 44, "SIGRTMIN+3", "Fourth Realtime Signal" },
1314 + { 45, "SIGRTMAX-3", "Fourth Last Realtime Signal" },
1315 + { 46, "SIGRTMAX-2", "Third Last Realtime Signal" },
1316 + { 47, "SIGRTMAX-1", "Second Last Realtime Signal" },
1317 + { 48, "SIGRTMAX", "Last Realtime Signal" },
1322 diff -urN libgtop-2.25.91/sysdeps/solaris/sysinfo.c ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/sysinfo.c
1323 --- libgtop-2.25.91/sysdeps/solaris/sysinfo.c 1970-01-01 00:00:00.000000000 +0000
1324 +++ ../SUNWlibgtop-2.25.91.hacked/libgtop-2.25.91/sysdeps/solaris/sysinfo.c 2009-02-25 17:16:38.065095000 +0000
1326 +/* $Id: sysinfo.c,v 1.22 2004/11/28 01:32:55 bdejean Exp $ */
1328 +/* Copyright (C) 1998-99 Martin Baulig
1329 + This file is part of LibGTop 1.0.
1331 + Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
1333 + LibGTop is free software; you can redistribute it and/or modify it
1334 + under the terms of the GNU General Public License as published by
1335 + the Free Software Foundation; either version 2 of the License,
1336 + or (at your option) any later version.
1338 + LibGTop is distributed in the hope that it will be useful, but WITHOUT
1339 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1340 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1343 + You should have received a copy of the GNU General Public License
1344 + along with LibGTop; see the file COPYING. If not, write to the
1345 + Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1346 + Boston, MA 02111-1307, USA.
1349 +#include <config.h>
1350 +#include <glibtop/error.h>
1351 +#include <glibtop/cpu.h>
1352 +#include <glibtop/sysinfo.h>
1354 +#include "glibtop_private.h"
1357 +static const unsigned long _glibtop_sysdeps_sysinfo =
1358 +(1L << GLIBTOP_SYSINFO_CPUINFO);
1360 +static glibtop_sysinfo sysinfo = { .flags = 0 };
1363 +init_sysinfo (glibtop *server)
1368 +const glibtop_sysinfo *
1369 +glibtop_get_sysinfo_s (glibtop *server)
1371 + init_sysinfo (server);
1374 --- a/sysdeps/solaris/open.c 2017-10-27 23:27:47.201639710 -0700
1375 +++ b/sysdeps/solaris/open.c 2017-10-27 23:29:13.969490610 -0700
1376 @@ -209,34 +209,34 @@
1380 - /* Now let's have a bit of magic dust... */
1381 +// /* Now let's have a bit of magic dust... */
1383 -#if GLIBTOP_SOLARIS_RELEASE >= 50600
1385 - dl = dlopen("/usr/lib/libproc.so", RTLD_LAZY);
1386 - if(server->machine->libproc)
1387 - dlclose(server->machine->libproc);
1388 - server->machine->libproc = dl;
1393 - func = dlsym(dl, "Pobjname"); /* Solaris 8 */
1395 - func = dlsym(dl, "proc_objname"); /* Solaris 7 */
1396 - server->machine->objname = (void (*)
1397 - (void *, uintptr_t, const char *, size_t))func;
1398 - server->machine->pgrab = (struct ps_prochandle *(*)(pid_t, int, int *))
1399 - dlsym(dl, "Pgrab");
1400 - server->machine->pfree = (void (*)(void *))dlsym(dl, "Pfree");
1405 - server->machine->objname = NULL;
1406 - server->machine->pgrab = NULL;
1407 - server->machine->pfree = NULL;
1410 +//#if GLIBTOP_SOLARIS_RELEASE >= 50600
1412 +// dl = dlopen("/usr/lib/libproc.so", RTLD_LAZY);
1413 +// if(server->machine->libproc)
1414 +// dlclose(server->machine->libproc);
1415 +// server->machine->libproc = dl;
1420 +// func = dlsym(dl, "Pobjname"); /* Solaris 8 */
1422 +// func = dlsym(dl, "proc_objname"); /* Solaris 7 */
1423 +// server->machine->objname = (void (*)
1424 +// (void *, uintptr_t, const char *, size_t))func;
1425 +// server->machine->pgrab = (struct ps_prochandle *(*)(pid_t, int, int *))
1426 +// dlsym(dl, "Pgrab");
1427 +// server->machine->pfree = (void (*)(void *))dlsym(dl, "Pfree");
1432 +// server->machine->objname = NULL;
1433 +// server->machine->pgrab = NULL;
1434 +// server->machine->pfree = NULL;
1437 server->machine->me = getpid();
1439 --- a/glibtop.h 2017-10-27 20:32:08.852858820 -0700
1440 +++ b/glibtop.h 2017-10-27 20:32:18.170926960 -0700
1442 #include <glibtop/global.h>
1444 #include <glibtop_server.h>
1445 +#include <glibtop_machine.h>
1447 #ifndef GLIBTOP_MOUNTENTRY_LEN
1448 #define GLIBTOP_MOUNTENTRY_LEN 79
1449 --- a/sysdeps/solaris/procmap.c 2017-10-26 16:14:15.708456884 -0700
1450 +++ b/sysdeps/solaris/procmap.c 2017-10-26 16:14:36.424701783 -0700
1452 glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
1454 int fd, i, nmaps, pr_err, heap;
1456 + char filename [BUFSIZ];
1457 + /* use flags as a check condition, if it is 1, check, or, not check... zhua */
1458 + int check = buf->flags;
1459 + /* set flags back to 0 */
1462 #if GLIBTOP_SOLARIS_RELEASE >= 50600
1464 - struct ps_prochandle *Pr = NULL;
1465 +// struct ps_prochandle *Pr = NULL;
1469 @@ -123,16 +130,44 @@
1470 buf->total = nmaps * sizeof(glibtop_map_entry);
1471 entry = g_malloc0(buf->total);
1473 -#if GLIBTOP_SOLARIS_RELEASE >= 50600
1474 +//#if GLIBTOP_SOLARIS_RELEASE >= 50600
1476 - if(server->machine->objname && server->machine->pgrab &&
1477 - server->machine->pfree)
1478 - Pr = (server->machine->pgrab)(pid, 1, &pr_err);
1480 +// if(server->machine.objname && server->machine.pgrab &&
1481 +// server->machine.pfree)
1482 +// Pr = (server->machine.pgrab)(pid, 1, &pr_err);
1484 for(heap = 0,i = 0; i < nmaps; ++i)
1488 + /* take a check to see if we need all information, if not, just get what we need..
1489 + Also please see comments in get_process_memory_writable() of gnome-system-monitor zhua */
1492 + if(maps[i].pr_mflags & MA_WRITE){
1493 + entry[i].perm |= GLIBTOP_MAP_PERM_WRITE;
1494 + entry[i].size = maps[i].pr_size;
1496 + if(maps[i].pr_mflags & MA_SHARED){
1497 + entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
1498 + /* here use shared_clean to store Shared Memory */
1499 + entry[i].shared_clean = maps[i].pr_size;
1505 + if(maps[i].pr_mflags & MA_SHARED){
1506 + entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
1507 + /* here use shared_clean to store Shared Memory */
1508 + entry[i].shared_clean = maps[i].pr_size;
1516 entry[i].start = maps[i].pr_vaddr;
1517 entry[i].end = maps[i].pr_vaddr + maps[i].pr_size;
1519 @@ -177,25 +212,40 @@
1520 entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
1525 - server->machine->objname(Pr, maps[i].pr_vaddr, buffer,
1527 - if((len = resolvepath(buffer, entry[i].filename,
1528 - GLIBTOP_MAP_FILENAME_LEN)) > 0)
1530 - entry[i].filename[len] = 0;
1531 - entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
1536 +// server->machine.objname(Pr, maps[i].pr_vaddr, buffer,
1538 +// if((len = resolvepath(buffer, entry[i].filename,
1539 +// GLIBTOP_MAP_FILENAME_LEN)) > 0)
1541 +// entry[i].filename[len] = 0;
1542 +// entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
1546 + g_strlcpy(buffer, maps[i].pr_mapname, sizeof buffer);
1547 + /* from /path get file name */
1548 + g_snprintf(filename, sizeof filename, "/proc/%d/path/%s",
1551 + rv = readlink(filename, entry[i].filename, sizeof(entry[i].filename) - 1);
1552 + /* read object, if have not, set it as NULL */
1555 + entry[i].filename[rv] = '\0';
1556 + /* now set the flags */
1557 + entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
1563 -#if GLIBTOP_SOLARIS_RELEASE >= 50600
1564 +//#if GLIBTOP_SOLARIS_RELEASE >= 50600
1567 - server->machine->pfree(Pr);
1570 +// server->machine.pfree(Pr);
1572 buf->flags = _glibtop_sysdeps_proc_map;