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