8402N/A running kernel (if there are no configured kernel sources). */
8402N/A #undef GLIBTOP_LINUX_VERSION_CODE
8402N/A-/* Solaris release code (eg. 251 for Solaris 2.5.1). */
8402N/A+/* Solaris release code (eg. 20501 for Solaris 2.5.1). */
8402N/A #undef GLIBTOP_SOLARIS_RELEASE
8402N/A /* Define the location where the catalogs will be installed */
8402N/A@@ -164,6 +164,15 @@ dnl AIX
8402N/A AC_CHECK_LIB(perfstat, vmgetinfo,
8402N/A AC_DEFINE(HAVE_VMGETINFO, 1,
8402N/A [Define to 1 if you have the 'vmgetinfo' function in libperfstat]))
8402N/A+dnl Solaris msgfmt does not support the -c option so blank it.
8402N/A@@ -171,9 +180,10 @@ case "$host_os" in
8402N/A AC_CHECK_LIB(kstat, kstat_open)
8402N/A AC_CHECK_FUNCS(getloadavg swapctl)
8402N/A dnl Some versions of Solaris require -lelf for -lkvm
8402N/A+ solaris[[8-9]] | solaris2.[[0-9]].*)
8402N/A AC_CHECK_LIB(kvm, kvm_open,[
8402N/A ],[AC_MSG_CHECKING(for kvm_open in -lkvm with -lelf)
8402N/A@@ -192,6 +202,8 @@ case "$host_os" in
8402N/A-void glibtop_error_vr (glibtop *server, const char *format, va_list args) G_GNUC_INTERNAL G_GNUC_NORETURN;
8402N/A-void glibtop_warn_vr (glibtop *server, const char *format, va_list args) G_GNUC_INTERNAL;
8402N/A-void glibtop_error_io_vr (glibtop *server, const char *format, int, va_list args) G_GNUC_INTERNAL G_GNUC_NORETURN;
8402N/A-void glibtop_warn_io_vr (glibtop *server, const char *format, int, va_list args) G_GNUC_INTERNAL;
8402N/A-void glibtop_error_r (glibtop *server, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3) G_GNUC_NORETURN;
8402N/A-void glibtop_warn_r (glibtop *server, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3);
8402N/A-void glibtop_error_io_r (glibtop *server, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3) G_GNUC_NORETURN;
8402N/A-void glibtop_warn_io_r (glibtop *server, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3);
8402N/A-void glibtop_error (const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(1, 2) G_GNUC_NORETURN;
8402N/A-void glibtop_warn (const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(1, 2);
8402N/A-void glibtop_error_io (const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(1, 2) G_GNUC_NORETURN;
8402N/A-void glibtop_warn_io (const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(1, 2);
8402N/A+G_GNUC_INTERNAL void glibtop_error_vr (glibtop *server, const char *format, va_list args) G_GNUC_NORETURN;
8402N/A+G_GNUC_INTERNAL void glibtop_warn_vr (glibtop *server, const char *format, va_list args) ;
8402N/A+G_GNUC_INTERNAL void glibtop_error_io_vr (glibtop *server, const char *format, int, va_list args) G_GNUC_NORETURN;
8402N/A+G_GNUC_INTERNAL void glibtop_warn_io_vr (glibtop *server, const char *format, int, va_list args) ;
8402N/A+G_GNUC_INTERNAL void glibtop_error_r (glibtop *server, const char *format, ...) G_GNUC_PRINTF(2, 3) G_GNUC_NORETURN;
8402N/A+G_GNUC_INTERNAL void glibtop_warn_r (glibtop *server, const char *format, ...) G_GNUC_PRINTF(2, 3);
8402N/A+G_GNUC_INTERNAL void glibtop_error_io_r (glibtop *server, const char *format, ...) G_GNUC_PRINTF(2, 3) G_GNUC_NORETURN;
8402N/A+G_GNUC_INTERNAL void glibtop_warn_io_r (glibtop *server, const char *format, ...) G_GNUC_PRINTF(2, 3);
8402N/A+G_GNUC_INTERNAL void glibtop_error (const char *format, ...) G_GNUC_PRINTF(1, 2) G_GNUC_NORETURN;
8402N/A+G_GNUC_INTERNAL void glibtop_warn (const char *format, ...) G_GNUC_PRINTF(1, 2);
8402N/A+G_GNUC_INTERNAL void glibtop_error_io (const char *format, ...) G_GNUC_PRINTF(1, 2) G_GNUC_NORETURN;
8402N/A+G_GNUC_INTERNAL void glibtop_warn_io (const char *format, ...) G_GNUC_PRINTF(1, 2);
8402N/A@@ -60,6 +60,7 @@ G_BEGIN_DECLS
8402N/A #define GLIBTOP_MAP_PERM_EXECUTE 4
8402N/A #define GLIBTOP_MAP_PERM_SHARED 8
8402N/A #define GLIBTOP_MAP_PERM_PRIVATE 16
8402N/A+#define GLIBTOP_MAP_PERM_SHAREDMEMORY 32
8402N/A typedef struct _glibtop_map_entry glibtop_map_entry;
8402N/A@@ -53,6 +53,7 @@ struct _glibtop_proc_mem
8402N/A rss, /* resident set size */
8402N/A rss_rlim; /* current limit (in bytes) of the rss
8402N/A * of the process; usually 2,147,483,647 */
8402N/A+ guint load; /* cpu load for process */
8402N/A void glibtop_get_proc_mem(glibtop_proc_mem *buf, pid_t pid);
8402N/A@@ -255,16 +255,16 @@ main (void)
8402N/A AC_MSG_RESULT($os_version_code)
8402N/A- os_major_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]\)\.*\([[0-9]]*\)/\1/'`
8402N/A- os_minor_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]\)\.*\([[0-9]]*\)/\2/'`
8402N/A- os_micro_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]\)\.*\([[0-9]]*\)/\3/'`
8402N/A+ os_major_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]*\)\.*\([[0-9]]*\)/\1/'`
8402N/A+ os_minor_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]*\)\.*\([[0-9]]*\)/\2/'`
8402N/A+ os_micro_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]*\)\.*\([[0-9]]*\)/\3/'`
8402N/A test -z "$os_micro_version" && os_micro_version=0
8402N/A- os_version_expr="$os_major_version 100 * $os_minor_version 10 * + $os_micro_version + p q"
8402N/A+ os_version_expr="$os_major_version 10000 * $os_minor_version 100 * + $os_micro_version + p q"
8402N/A os_version_code=`echo "$os_version_expr" | dc`
8402N/A AC_MSG_CHECKING(for Solaris release code)
8402N/A AC_DEFINE_UNQUOTED(GLIBTOP_SOLARIS_RELEASE, $os_version_code,
8402N/A- [Solaris release code (eg. 251 for Solaris 2.5.1).])
8402N/A+ [Solaris release code (eg. 20501 for Solaris 2.5.1).])
8402N/A AC_MSG_RESULT($os_version_code)
8402N/A@@ -39,6 +39,7 @@ MKINSTALLDIRS = $(top_srcdir)/@MKINSTALL
8402N/A+GMSGFMT_CHECKOPT = @GMSGFMT_CHECKOPT@
8402N/A@@ -78,7 +79,7 @@ INSTOBJEXT = @INSTOBJEXT@
8402N/A file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \
8402N/A- && rm -f $$file && $(GMSGFMT) -c -o $$file $<
8402N/A+ && rm -f $$file && $(GMSGFMT) -o $(GMSGFMT_CHECKOPT) $$file $<
8402N/A@@ -59,17 +59,17 @@ G_BEGIN_DECLS
8402N/A #define MSG_BUFSZ sizeof (struct _glibtop_ipc_message)
8402N/A #define MSG_MSGSZ (MSG_BUFSZ - sizeof (long))
8402N/A-void handle_parent_connection (int s) G_GNUC_INTERNAL;
8402N/A-void handle_slave_connection (int input, int output) G_GNUC_INTERNAL;
8402N/A-void handle_slave_command (glibtop_command *cmnd, glibtop_response *resp,
8402N/A- const void *parameter) G_GNUC_INTERNAL ;
8402N/A-void do_output (int s, glibtop_response *resp, off_t offset,
8402N/A- size_t data_size, const void *data) G_GNUC_INTERNAL;
8402N/A-int do_read (int s, void *ptr, size_t total_size) G_GNUC_INTERNAL;
8402N/A+G_GNUC_INTERNAL void handle_parent_connection (int s) ;
8402N/A+G_GNUC_INTERNAL void handle_slave_connection (int input, int output) ;
8402N/A+G_GNUC_INTERNAL void handle_slave_command (glibtop_command *cmnd, glibtop_response *resp,
8402N/A+G_GNUC_INTERNAL void do_output (int s, glibtop_response *resp, off_t offset,
8402N/A+ size_t data_size, const void *data) ;
8402N/A+G_GNUC_INTERNAL int do_read (int s, void *ptr, size_t total_size) ;
8402N/A-void syslog_message (int priority, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3);
8402N/A-void syslog_io_message (int priority, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3);
8402N/A+G_GNUC_INTERNAL void syslog_message (int priority, const char *format, ...) G_GNUC_PRINTF(2, 3);
8402N/A+G_GNUC_INTERNAL void syslog_io_message (int priority, const char *format, ...) G_GNUC_PRINTF(2, 3);
8402N/A@@ -126,10 +126,10 @@ static const unsigned long _glibtop_sysd
8402N/A _glibtop_linux_get_fsusage_read_write(glibtop *server,
8402N/A- const char *path) G_GNUC_INTERNAL;
8402N/A _glibtop_get_fsusage_read_write(glibtop *server,
8402N/A@@ -141,7 +141,7 @@ _glibtop_get_fsusage_read_write(glibtop
8402N/A _glibtop_freebsd_get_fsusage_read_write(glibtop *server,
8402N/A@@ -475,8 +475,10 @@ read_filesystem_list (void)
8402N/A@@ -610,7 +612,7 @@ glibtop_get_mountlist_s (glibtop *server
8402N/A buf->total = buf->number * buf->size;
8402N/A buf->flags = (1 << GLIBTOP_MOUNTLIST_SIZE)
8402N/A- | (1 << GLIBTOP_MOUNTLIST_SIZE)
8402N/A+ | (1 << GLIBTOP_MOUNTLIST_NUMBER)
8402N/A | (1 << GLIBTOP_MOUNTLIST_TOTAL);
8402N/A return (glibtop_mountentry*) g_array_free(mount_array, FALSE);
8402N/A libgtop_sysdeps_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
8402N/A@@ -36,6 +36,7 @@ static const unsigned long _glibtop_sysd
8402N/A static const unsigned long _glibtop_sysdeps_cpu_all =
8402N/A (1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
8402N/A (1L << GLIBTOP_CPU_SYS) + (1L << GLIBTOP_CPU_IDLE) +
8402N/A (1L << GLIBTOP_XCPU_TOTAL) + (1L << GLIBTOP_XCPU_USER) +
8402N/A (1L << GLIBTOP_XCPU_SYS) + (1L << GLIBTOP_XCPU_IDLE) +
8402N/A@@ -63,14 +63,8 @@ struct _glibtop_machine
8402N/A int pagesize; /* in bits to shift, ie. 2^pagesize gives Kb */
8402N/A int ticks; /* clock ticks, as returned by sysconf() */
8402N/A unsigned long long boot; /* boot time, although it's ui32 in kstat */
8402N/A- void *libproc; /* libproc handle */
8402N/A-#if GLIBTOP_SOLARIS_RELEASE >= 560
8402N/A- void (*objname)(void *, uintptr_t, const char *, size_t);
8402N/A- struct ps_prochandle *(*pgrab)(pid_t, int, int *);
8402N/A-static const struct nlist nlst[] = { {"msginfo"}, {NULL} };
8402N/A+static const struct nlist nlst[] = { {"glibtop_msg_limits"}, {NULL} };
8402N/A+#if GLIBTOP_SOLARIS_RELEASE < 51000
8402N/A static const unsigned long _glibtop_sysdeps_msg_limits =
8402N/A-#if GLIBTOP_SOLARIS_RELEASE <= 570
8402N/A+#if GLIBTOP_SOLARIS_RELEASE <= 50700
8402N/A (1L << GLIBTOP_IPC_MSGMAP) + (1L << GLIBTOP_IPC_MSGSSZ) +
8402N/A (1L << GLIBTOP_IPC_MSGPOOL) + (1L << GLIBTOP_IPC_MSGMAX) +
8402N/A (1L << GLIBTOP_IPC_MSGMNB) + (1L << GLIBTOP_IPC_MSGMNI) +
8402N/A (1L << GLIBTOP_IPC_MSGTQL);
8402N/A+static const unsigned long _glibtop_sysdeps_msg_limits = 0;
8402N/A glibtop_init_msg_limits_p (glibtop *server)
8402N/A+#if GLIBTOP_SOLARIS_RELEASE < 51000
8402N/A if(kd && !kvm_nlist(kd, nlst))
8402N/A /* Provides information about sysv ipc limits. */
8402N/A@@ -55,18 +64,22 @@ glibtop_init_msg_limits_p (glibtop *serv
8402N/A glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
8402N/A+#if GLIBTOP_SOLARIS_RELEASE < 51000
8402N/A memset (buf, 0, sizeof (glibtop_msg_limits));
8402N/A if(kvm_read(kd, nlst[0].n_value, (void *)&minfo,
8402N/A- sizeof(struct msginfo)) != sizeof(struct msginfo))
8402N/A+ sizeof(glibtop_msg_limits)) != sizeof(glibtop_msg_limits))
8402N/A-#if GLIBTOP_SOLARIS_RELEASE <= 570
8402N/A+#if GLIBTOP_SOLARIS_RELEASE <= 50700
8402N/A /* These fields don't exist anymore in Solaris 8.
8402N/A * Thanks to Laszlo PETER <Laszlo.Peter@ireland.sun.com>. */
8402N/A@@ -76,6 +89,33 @@ glibtop_get_msg_limits_p (glibtop *serve
8402N/A- buf->flags = _glibtop_sysdeps_msg_limits;
8402N/A+#if GLIBTOP_SOLARIS_RELEASE >= 51000
8402N/A+ if ((rblk = malloc(rctlblk_size())) == NULL)
8402N/A+ buf->msgmnb = rctlblk_get_value(rblk);
8402N/A+ buf->msgmni = rctlblk_get_value(rblk);
8402N/A+ buf->msgtql = rctlblk_get_value(rblk);
8402N/A+ /* this is the maximum size of a system V message, which has been obsoleted as a kernel tunable value now */
8402N/A+ /* and it should always be 65535 instead, so I list it here, if needed, can be removed */
8402N/A+ buf->msgpool = buf->msgmni * buf->msgmnb >> 10;
8402N/A+ buf->flags = _glibtop_sysdeps_msg_limits;
8402N/A@@ -50,13 +50,19 @@ glibtop_get_netlist_s (glibtop *server,
8402N/A devices = g_ptr_array_new();
8402N/A+ glibtop_warn_io_r (server, "kstat_open ()");
8402N/A for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next)
8402N/A if (strcmp(ksp->ks_class, "net") != 0)
8402N/A g_ptr_array_add(devices, g_strdup(ksp->ks_name));
8402N/A-static const unsigned long _glibtop_sysdeps_netload = 0;
8402N/A+//#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
8402N/A+/* needed for IPV6 support */
8402N/A+#define IN6_IS_ADDR_GLOBAL(a) \
8402N/A+ (((((__const uint8_t *) (a))[0] & 0xff) == 0x3f \
8402N/A+ || (((__const uint8_t *) (a))[0] & 0xff) == 0x20))
8402N/A+#endif /* HAVE_IFADDRS_H */
8402N/A+static const unsigned long _glibtop_sysdeps_netload =
8402N/A+(1L << GLIBTOP_NETLOAD_ERRORS_IN) +
8402N/A+(1L << GLIBTOP_NETLOAD_ERRORS_OUT) +
8402N/A+(1L << GLIBTOP_NETLOAD_COLLISIONS);
8402N/A+static const unsigned long _glibtop_sysdeps_netload_data =
8402N/A+(1L << GLIBTOP_NETLOAD_ADDRESS) +
8402N/A+(1L << GLIBTOP_NETLOAD_SUBNET) +
8402N/A+(1L << GLIBTOP_NETLOAD_MTU);
8402N/A+static const unsigned long _glibtop_sysdeps_netload_bytes =
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_IN) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_OUT) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL);
8402N/A+static const unsigned long _glibtop_sysdeps_netload_packets =
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_IN) +
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_OUT) +
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL);
8402N/A+static const unsigned long _glibtop_sysdeps_netload_total =
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL);
8402N/A+static const unsigned long _glibtop_sysdeps_netload_in =
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) +
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_IN) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_IN);
8402N/A+static const unsigned long _glibtop_sysdeps_netload_out =
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) +
8402N/A+(1L << GLIBTOP_NETLOAD_PACKETS_OUT) +
8402N/A+(1L << GLIBTOP_NETLOAD_BYTES_OUT);
8402N/A+static const unsigned long _glibtop_sysdeps_netload_6 =
8402N/A+(1L << GLIBTOP_NETLOAD_ADDRESS6) +
8402N/A+(1L << GLIBTOP_NETLOAD_PREFIX6) +
8402N/A+(1L << GLIBTOP_NETLOAD_SCOPE6);
8402N/A glibtop_init_netload_s (glibtop *server)
8402N/A+ _glibtop_sysdeps_netload_bytes |
8402N/A+ _glibtop_sysdeps_netload_packets;
8402N/A+static void get_ipv6(glibtop *server, glibtop_netload *buf,
8402N/A+ struct ifaddrs *ifa0, *ifr6;
8402N/A+ if(getifaddrs (&ifa0) != 0)
8402N/A+ glibtop_warn_r(server, "getifaddrs failed : %s", g_strerror(errno));
8402N/A+ for (ifr6 = ifa0; ifr6; ifr6 = ifr6->ifa_next) {
8402N/A+ if (strcmp (ifr6->ifa_name, interface) == 0
8402N/A+ && ifr6->ifa_addr->sa_family == AF_INET6)
8402N/A+ &((struct sockaddr_in6 *) ifr6->ifa_addr)->sin6_addr,
8402N/A+ &((struct sockaddr_in6 *) ifr6->ifa_netmask)->sin6_addr,
8402N/A+ if (IN6_IS_ADDR_LINKLOCAL (buf->address6))
8402N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_LINK;
8402N/A+ else if (IN6_IS_ADDR_SITELOCAL (buf->address6))
8402N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_SITE;
8402N/A+ else if (IN6_IS_ADDR_GLOBAL (buf->address6)
8402N/A+ || IN6_IS_ADDR_MC_ORGLOCAL (buf->address6)
8402N/A+ || IN6_IS_ADDR_V4COMPAT (buf->address6)
8402N/A+ || IN6_IS_ADDR_MULTICAST (buf->address6)
8402N/A+ || IN6_IS_ADDR_UNSPECIFIED (buf->address6)
8402N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_GLOBAL;
8402N/A+ else if (IN6_IS_ADDR_LOOPBACK (buf->address6))
8402N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_HOST;
8402N/A+ buf->scope6 = GLIBTOP_IF_IN6_SCOPE_UNKNOWN;
8402N/A+ buf->flags |= _glibtop_sysdeps_netload_6;
8402N/A+#endif /* HAVE_IFADDRS_H */
8402N/A+solaris_stats(glibtop *server,
8402N/A+ * chop off the trailing interface and
8402N/A+ ptr = module + strlen( module ) - 1;
8402N/A+ while( (ptr > module) && isdigit( (int) *ptr ) ) {
8402N/A+ * get a kstat handle and update the user's kstat chain
8402N/A+ if( (kctl = kstat_open()) == NULL ){
8402N/A+ glibtop_warn_io_r (server, "kstat_open ()");
8402N/A+ while( kstat_chain_update( kctl ) != 0 )
8402N/A+ * traverse the kstat chain
8402N/A+ * to find the appropriate statistics
8402N/A+ if( (ksp = kstat_lookup( kctl,
8402N/A+ module, 0, name )) == NULL ) {
8402N/A+ if( kstat_read( kctl, ksp, NULL ) == -1 ) {
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "ipackets" );
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "opackets" );
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "rbytes" );
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "obytes" );
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "ierrors" );
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "oerrors" );
8402N/A+ kdata = (kstat_named_t *) kstat_data_lookup( ksp, "collisions" );
8402N/A+ /* Compute total valules. */
8402N/A+ buf->bytes_total = buf->bytes_in + buf->bytes_out;
8402N/A+ buf->packets_total = buf->packets_in + buf->packets_out;
8402N/A+ buf->errors_total = buf->errors_in + buf->errors_out;
8402N/A+ buf->flags |= _glibtop_sysdeps_netload;
8402N/A+ buf->flags |= _glibtop_sysdeps_netload_bytes;
8402N/A+ buf->flags |= _glibtop_sysdeps_netload_packets;
8402N/A /* Provides network statistics. */
8402N/A glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
8402N/A- memset (buf, 0, sizeof (glibtop_netload));
8402N/A+ memset (buf, 0, sizeof (glibtop_netload));
8402N/A+ skfd = socket (PF_INET, SOCK_DGRAM, 0);
8402N/A+ if (ioctl (skfd, SIOCGIFFLAGS, &ifr) >= 0) {
8402N/A+ buf->flags |= (1L << GLIBTOP_NETLOAD_IF_FLAGS);
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_UP);
8402N/A+ if (flags & IFF_BROADCAST)
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_BROADCAST);
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_DEBUG);
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_LOOPBACK);
8402N/A+ if (flags & IFF_POINTOPOINT)
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_POINTOPOINT);
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_RUNNING);
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_NOARP);
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_PROMISC);
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_ALLMULTI);
8402N/A+ if (flags & IFF_MULTICAST)
8402N/A+ buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_MULTICAST);
8402N/A+ if (!ioctl (skfd, SIOCGIFADDR, &ifr)) {
8402N/A+ buf->flags |= (1L << GLIBTOP_NETLOAD_ADDRESS);
8402N/A+ if (!ioctl (skfd, SIOCGIFNETMASK, &ifr)) {
8402N/A+ buf->flags |= (1L << GLIBTOP_NETLOAD_SUBNET);
8402N/A+ solaris_stats(server, buf, interface);
8402N/A+ get_ipv6(server, buf, interface);
8402N/A+#endif /* HAVE_IFADDRS_H */
8402N/A@@ -83,7 +83,8 @@ glibtop_get_kstats(glibtop *server)
8402N/A for(i = 0, checked = 0; i < GLIBTOP_NCPU || checked == new_ncpu; ++i)
8402N/A sprintf(cpu, "cpu_stat%d", i);
8402N/A@@ -145,6 +146,8 @@ glibtop_open_s (glibtop *server, const c
8402N/A for(i = 0; page; ++i, page >>= 1);
8402N/A@@ -208,31 +211,5 @@ glibtop_open_s (glibtop *server, const c
8402N/A- /* Now let's have a bit of magic dust... */
8402N/A-#if GLIBTOP_SOLARIS_RELEASE >= 560
8402N/A- func = dlsym(dl, "Pobjname"); /* Solaris 8 */
8402N/A- func = dlsym(dl, "proc_objname"); /* Solaris 7 */
8402N/A- (void *, uintptr_t, const char *, size_t))func;
8402N/A@@ -69,9 +69,13 @@ glibtop_open_p (glibtop *server, const c
8402N/A+#if GLIBTOP_SOLARIS_RELEASE < 51000
8402N/A glibtop_warn_io_r(server, "kvm_open()");
8402N/A /* Drop priviledges; we only become root when necessary.
8402N/A@@ -56,7 +56,8 @@ glibtop_map_entry *
8402N/A glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
8402N/A int fd, i, nmaps, pr_err, heap;
8402N/A-#if GLIBTOP_SOLARIS_RELEASE >= 560
8402N/A+#if GLIBTOP_SOLARIS_RELEASE >= 50600
8402N/A struct ps_prochandle *Pr = NULL;
8402N/A@@ -84,7 +85,7 @@ glibtop_get_proc_map_s (glibtop *server,
8402N/A if((fd = s_open(buffer, O_RDONLY)) < 0)
8402N/A- if(errno != EPERM && errno != EACCES)
8402N/A+ if (errno != EPERM && errno != EACCES)
8402N/A glibtop_warn_io_r(server, "open (%s)", buffer);
8402N/A@@ -125,20 +126,14 @@ glibtop_get_proc_map_s (glibtop *server,
8402N/A buf->total = nmaps * sizeof(glibtop_map_entry);
8402N/A entry = g_malloc0(buf->total);
8402N/A-#if GLIBTOP_SOLARIS_RELEASE >= 560
8402N/A for(heap = 0,i = 0; i < nmaps; ++i)
8402N/A entry[i].start = maps[i].pr_vaddr;
8402N/A entry[i].end = maps[i].pr_vaddr + maps[i].pr_size;
8402N/A-#if GLIBTOP_SOLARIS_RELEASE >= 560
8402N/A+#if GLIBTOP_SOLARIS_RELEASE >= 50600
8402N/A if(maps[i].pr_dev != PRNODEV)
8402N/A@@ -150,17 +145,23 @@ glibtop_get_proc_map_s (glibtop *server,
8402N/A entry[i].offset = maps[i].OFFSET;
8402N/A if(maps[i].pr_mflags & MA_READ)
8402N/A entry[i].perm |= GLIBTOP_MAP_PERM_READ;
8402N/A- if(maps[i].pr_mflags & MA_WRITE)
8402N/A+ if(maps[i].pr_mflags & MA_WRITE){
8402N/A entry[i].perm |= GLIBTOP_MAP_PERM_WRITE;
8402N/A+ entry[i].size = maps[i].pr_size;
8402N/A if(maps[i].pr_mflags & MA_EXEC)
8402N/A entry[i].perm |= GLIBTOP_MAP_PERM_EXECUTE;
8402N/A if(maps[i].pr_mflags & MA_SHARED)
8402N/A entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
8402N/A+ if(maps[i].pr_mflags & (MA_SHM|MA_ISM)){
8402N/A+ entry[i].perm |= GLIBTOP_MAP_PERM_SHAREDMEMORY;
8402N/A+ entry[i].shared_clean = maps[i].pr_size; /* here use shared_clean to store Shared Memory */
8402N/A entry[i].perm |= GLIBTOP_MAP_PERM_PRIVATE;
8402N/A entry[i].flags = _glibtop_sysdeps_map_entry;
8402N/A-#if GLIBTOP_SOLARIS_RELEASE >= 560
8402N/A+#if GLIBTOP_SOLARIS_RELEASE >= 50600
8402N/A if(maps[i].pr_mflags & MA_ANON)
8402N/A@@ -177,25 +178,24 @@ glibtop_get_proc_map_s (glibtop *server,
8402N/A entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
8402N/A- if((len = resolvepath(buffer, entry[i].filename,
8402N/A- GLIBTOP_MAP_FILENAME_LEN)) > 0)
8402N/A- entry[i].filename[len] = 0;
8402N/A- entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
8402N/A+ strcpy(buffer, maps[i].pr_mapname);
8402N/A+ /* from /path get file name */
8402N/A+ g_snprintf(filename, sizeof filename, "/proc/%
d/path/%s",
8402N/A+ rv = readlink(filename, entry[i].filename, sizeof(entry[i].filename) - 1);
8402N/A+ /* read object, if have not, set it as NULL */
8402N/A+ entry[i].filename[rv] = '\0';
8402N/A+ entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
8402N/A-#if GLIBTOP_SOLARIS_RELEASE >= 560
8402N/A buf->flags = _glibtop_sysdeps_proc_map;
8402N/A@@ -59,9 +60,25 @@ glibtop_get_proc_mem_s (glibtop *server,
8402N/A+ maps = glibtop_get_proc_map_s(server, &mapbuf, pid);
8402N/A+ if (maps[i].perm & GLIBTOP_MAP_PERM_SHAREDMEMORY)
8402N/A+ buf->share += maps[i].shared_clean;
8402N/A buf->flags = _glibtop_sysdeps_proc_mem;
8402N/A+/* Copyright (C) 2006 Henry Zhang
8402N/A+ This file is part of LibGTop 2.14.
8402N/A+ Contributed by Henry Zhang <hua.zhang@sun.com>, July 2006.
8402N/A+ LibGTop is free software; you can redistribute it
and/or modify it
8402N/A+ under the terms of the GNU General Public License as published by
8402N/A+ the Free Software Foundation; either version 2 of the License,
8402N/A+ or (at your option) any later version.
8402N/A+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
8402N/A+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8402N/A+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8402N/A+ You should have received a copy of the GNU General Public License
8402N/A+ along with LibGTop; see the file COPYING. If not, write to the
8402N/A+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
8402N/A+ Boston, MA 02111-1307, USA.
8402N/A+static const unsigned long _glibtop_sysdeps_proc_open_files =
8402N/A+(1L << GLIBTOP_PROC_OPEN_FILES_NUMBER)|
8402N/A+(1L << GLIBTOP_PROC_OPEN_FILES_TOTAL)|
8402N/A+(1L << GLIBTOP_PROC_OPEN_FILES_SIZE);
8402N/A+glibtop_init_proc_open_files_s (glibtop *server)
8402N/A+/* Provides detailed information about a process' open files */
8402N/A+glibtop_get_proc_open_files_s (glibtop *server, glibtop_proc_open_files *buf, pid_t pid)
8402N/A+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_OPEN_FILES, 0);
8402N/A+ memset (buf, 0, sizeof (glibtop_proc_open_files));
8402N/A+ entries = g_array_new(FALSE, FALSE, sizeof(glibtop_open_files_entry));
8402N/A+ while((direntry = readdir(dir))) {
8402N/A+ glibtop_open_files_entry entry = {0};
8402N/A+ if(direntry->d_name[0] == '.')
8402N/A+ /* at /path, there are some dir which are not fd, so need to skip them */
8402N/A+ /* Clear error for atoi return */
8402N/A+ /* from /path get object name */
8402N/A+ g_snprintf(filename, sizeof filename, "/proc/%
d/path/%s",
8402N/A+ rv = readlink(filename, tgt, sizeof(tgt) - 1);
8402N/A+ /* read object, if not have, set it as NULL, but this fd still need to insert into the array */
8402N/A+ /* from /fd get the stat data */
8402N/A+ g_snprintf(filename, sizeof filename, "/proc/%
d/fd/%s",
8402N/A+ if(stat (filename, &statbuf))
8402N/A+ case S_IFSOCK: /* socket */
8402N/A+ /* at solaris, now a little difficult to tell the Socket type, so here I
8402N/A+ give the type 0, it will not impact the existed code. Later will provide
8402N/A+ a patch to tell the type, and get the object name */
8402N/A+ g_array_append_val(entries, entry);
8402N/A+ buf->flags = _glibtop_sysdeps_proc_open_files;
8402N/A+ buf->number = entries->len;
8402N/A+ buf->size = sizeof(glibtop_open_files_entry);
8402N/A+ buf->total = buf->number * buf->size;
8402N/A+ return (glibtop_open_files_entry*)g_array_free(entries, FALSE);
8402N/A@@ -46,6 +46,7 @@ glibtop_get_proc_time_s (glibtop *server
8402N/A memset (buf, 0, sizeof (glibtop_proc_time));
8402N/A@@ -56,7 +57,9 @@ glibtop_get_proc_time_s (glibtop *server
8402N/A if (glibtop_get_proc_data_usage_s (server, &prusage, pid))
8402N/A+ g_get_current_time (&time);
8402N/A-static const struct nlist nlst[] = { {"seminfo"}, {NULL} };
8402N/A+static const struct nlist nlst[] = { {"glibtop_sem_limits"}, {NULL} };
8402N/A+#if GLIBTOP_SOLARIS_RELEASE < 51000
8402N/A static const unsigned long _glibtop_sysdeps_sem_limits =
8402N/A-#if GLIBTOP_SOLARIS_RELEASE <= 570
8402N/A+#if GLIBTOP_SOLARIS_RELEASE <= 50700
8402N/A (1L << GLIBTOP_IPC_SEMMAP) +
8402N/A (1L << GLIBTOP_IPC_SEMMNI) + (1L << GLIBTOP_IPC_SEMMNS) +
8402N/A@@ -38,18 +40,25 @@ static const unsigned long _glibtop_sysd
8402N/A (1L << GLIBTOP_IPC_SEMOPM) + (1L << GLIBTOP_IPC_SEMUME) +
8402N/A (1L << GLIBTOP_IPC_SEMUSZ) + (1L << GLIBTOP_IPC_SEMVMX) +
8402N/A (1L << GLIBTOP_IPC_SEMAEM);
8402N/A+static const unsigned long _glibtop_sysdeps_sem_limits = 0;
8402N/A glibtop_init_sem_limits_p (glibtop *server)
8402N/A+#if GLIBTOP_SOLARIS_RELEASE < 51000
8402N/A if(kd && !kvm_nlist(kd, nlst))
8402N/A /* Provides information about sysv sem limits. */
8402N/A@@ -57,18 +66,20 @@ glibtop_init_sem_limits_p (glibtop *serv
8402N/A glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
8402N/A+#if GLIBTOP_SOLARIS_RELEASE < 51000
8402N/A memset (buf, 0, sizeof (glibtop_sem_limits));
8402N/A if(kvm_read(kd, nlst[0].n_value, (void *)&sinfo,
8402N/A- sizeof(struct seminfo)) != sizeof(struct seminfo))
8402N/A+ sizeof(glibtop_sem_limits)) != sizeof(glibtop_sem_limits))
8402N/A-#if GLIBTOP_SOLARIS_RELEASE <= 570
8402N/A+#if GLIBTOP_SOLARIS_RELEASE <= 50700
8402N/A /* This field don't exist anymore in Solaris 8.
8402N/A * Thanks to Laszlo PETER <Laszlo.Peter@ireland.sun.com>. */
8402N/A@@ -82,5 +93,30 @@ glibtop_get_sem_limits_p (glibtop *serve
8402N/A- buf->flags = _glibtop_sysdeps_sem_limits;
8402N/A+#if GLIBTOP_SOLARIS_RELEASE >= 51000
8402N/A+ if ((rblk = malloc(rctlblk_size())) == NULL)
8402N/A+ buf->semopm = rctlblk_get_value(rblk);
8402N/A+ buf->semmsl = rctlblk_get_value(rblk);
8402N/A+ buf->semmni = rctlblk_get_value(rblk);
8402N/A+ /* there are only 3 fields, the remaining ones have been obsoleted in S10
8402N/A+ and no longer have system-wide limits */
8402N/A+ buf->flags = _glibtop_sysdeps_sem_limits;
8402N/A-static const struct nlist nlst[] = { {"shminfo"}, {NULL} };
8402N/A+static const struct nlist nlst[] = { {"glibtop_shm_limits"}, {NULL} };
8402N/A-#if GLIBTOP_SOLARIS_RELEASE < 590
8402N/A+#if GLIBTOP_SOLARIS_RELEASE >=51000
8402N/A+static const unsigned long _glibtop_sysdeps_shm_limits = 0;
8402N/A+# if GLIBTOP_SOLARIS_RELEASE < 50900
8402N/A static const unsigned long _glibtop_sysdeps_shm_limits =
8402N/A (1L << GLIBTOP_IPC_SHMMAX) + (1L << GLIBTOP_IPC_SHMMIN);
8402N/A static const unsigned long _glibtop_sysdeps_shm_limits =
8402N/A (1L << GLIBTOP_IPC_SHMMAX) + (1L << GLIBTOP_IPC_SHMMIN) +
8402N/A (1L << GLIBTOP_IPC_SHMMNI) + (1L << GLIBTOP_IPC_SHMSEG);
8402N/A@@ -45,12 +50,15 @@ static const unsigned long _glibtop_sysd
8402N/A glibtop_init_shm_limits_p (glibtop *server)
8402N/A+#if GLIBTOP_SOLARIS_RELEASE < 51000
8402N/A if(kd && !kvm_nlist(kd, nlst))
8402N/A /* Provides information about sysv ipc limits. */
8402N/A@@ -58,8 +66,11 @@ glibtop_init_shm_limits_p (glibtop *serv
8402N/A glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
8402N/A+#if GLIBTOP_SOLARIS_RELEASE < 51000
8402N/A memset (buf, 0, sizeof (glibtop_shm_limits));
8402N/A@@ -67,14 +78,32 @@ glibtop_get_shm_limits_p (glibtop *serve
8402N/A if(kvm_read(kd, nlst[0].n_value, (void *)&sinfo,
8402N/A- sizeof(struct shminfo)) != sizeof(struct shminfo))
8402N/A+ sizeof(glibtop_shm_limits)) != sizeof(glibtop_shm_limits))
8402N/A-#if GLIBTOP_SOLARIS_RELEASE < 590
8402N/A+#if GLIBTOP_SOLARIS_RELEASE < 50900
8402N/A+#if GLIBTOP_SOLARIS_RELEASE >= 51000
8402N/A+ if ((rblk = malloc(rctlblk_size())) == NULL)
8402N/A+ buf->shmmax = rctlblk_get_value(rblk);
8402N/A+ buf->shmmni = rctlblk_get_value(rblk);
8402N/A buf->flags = _glibtop_sysdeps_shm_limits;
8402N/A@@ -31,6 +31,7 @@ const glibtop_signame glibtop_sys_siglis
8402N/A { 4, "SIGILL", "Illegal Instruction" },
8402N/A+ { 6, "SIGIOT", "IOT instruction" }, /* S8 also introduced */
8402N/A { 7, "SIGEMT", "Emulation Trap" },
8402N/A { 8, "SIGFPE", "Arithmetic Exception" },
8402N/A@@ -43,6 +44,7 @@ const glibtop_signame glibtop_sys_siglis
8402N/A { 15, "SIGTERM", "Terminated" },
8402N/A { 16, "SIGUSR1", "User Signal 1" },
8402N/A { 17, "SIGUSR2", "User Signal 2" },
8402N/A+ { 18, "SIGCLD", "Child Status Changed" },/* S8 also introduced */
8402N/A { 18, "SIGCHLD", "Child Status Changed" },
8402N/A { 20, "SIGWINCH","Window Size Change" },
8402N/A@@ -63,6 +65,7 @@ const glibtop_signame glibtop_sys_siglis
8402N/A { 35, "SIGTHAW", "Checkpoint Thaw" },
8402N/A { 36, "SIGCANCEL","Thread Cancelation" },
8402N/A { 37, "SIGLOST", "Resource Lost" },
8402N/A+#if GLIBTOP_SOLARIS_RELEASE < 50900 /* S8 */
8402N/A { 38, "SIGRTMIN","First Realtime Signal" },
8402N/A { 39, "SIGRTMIN+1", "Second Realtime Signal" },
8402N/A { 40, "SIGRTMIN+2", "Third Realtime Signal" },
8402N/A@@ -71,5 +74,30 @@ const glibtop_signame glibtop_sys_siglis
8402N/A { 43, "SIGRTMAX-2", "Third Last Realtime Signal" },
8402N/A { 44, "SIGRTMAX-1", "Second Last Realtime Signal" },
8402N/A { 45, "SIGRTMAX", "Last Realtime Signal" },
8402N/A+#if GLIBTOP_SOLARIS_RELEASE >= 50900
8402N/A+ { 38, "SIGXRES","Resource Control Exceeded" },
8402N/A+#if GLIBTOP_SOLARIS_RELEASE <51000 /* signal here existed in s9 */
8402N/A+ { 39, "SIGRTMIN","First Realtime Signal" },
8402N/A+ { 40, "SIGRTMIN+1", "Second Realtime Signal" },
8402N/A+ { 41, "SIGRTMIN+2", "Third Realtime Signal" },
8402N/A+ { 42, "SIGRTMIN+3", "Fourth Realtime Signal" },
8402N/A+ { 43, "SIGRTMAX-3", "Fourth Last Realtime Signal" },
8402N/A+ { 44, "SIGRTMAX-2", "Third Last Realtime Signal" },
8402N/A+ { 45, "SIGRTMAX-1", "Second Last Realtime Signal" },
8402N/A+ { 46, "SIGRTMAX", "Last Realtime Signal" },
8402N/A+#else /* signal here existed in s10 and s11 */
8402N/A+ { 39, "SIGJVM1","Reserved signal for Java Virtual Machine" },
8402N/A+ { 40, "SIGJVM1","Reserved signal for Java Virtual Machine" },
8402N/A+ { 41, "SIGRTMIN","First Realtime Signal" },
8402N/A+ { 42, "SIGRTMIN+1", "Second Realtime Signal" },
8402N/A+ { 43, "SIGRTMIN+2", "Third Realtime Signal" },
8402N/A+ { 44, "SIGRTMIN+3", "Fourth Realtime Signal" },
8402N/A+ { 45, "SIGRTMAX-3", "Fourth Last Realtime Signal" },
8402N/A+ { 46, "SIGRTMAX-2", "Third Last Realtime Signal" },
8402N/A+ { 47, "SIGRTMAX-1", "Second Last Realtime Signal" },
8402N/A+ { 48, "SIGRTMAX", "Last Realtime Signal" },
8402N/A+/* Copyright (C) 1998-99 Martin Baulig
8402N/A+ This file is part of LibGTop 1.0.
8402N/A+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
8402N/A+ LibGTop is free software; you can redistribute it
and/or modify it
8402N/A+ under the terms of the GNU General Public License as published by
8402N/A+ the Free Software Foundation; either version 2 of the License,
8402N/A+ or (at your option) any later version.
8402N/A+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
8402N/A+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8402N/A+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8402N/A+ You should have received a copy of the GNU General Public License
8402N/A+ along with LibGTop; see the file COPYING. If not, write to the
8402N/A+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
8402N/A+ Boston, MA 02111-1307, USA.
8402N/A+static const unsigned long _glibtop_sysdeps_sysinfo =
8402N/A+(1L << GLIBTOP_SYSINFO_CPUINFO);
8402N/A+static glibtop_sysinfo sysinfo = { .flags = 0 };
8402N/A+init_sysinfo (glibtop *server)
8402N/A+glibtop_get_sysinfo_s (glibtop *server)