whitespace clean up.
* *.{c,h} : whitespace clean up.
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2004-06-09 Benoît Dejean <TazForEver@dlfp.org>
|
||||||
|
|
||||||
|
* *.{c,h} : whitespace clean up.
|
||||||
|
|
||||||
2004-06-07 Benoît Dejean <tazforever@dlfp.org>
|
2004-06-07 Benoît Dejean <tazforever@dlfp.org>
|
||||||
|
|
||||||
* lib/parameter.c:
|
* lib/parameter.c:
|
||||||
|
@@ -57,7 +57,7 @@ glibtop_call_i (glibtop_server *server, backend_server_private *priv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmnd.data_size = data_size;
|
cmnd.data_size = data_size;
|
||||||
|
|
||||||
glibtop_write_i (priv, sizeof (glibtop_command), &cmnd);
|
glibtop_write_i (priv, sizeof (glibtop_command), &cmnd);
|
||||||
|
|
||||||
if (data_size) {
|
if (data_size) {
|
||||||
@@ -75,7 +75,7 @@ glibtop_call_i (glibtop_server *server, backend_server_private *priv,
|
|||||||
(long) resp.recv_size, (long) resp.data_size,
|
(long) resp.recv_size, (long) resp.data_size,
|
||||||
recv_ptr, (long) recv_size);
|
recv_ptr, (long) recv_size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (retval_ptr)
|
if (retval_ptr)
|
||||||
*retval_ptr = resp.glibtop_errno;
|
*retval_ptr = resp.glibtop_errno;
|
||||||
|
|
||||||
|
@@ -45,10 +45,10 @@ glibtop_read_data_i (backend_server_private *priv)
|
|||||||
fprintf (stderr, "LIBRARY: really reading %d data bytes (ret = %d).\n", size, ret);
|
fprintf (stderr, "LIBRARY: really reading %d data bytes (ret = %d).\n", size, ret);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!size) return NULL;
|
if (!size) return NULL;
|
||||||
|
|
||||||
ptr = g_malloc (size);
|
ptr = g_malloc (size);
|
||||||
|
|
||||||
ret = read (priv->input [0], ptr, size);
|
ret = read (priv->input [0], ptr, size);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@@ -86,7 +86,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
server = glibtop_global_server;
|
server = glibtop_global_server;
|
||||||
|
|
||||||
if (!server->_priv)
|
if (!server->_priv)
|
||||||
server->_priv = g_malloc (sizeof (glibtop_server_private));
|
server->_priv = g_malloc (sizeof (glibtop_server_private));
|
||||||
|
|
||||||
@@ -185,5 +185,5 @@ handle_slave_connection (int input, int output)
|
|||||||
resp.data_size = recv_data_size;
|
resp.data_size = recv_data_size;
|
||||||
|
|
||||||
do_output (output, &resp, recv_ptr, recv_data_ptr);
|
do_output (output, &resp, recv_ptr, recv_data_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ glibtop_send_version_i (glibtop *server, int fd)
|
|||||||
sizeof (glibtop_response),
|
sizeof (glibtop_response),
|
||||||
sizeof (glibtop_union),
|
sizeof (glibtop_union),
|
||||||
sizeof (glibtop_sysdeps));
|
sizeof (glibtop_sysdeps));
|
||||||
|
|
||||||
size = strlen (buffer) + 1;
|
size = strlen (buffer) + 1;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@@ -60,7 +60,7 @@ _open_sysdeps (glibtop_server *server, glibtop_backend *backend,
|
|||||||
(*init_fkt) (server);
|
(*init_fkt) (server);
|
||||||
|
|
||||||
server->info->sysdeps.pointer_size = sizeof (void*)*8;
|
server->info->sysdeps.pointer_size = sizeof (void*)*8;
|
||||||
|
|
||||||
server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
|
server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -55,7 +55,7 @@ main (int argc, char *argv [])
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
||||||
textdomain (GETTEXT_PACKAGE);
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
||||||
|
|
||||||
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
||||||
@@ -135,7 +135,7 @@ main (int argc, char *argv [])
|
|||||||
|
|
||||||
for (c = 0; c < PROFILE_COUNT; c++)
|
for (c = 0; c < PROFILE_COUNT; c++)
|
||||||
glibtop_get_shm_limits (&data.shm_limits);
|
glibtop_get_shm_limits (&data.shm_limits);
|
||||||
|
|
||||||
printf ("Shm Limits (0x%08lx): %lu, %lu, %lu, %lu, %lu\n",
|
printf ("Shm Limits (0x%08lx): %lu, %lu, %lu, %lu, %lu\n",
|
||||||
(unsigned long) data.shm_limits.flags,
|
(unsigned long) data.shm_limits.flags,
|
||||||
(unsigned long) data.shm_limits.shmmax,
|
(unsigned long) data.shm_limits.shmmax,
|
||||||
@@ -159,7 +159,7 @@ main (int argc, char *argv [])
|
|||||||
|
|
||||||
for (c = 0; c < PROFILE_COUNT; c++)
|
for (c = 0; c < PROFILE_COUNT; c++)
|
||||||
glibtop_get_sem_limits (&data.sem_limits);
|
glibtop_get_sem_limits (&data.sem_limits);
|
||||||
|
|
||||||
printf ("Sem Limits (0x%08lx): "
|
printf ("Sem Limits (0x%08lx): "
|
||||||
"%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n",
|
"%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n",
|
||||||
(unsigned long) data.sem_limits.flags,
|
(unsigned long) data.sem_limits.flags,
|
||||||
@@ -217,7 +217,7 @@ main (int argc, char *argv [])
|
|||||||
(unsigned long) sysdeps.ppp);
|
(unsigned long) sysdeps.ppp);
|
||||||
|
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
|
|
||||||
ptr = glibtop_get_proclist (&data.proclist, 0, 0);
|
ptr = glibtop_get_proclist (&data.proclist, 0, 0);
|
||||||
|
|
||||||
printf ("Proclist (0x%08lx): %lu, %lu, %lu\n",
|
printf ("Proclist (0x%08lx): %lu, %lu, %lu\n",
|
||||||
@@ -308,7 +308,7 @@ main (int argc, char *argv [])
|
|||||||
|
|
||||||
for (c = 0; c < PROFILE_COUNT; c++)
|
for (c = 0; c < PROFILE_COUNT; c++)
|
||||||
glibtop_get_proc_signal (&data.proc_signal, pid);
|
glibtop_get_proc_signal (&data.proc_signal, pid);
|
||||||
|
|
||||||
printf ("Proc_Signal PID %5d (0x%08lx): "
|
printf ("Proc_Signal PID %5d (0x%08lx): "
|
||||||
"%lu %lu %lu %lu\n", (int) pid,
|
"%lu %lu %lu %lu\n", (int) pid,
|
||||||
(unsigned long) data.proc_signal.flags,
|
(unsigned long) data.proc_signal.flags,
|
||||||
|
@@ -50,11 +50,11 @@ main (int argc, char *argv [])
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
||||||
textdomain (GETTEXT_PACKAGE);
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
||||||
|
|
||||||
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
||||||
|
|
||||||
printf ("Method = %d\n", method);
|
printf ("Method = %d\n", method);
|
||||||
|
|
||||||
count = glibtop_get_parameter (GLIBTOP_PARAM_COMMAND, buffer, BUFSIZ);
|
count = glibtop_get_parameter (GLIBTOP_PARAM_COMMAND, buffer, BUFSIZ);
|
||||||
|
@@ -54,7 +54,7 @@ main (int argc, char *argv [])
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
||||||
textdomain (GETTEXT_PACKAGE);
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
||||||
|
|
||||||
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
||||||
@@ -77,7 +77,7 @@ main (int argc, char *argv [])
|
|||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
glibtop_error ("Usage: %s interface", argv [0]);
|
glibtop_error ("Usage: %s interface", argv [0]);
|
||||||
|
|
||||||
glibtop_get_netload (&netload, argv [1]);
|
glibtop_get_netload (&netload, argv [1]);
|
||||||
|
|
||||||
addr.s_addr = netload.address;
|
addr.s_addr = netload.address;
|
||||||
|
@@ -61,7 +61,7 @@ main (int argc, char *argv [])
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
||||||
textdomain (GETTEXT_PACKAGE);
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
||||||
|
|
||||||
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
||||||
@@ -97,7 +97,7 @@ main (int argc, char *argv [])
|
|||||||
const char *filename = NULL;
|
const char *filename = NULL;
|
||||||
unsigned device, device_major, device_minor;
|
unsigned device, device_major, device_minor;
|
||||||
char perm [5];
|
char perm [5];
|
||||||
|
|
||||||
if (maps [i].flags & (1L << GLIBTOP_MAP_ENTRY_FILENAME))
|
if (maps [i].flags & (1L << GLIBTOP_MAP_ENTRY_FILENAME))
|
||||||
filename = maps [i].filename;
|
filename = maps [i].filename;
|
||||||
|
|
||||||
|
@@ -50,7 +50,7 @@ output (pid_t pid)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
|
|
||||||
glibtop_get_proc_state (&data.proc_state, pid);
|
glibtop_get_proc_state (&data.proc_state, pid);
|
||||||
|
|
||||||
printf ("Proc_State PID %5d (0x%08lx): "
|
printf ("Proc_State PID %5d (0x%08lx): "
|
||||||
@@ -59,9 +59,9 @@ output (pid_t pid)
|
|||||||
data.proc_state.cmd, data.proc_state.state,
|
data.proc_state.cmd, data.proc_state.state,
|
||||||
(unsigned long) data.proc_state.uid,
|
(unsigned long) data.proc_state.uid,
|
||||||
(unsigned long) data.proc_state.gid);
|
(unsigned long) data.proc_state.gid);
|
||||||
|
|
||||||
glibtop_get_proc_uid (&data.proc_uid, pid);
|
glibtop_get_proc_uid (&data.proc_uid, pid);
|
||||||
|
|
||||||
printf ("Proc_Uid PID %5d (0x%08lx): "
|
printf ("Proc_Uid PID %5d (0x%08lx): "
|
||||||
"%d %d %d %d %d %d %d %d %d %d %d %d\n", (int) pid,
|
"%d %d %d %d %d %d %d %d %d %d %d %d\n", (int) pid,
|
||||||
(unsigned long) data.proc_uid.flags,
|
(unsigned long) data.proc_uid.flags,
|
||||||
@@ -73,7 +73,7 @@ output (pid_t pid)
|
|||||||
data.proc_uid.priority, data.proc_uid.nice);
|
data.proc_uid.priority, data.proc_uid.nice);
|
||||||
|
|
||||||
glibtop_get_proc_mem (&data.proc_mem, pid);
|
glibtop_get_proc_mem (&data.proc_mem, pid);
|
||||||
|
|
||||||
printf ("Proc_Mem PID %5d (0x%08lx): "
|
printf ("Proc_Mem PID %5d (0x%08lx): "
|
||||||
"%lu %lu %lu %lu %lu %lu\n", (int) pid,
|
"%lu %lu %lu %lu %lu %lu\n", (int) pid,
|
||||||
(unsigned long) data.proc_mem.flags,
|
(unsigned long) data.proc_mem.flags,
|
||||||
@@ -83,7 +83,7 @@ output (pid_t pid)
|
|||||||
(unsigned long) data.proc_mem.share,
|
(unsigned long) data.proc_mem.share,
|
||||||
(unsigned long) data.proc_mem.rss,
|
(unsigned long) data.proc_mem.rss,
|
||||||
(unsigned long) data.proc_mem.rss_rlim);
|
(unsigned long) data.proc_mem.rss_rlim);
|
||||||
|
|
||||||
glibtop_get_proc_segment (&data.proc_segment, pid);
|
glibtop_get_proc_segment (&data.proc_segment, pid);
|
||||||
|
|
||||||
printf ("Proc_Segment PID %5d (0x%08lx): "
|
printf ("Proc_Segment PID %5d (0x%08lx): "
|
||||||
@@ -99,7 +99,7 @@ output (pid_t pid)
|
|||||||
(unsigned long) data.proc_segment.start_stack);
|
(unsigned long) data.proc_segment.start_stack);
|
||||||
|
|
||||||
glibtop_get_proc_time (&data.proc_time, pid);
|
glibtop_get_proc_time (&data.proc_time, pid);
|
||||||
|
|
||||||
printf ("Proc_Time PID %5d (0x%08lx): "
|
printf ("Proc_Time PID %5d (0x%08lx): "
|
||||||
"%lu %lu %lu %lu %lu %lu %lu %lu %lu\n", (int) pid,
|
"%lu %lu %lu %lu %lu %lu %lu %lu %lu\n", (int) pid,
|
||||||
(unsigned long) data.proc_time.flags,
|
(unsigned long) data.proc_time.flags,
|
||||||
@@ -114,7 +114,7 @@ output (pid_t pid)
|
|||||||
(unsigned long) data.proc_time.frequency);
|
(unsigned long) data.proc_time.frequency);
|
||||||
|
|
||||||
glibtop_get_proc_signal (&data.proc_signal, pid);
|
glibtop_get_proc_signal (&data.proc_signal, pid);
|
||||||
|
|
||||||
printf ("Proc_Signal PID %5d (0x%08lx): "
|
printf ("Proc_Signal PID %5d (0x%08lx): "
|
||||||
"%lu %lu %lu %lu\n", (int) pid,
|
"%lu %lu %lu %lu\n", (int) pid,
|
||||||
(unsigned long) data.proc_signal.flags,
|
(unsigned long) data.proc_signal.flags,
|
||||||
@@ -160,7 +160,7 @@ output (pid_t pid)
|
|||||||
ncpu = glibtop_global_server->ncpu;
|
ncpu = glibtop_global_server->ncpu;
|
||||||
|
|
||||||
glibtop_get_proc_time (&data.proc_time, pid);
|
glibtop_get_proc_time (&data.proc_time, pid);
|
||||||
|
|
||||||
total = (unsigned long) data.proc_time.utime +
|
total = (unsigned long) data.proc_time.utime +
|
||||||
(unsigned long) data.proc_time.stime;
|
(unsigned long) data.proc_time.stime;
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ main (int argc, char *argv [])
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
||||||
textdomain (GETTEXT_PACKAGE);
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
glibtop_init ();
|
glibtop_init ();
|
||||||
|
|
||||||
glibtop_get_sysdeps (&sysdeps);
|
glibtop_get_sysdeps (&sysdeps);
|
||||||
@@ -288,7 +288,7 @@ main (int argc, char *argv [])
|
|||||||
for (i = 0; i < proclist.number; i++) {
|
for (i = 0; i < proclist.number; i++) {
|
||||||
|
|
||||||
pid = ptr [i];
|
pid = ptr [i];
|
||||||
|
|
||||||
output (pid);
|
output (pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ main (int argc, char *argv [])
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
||||||
textdomain (GETTEXT_PACKAGE);
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
glibtop_init();
|
glibtop_init();
|
||||||
|
|
||||||
glibtop_get_cpu (&cpu);
|
glibtop_get_cpu (&cpu);
|
||||||
@@ -102,7 +102,7 @@ main (int argc, char *argv [])
|
|||||||
printf ("%-26s %12s %12s %12s %12s %12s\n%s\n", _("Percent:"),
|
printf ("%-26s %12s %12s %12s %12s %12s\n%s\n", _("Percent:"),
|
||||||
_("Total (%)"), _("User (%)"), _("Nice (%)"), _("Sys (%)"),
|
_("Total (%)"), _("User (%)"), _("Nice (%)"), _("Sys (%)"),
|
||||||
_("Idle (%)"), separator);
|
_("Idle (%)"), separator);
|
||||||
|
|
||||||
printf (_("CPU (0x%08lx): %12.3f %12.3f %12.3f %12.3f %12.3f\n\n"),
|
printf (_("CPU (0x%08lx): %12.3f %12.3f %12.3f %12.3f %12.3f\n\n"),
|
||||||
(unsigned long) cpu.flags, (double) total * 100.0 / total,
|
(unsigned long) cpu.flags, (double) total * 100.0 / total,
|
||||||
(double) user * 100.0 / total,
|
(double) user * 100.0 / total,
|
||||||
|
@@ -48,7 +48,7 @@ main (int argc, char *argv [])
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
|
||||||
textdomain (GETTEXT_PACKAGE);
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
||||||
|
|
||||||
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
|
|
||||||
#include <glibtop/open.h>
|
#include <glibtop/open.h>
|
||||||
#include <glibtop/close.h>
|
#include <glibtop/close.h>
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
void main_prog(int argc, char *argv[]);
|
void main_prog(int argc, char *argv[]);
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
|
@@ -87,7 +87,7 @@ main (int argc, char *argv [])
|
|||||||
"Feature", "Flags", "Count", "utime", "stime");
|
"Feature", "Flags", "Count", "utime", "stime");
|
||||||
printf ("-------------------------------------------"
|
printf ("-------------------------------------------"
|
||||||
"---------------\n");
|
"---------------\n");
|
||||||
|
|
||||||
glibtop_init_r (&glibtop_global_server, 0, 0);
|
glibtop_init_r (&glibtop_global_server, 0, 0);
|
||||||
|
|
||||||
getrusage (RUSAGE_SELF, &total_start);
|
getrusage (RUSAGE_SELF, &total_start);
|
||||||
@@ -303,7 +303,7 @@ main (int argc, char *argv [])
|
|||||||
|
|
||||||
for (c = 0; c < PROFILE_COUNT; c++)
|
for (c = 0; c < PROFILE_COUNT; c++)
|
||||||
glibtop_get_proc_signal (&data.proc_signal, pid);
|
glibtop_get_proc_signal (&data.proc_signal, pid);
|
||||||
|
|
||||||
getrusage (RUSAGE_SELF, &rusage_end);
|
getrusage (RUSAGE_SELF, &rusage_end);
|
||||||
|
|
||||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||||
@@ -334,7 +334,7 @@ main (int argc, char *argv [])
|
|||||||
(unsigned long) data.proc_kernel.flags, PROFILE_COUNT,
|
(unsigned long) data.proc_kernel.flags, PROFILE_COUNT,
|
||||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||||
|
|
||||||
getrusage (RUSAGE_SELF, &total_end);
|
getrusage (RUSAGE_SELF, &total_end);
|
||||||
|
|
||||||
libgtop_timersub (&total_end.ru_utime, &total_start.ru_utime,
|
libgtop_timersub (&total_end.ru_utime, &total_start.ru_utime,
|
||||||
|
@@ -9,15 +9,15 @@
|
|||||||
|
|
||||||
Copyright (C) 1989 Free Software Foundation, Inc.
|
Copyright (C) 1989 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Author: Andy Norman (ange@hplb.hpl.hp.com), based on
|
Author: Andy Norman (ange@hplb.hpl.hp.com), based on
|
||||||
'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
|
'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
|
||||||
Emacs distribution.
|
Emacs distribution.
|
||||||
|
|
||||||
Please mail bugs and suggestions to the author at the above address.
|
Please mail bugs and suggestions to the author at the above address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* HISTORY
|
/* HISTORY
|
||||||
* 11-Nov-1990 bristor@simba
|
* 11-Nov-1990 bristor@simba
|
||||||
* Added EOT stuff.
|
* Added EOT stuff.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define MCOOKIE_SCREEN "42980" /* screen # to use as the gnuserv cookie */
|
#define MCOOKIE_SCREEN "42980" /* screen # to use as the gnuserv cookie */
|
||||||
#endif
|
#endif
|
||||||
#define MCOOKIE_NAME "MAGIC-1" /* authentication protocol name */
|
#define MCOOKIE_NAME "MAGIC-1" /* authentication protocol name */
|
||||||
#define MCOOKIE_X_NAME "MIT-MAGIC-COOKIE-1" /* as needed by X */
|
#define MCOOKIE_X_NAME "MIT-MAGIC-COOKIE-1" /* as needed by X */
|
||||||
@@ -106,7 +106,7 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a
|
|||||||
* since it limits the size of requests and responses. Don't make it bigger
|
* since it limits the size of requests and responses. Don't make it bigger
|
||||||
* than your system's max message size though (usually a couple of k) or else
|
* than your system's max message size though (usually a couple of k) or else
|
||||||
* msgsend will start failing. For sockets, using the system BUFSIZ is usually
|
* msgsend will start failing. For sockets, using the system BUFSIZ is usually
|
||||||
* what you want.
|
* what you want.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
|
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GLIBTOP_PPP_STATE 0
|
#define GLIBTOP_PPP_STATE 0
|
||||||
#define GLIBTOP_PPP_BYTES_IN 1
|
#define GLIBTOP_PPP_BYTES_IN 1
|
||||||
#define GLIBTOP_PPP_BYTES_OUT 2
|
#define GLIBTOP_PPP_BYTES_OUT 2
|
||||||
|
|
||||||
#define GLIBTOP_MAX_PPP 3
|
#define GLIBTOP_MAX_PPP 3
|
||||||
|
@@ -55,7 +55,7 @@ typedef struct _glibtop_proc_state glibtop_proc_state;
|
|||||||
struct _glibtop_proc_state
|
struct _glibtop_proc_state
|
||||||
{
|
{
|
||||||
guint64 flags;
|
guint64 flags;
|
||||||
char cmd[40]; /* basename of executable file in
|
char cmd[40]; /* basename of executable file in
|
||||||
* call to exec(2) */
|
* call to exec(2) */
|
||||||
unsigned state; /* single-char code for process state
|
unsigned state; /* single-char code for process state
|
||||||
* (S=sleeping) */
|
* (S=sleeping) */
|
||||||
@@ -90,7 +90,7 @@ void glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf, pid_t p
|
|||||||
void glibtop_init_proc_state_s (glibtop *server);
|
void glibtop_init_proc_state_s (glibtop *server);
|
||||||
void glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid);
|
void glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GLIBTOP_NAMES
|
#ifdef GLIBTOP_NAMES
|
||||||
|
|
||||||
/* You need to link with -lgtop_names to get this stuff here. */
|
/* You need to link with -lgtop_names to get this stuff here. */
|
||||||
|
@@ -51,14 +51,14 @@ typedef struct _glibtop_proc_time glibtop_proc_time;
|
|||||||
struct _glibtop_proc_time
|
struct _glibtop_proc_time
|
||||||
{
|
{
|
||||||
guint64 flags,
|
guint64 flags,
|
||||||
start_time, /* start time of process --
|
start_time, /* start time of process --
|
||||||
* seconds since 1-1-70 */
|
* seconds since 1-1-70 */
|
||||||
rtime, /* real time accumulated by process */
|
rtime, /* real time accumulated by process */
|
||||||
utime, /* user-mode CPU time accumulated by process */
|
utime, /* user-mode CPU time accumulated by process */
|
||||||
stime, /* kernel-mode CPU time accumulated by process */
|
stime, /* kernel-mode CPU time accumulated by process */
|
||||||
cutime, /* cumulative utime of process and
|
cutime, /* cumulative utime of process and
|
||||||
* reaped children */
|
* reaped children */
|
||||||
cstime, /* cumulative stime of process and
|
cstime, /* cumulative stime of process and
|
||||||
* reaped children */
|
* reaped children */
|
||||||
timeout, /* The time (in jiffies) of the process's
|
timeout, /* The time (in jiffies) of the process's
|
||||||
* next timeout */
|
* next timeout */
|
||||||
|
@@ -212,7 +212,7 @@ get_wchan (struct task_struct *p)
|
|||||||
return ((unsigned long *)schedule_frame)[12];
|
return ((unsigned long *)schedule_frame)[12];
|
||||||
}
|
}
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
#elif defined(__mc68000__)
|
#elif defined(__mc68000__)
|
||||||
{
|
{
|
||||||
unsigned long fp, pc;
|
unsigned long fp, pc;
|
||||||
@@ -318,7 +318,7 @@ static inline void
|
|||||||
task_mem (struct task_struct *p, libgtop_proc_segment_t *proc_segment)
|
task_mem (struct task_struct *p, libgtop_proc_segment_t *proc_segment)
|
||||||
{
|
{
|
||||||
struct mm_struct * mm = p->mm;
|
struct mm_struct * mm = p->mm;
|
||||||
|
|
||||||
if (mm && mm != &init_mm) {
|
if (mm && mm != &init_mm) {
|
||||||
struct vm_area_struct * vma = mm->mmap;
|
struct vm_area_struct * vma = mm->mmap;
|
||||||
unsigned long data = 0, stack = 0;
|
unsigned long data = 0, stack = 0;
|
||||||
@@ -486,7 +486,7 @@ get_statm (struct task_struct *tsk, libgtop_proc_mem_t *proc_mem)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_mem->segment.vsize = vsize;
|
proc_mem->segment.vsize = vsize;
|
||||||
proc_mem->segment.data = data;
|
proc_mem->segment.data = data;
|
||||||
proc_mem->segment.stack = stack;
|
proc_mem->segment.stack = stack;
|
||||||
proc_mem->segment.exec = exec;
|
proc_mem->segment.exec = exec;
|
||||||
@@ -498,7 +498,7 @@ get_statm (struct task_struct *tsk, libgtop_proc_mem_t *proc_mem)
|
|||||||
proc_mem->trs = trs;
|
proc_mem->trs = trs;
|
||||||
proc_mem->lrs = lrs;
|
proc_mem->lrs = lrs;
|
||||||
proc_mem->drs = drs;
|
proc_mem->drs = drs;
|
||||||
proc_mem->dt = dt;
|
proc_mem->dt = dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -522,7 +522,7 @@ collect_sigign_sigcatch (struct task_struct *p, sigset_t *ign,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
task_sig (struct task_struct *p, libgtop_proc_signal_t *proc_signal)
|
task_sig (struct task_struct *p, libgtop_proc_signal_t *proc_signal)
|
||||||
{
|
{
|
||||||
sigset_t ignore, catch;
|
sigset_t ignore, catch;
|
||||||
@@ -670,7 +670,7 @@ libgtop_sysctl (ctl_table *table, int nlen, int *name)
|
|||||||
|
|
||||||
if ((which & LIBGTOP_EXCLUDE_NOTTY) && (tsk->tty == NULL))
|
if ((which & LIBGTOP_EXCLUDE_NOTTY) && (tsk->tty == NULL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
proclist->pids [tindex++] = tsk->pid;
|
proclist->pids [tindex++] = tsk->pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -702,7 +702,7 @@ libgtop_sysctl_proc (ctl_table *table, int nlen, int *name,
|
|||||||
case LIBGTOP_PROC_STATE:
|
case LIBGTOP_PROC_STATE:
|
||||||
proc_state = table->data;
|
proc_state = table->data;
|
||||||
memset (proc_state, 0, sizeof (libgtop_proc_state_t));
|
memset (proc_state, 0, sizeof (libgtop_proc_state_t));
|
||||||
|
|
||||||
proc_state->uid = tsk->uid;
|
proc_state->uid = tsk->uid;
|
||||||
proc_state->gid = tsk->gid;
|
proc_state->gid = tsk->gid;
|
||||||
proc_state->flags = tsk->flags;
|
proc_state->flags = tsk->flags;
|
||||||
@@ -711,12 +711,12 @@ libgtop_sysctl_proc (ctl_table *table, int nlen, int *name,
|
|||||||
proc_state->euid = tsk->euid;
|
proc_state->euid = tsk->euid;
|
||||||
proc_state->suid = tsk->suid;
|
proc_state->suid = tsk->suid;
|
||||||
proc_state->fsuid = tsk->fsuid;
|
proc_state->fsuid = tsk->fsuid;
|
||||||
|
|
||||||
proc_state->gid = tsk->gid;
|
proc_state->gid = tsk->gid;
|
||||||
proc_state->egid = tsk->egid;
|
proc_state->egid = tsk->egid;
|
||||||
proc_state->sgid = tsk->sgid;
|
proc_state->sgid = tsk->sgid;
|
||||||
proc_state->fsgid = tsk->fsgid;
|
proc_state->fsgid = tsk->fsgid;
|
||||||
|
|
||||||
proc_state->pid = tsk->pid;
|
proc_state->pid = tsk->pid;
|
||||||
proc_state->pgrp = tsk->pgrp;
|
proc_state->pgrp = tsk->pgrp;
|
||||||
proc_state->ppid = tsk->p_pptr->pid;
|
proc_state->ppid = tsk->p_pptr->pid;
|
||||||
@@ -757,12 +757,12 @@ libgtop_sysctl_proc (ctl_table *table, int nlen, int *name,
|
|||||||
proc_state->it_real_incr = tsk->it_real_incr;
|
proc_state->it_real_incr = tsk->it_real_incr;
|
||||||
proc_state->it_prof_incr = tsk->it_prof_incr;
|
proc_state->it_prof_incr = tsk->it_prof_incr;
|
||||||
proc_state->it_virt_incr = tsk->it_virt_incr;
|
proc_state->it_virt_incr = tsk->it_virt_incr;
|
||||||
|
|
||||||
proc_state->min_flt = tsk->min_flt;
|
proc_state->min_flt = tsk->min_flt;
|
||||||
proc_state->cmin_flt = tsk->cmin_flt;
|
proc_state->cmin_flt = tsk->cmin_flt;
|
||||||
proc_state->maj_flt = tsk->maj_flt;
|
proc_state->maj_flt = tsk->maj_flt;
|
||||||
proc_state->cmaj_flt = tsk->cmaj_flt;
|
proc_state->cmaj_flt = tsk->cmaj_flt;
|
||||||
|
|
||||||
proc_state->nswap = tsk->nswap;
|
proc_state->nswap = tsk->nswap;
|
||||||
proc_state->cnswap = tsk->cnswap;
|
proc_state->cnswap = tsk->cnswap;
|
||||||
|
|
||||||
@@ -794,7 +794,7 @@ libgtop_sysctl_proc (ctl_table *table, int nlen, int *name,
|
|||||||
proc_state->ngroups = tsk->ngroups;
|
proc_state->ngroups = tsk->ngroups;
|
||||||
for (i = 0; i < min (tsk->ngroups, LIBGTOP_MAX_GROUPS); i++)
|
for (i = 0; i < min (tsk->ngroups, LIBGTOP_MAX_GROUPS); i++)
|
||||||
proc_state->groups [i] = tsk->groups [i];
|
proc_state->groups [i] = tsk->groups [i];
|
||||||
|
|
||||||
if (tsk->state & TASK_INTERRUPTIBLE)
|
if (tsk->state & TASK_INTERRUPTIBLE)
|
||||||
proc_state->state |= LIBGTOP_TASK_INTERRUPTIBLE;
|
proc_state->state |= LIBGTOP_TASK_INTERRUPTIBLE;
|
||||||
if (tsk->state & TASK_UNINTERRUPTIBLE)
|
if (tsk->state & TASK_UNINTERRUPTIBLE)
|
||||||
@@ -1023,7 +1023,7 @@ proc_args_ctl_handler (ctl_table *table, int *name, int nlen,
|
|||||||
|
|
||||||
if (put_user (len, oldlenp))
|
if (put_user (len, oldlenp))
|
||||||
goto err_fault_free_page;
|
goto err_fault_free_page;
|
||||||
|
|
||||||
if (copy_to_user (oldval, (void *) page, len))
|
if (copy_to_user (oldval, (void *) page, len))
|
||||||
goto err_fault_free_page;
|
goto err_fault_free_page;
|
||||||
|
|
||||||
@@ -1113,7 +1113,7 @@ proc_maps_ctl_handler (ctl_table *table, int *name, int nlen,
|
|||||||
proc_maps->filename [LIBGTOP_MAP_PATH_LEN-1] = '\0';
|
proc_maps->filename [LIBGTOP_MAP_PATH_LEN-1] = '\0';
|
||||||
proc_maps->header.filename_offset = line - proc_maps->filename;
|
proc_maps->header.filename_offset = line - proc_maps->filename;
|
||||||
|
|
||||||
proc_maps->header.device =
|
proc_maps->header.device =
|
||||||
map->vm_file->f_dentry->d_inode->i_dev;
|
map->vm_file->f_dentry->d_inode->i_dev;
|
||||||
proc_maps->header.inode =
|
proc_maps->header.inode =
|
||||||
map->vm_file->f_dentry->d_inode->i_ino;
|
map->vm_file->f_dentry->d_inode->i_ino;
|
||||||
@@ -1243,13 +1243,13 @@ proc_net_ctl_handler (ctl_table *table, int *name, int nlen,
|
|||||||
netload.rx_frame_errors = stats->rx_frame_errors;
|
netload.rx_frame_errors = stats->rx_frame_errors;
|
||||||
netload.rx_fifo_errors = stats->rx_fifo_errors;
|
netload.rx_fifo_errors = stats->rx_fifo_errors;
|
||||||
netload.rx_missed_errors = stats->rx_missed_errors;
|
netload.rx_missed_errors = stats->rx_missed_errors;
|
||||||
|
|
||||||
netload.tx_aborted_errors = stats->tx_aborted_errors;
|
netload.tx_aborted_errors = stats->tx_aborted_errors;
|
||||||
netload.tx_carrier_errors = stats->tx_carrier_errors;
|
netload.tx_carrier_errors = stats->tx_carrier_errors;
|
||||||
netload.tx_fifo_errors = stats->tx_fifo_errors;
|
netload.tx_fifo_errors = stats->tx_fifo_errors;
|
||||||
netload.tx_heartbeat_errors = stats->tx_heartbeat_errors;
|
netload.tx_heartbeat_errors = stats->tx_heartbeat_errors;
|
||||||
netload.tx_window_errors = stats->tx_window_errors;
|
netload.tx_window_errors = stats->tx_window_errors;
|
||||||
|
|
||||||
netload.rx_compressed = stats->rx_compressed;
|
netload.rx_compressed = stats->rx_compressed;
|
||||||
netload.tx_compressed = stats->tx_compressed;
|
netload.tx_compressed = stats->tx_compressed;
|
||||||
|
|
||||||
|
@@ -218,7 +218,7 @@ struct libgtop_netload
|
|||||||
unsigned long tx_dropped; /* no space available in linux */
|
unsigned long tx_dropped; /* no space available in linux */
|
||||||
unsigned long multicast; /* multicast packets received */
|
unsigned long multicast; /* multicast packets received */
|
||||||
unsigned long collisions;
|
unsigned long collisions;
|
||||||
|
|
||||||
/* detailed rx_errors: */
|
/* detailed rx_errors: */
|
||||||
unsigned long rx_length_errors;
|
unsigned long rx_length_errors;
|
||||||
unsigned long rx_over_errors; /* receiver ring buff overflow */
|
unsigned long rx_over_errors; /* receiver ring buff overflow */
|
||||||
@@ -226,14 +226,14 @@ struct libgtop_netload
|
|||||||
unsigned long rx_frame_errors; /* recv'd frame alignment error */
|
unsigned long rx_frame_errors; /* recv'd frame alignment error */
|
||||||
unsigned long rx_fifo_errors; /* recv'r fifo overrun */
|
unsigned long rx_fifo_errors; /* recv'r fifo overrun */
|
||||||
unsigned long rx_missed_errors; /* receiver missed packet */
|
unsigned long rx_missed_errors; /* receiver missed packet */
|
||||||
|
|
||||||
/* detailed tx_errors */
|
/* detailed tx_errors */
|
||||||
unsigned long tx_aborted_errors;
|
unsigned long tx_aborted_errors;
|
||||||
unsigned long tx_carrier_errors;
|
unsigned long tx_carrier_errors;
|
||||||
unsigned long tx_fifo_errors;
|
unsigned long tx_fifo_errors;
|
||||||
unsigned long tx_heartbeat_errors;
|
unsigned long tx_heartbeat_errors;
|
||||||
unsigned long tx_window_errors;
|
unsigned long tx_window_errors;
|
||||||
|
|
||||||
/* for cslip etc */
|
/* for cslip etc */
|
||||||
unsigned long rx_compressed;
|
unsigned long rx_compressed;
|
||||||
unsigned long tx_compressed;
|
unsigned long tx_compressed;
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
#define TABLE_KERN_PROC_UID 5
|
#define TABLE_KERN_PROC_UID 5
|
||||||
#define TABLE_KERN_PROC_RUID 6
|
#define TABLE_KERN_PROC_RUID 6
|
||||||
|
|
||||||
#define TABLE_KERN_PROC_MASK 15
|
#define TABLE_KERN_PROC_MASK 15
|
||||||
|
|
||||||
#define TABLE_EXCLUDE_IDLE 0x1000
|
#define TABLE_EXCLUDE_IDLE 0x1000
|
||||||
#define TABLE_EXCLUDE_SYSTEM 0x2000
|
#define TABLE_EXCLUDE_SYSTEM 0x2000
|
||||||
@@ -178,7 +178,7 @@ union table
|
|||||||
struct table_proc_mem proc_mem;
|
struct table_proc_mem proc_mem;
|
||||||
struct table_proc_segment proc_segment;
|
struct table_proc_segment proc_segment;
|
||||||
struct table_proc_time proc_time;
|
struct table_proc_time proc_time;
|
||||||
struct table_proc_state proc_state;
|
struct table_proc_state proc_state;
|
||||||
struct table_proc_signal proc_signal;
|
struct table_proc_signal proc_signal;
|
||||||
struct table_proc_kernel proc_kernel;
|
struct table_proc_kernel proc_kernel;
|
||||||
};
|
};
|
||||||
|
@@ -50,7 +50,7 @@ static struct task_struct *
|
|||||||
get_task (pid_t pid)
|
get_task (pid_t pid)
|
||||||
{
|
{
|
||||||
struct task_struct ** p;
|
struct task_struct ** p;
|
||||||
|
|
||||||
p = task;
|
p = task;
|
||||||
while (++p < task+NR_TASKS) {
|
while (++p < task+NR_TASKS) {
|
||||||
if (*p && (*p)->pid == pid)
|
if (*p && (*p)->pid == pid)
|
||||||
@@ -171,7 +171,7 @@ get_wchan (struct task_struct *p)
|
|||||||
{
|
{
|
||||||
unsigned long schedule_frame;
|
unsigned long schedule_frame;
|
||||||
unsigned long pc;
|
unsigned long pc;
|
||||||
|
|
||||||
pc = thread_saved_pc(&p->tss);
|
pc = thread_saved_pc(&p->tss);
|
||||||
if (pc >= (unsigned long) interruptible_sleep_on && pc < (unsigned long) add_timer) {
|
if (pc >= (unsigned long) interruptible_sleep_on && pc < (unsigned long) add_timer) {
|
||||||
schedule_frame = ((unsigned long *)p->tss.ksp)[6];
|
schedule_frame = ((unsigned long *)p->tss.ksp)[6];
|
||||||
@@ -246,7 +246,7 @@ sys_table (int type, union table *buf, const void *param)
|
|||||||
tbl.proclist.last_pid = last_pid;
|
tbl.proclist.last_pid = last_pid;
|
||||||
break;
|
break;
|
||||||
case TABLE_CPU:
|
case TABLE_CPU:
|
||||||
tbl.cpu.total = jiffies;
|
tbl.cpu.total = jiffies;
|
||||||
tbl.cpu.user = kstat.cpu_user;
|
tbl.cpu.user = kstat.cpu_user;
|
||||||
tbl.cpu.nice = kstat.cpu_nice;
|
tbl.cpu.nice = kstat.cpu_nice;
|
||||||
tbl.cpu.sys = kstat.cpu_system;
|
tbl.cpu.sys = kstat.cpu_system;
|
||||||
@@ -294,21 +294,21 @@ sys_table (int type, union table *buf, const void *param)
|
|||||||
tbl.proc_uid.euid = tsk->euid;
|
tbl.proc_uid.euid = tsk->euid;
|
||||||
tbl.proc_uid.suid = tsk->suid;
|
tbl.proc_uid.suid = tsk->suid;
|
||||||
tbl.proc_uid.fsuid = tsk->fsuid;
|
tbl.proc_uid.fsuid = tsk->fsuid;
|
||||||
|
|
||||||
tbl.proc_uid.gid = tsk->gid;
|
tbl.proc_uid.gid = tsk->gid;
|
||||||
tbl.proc_uid.egid = tsk->egid;
|
tbl.proc_uid.egid = tsk->egid;
|
||||||
tbl.proc_uid.sgid = tsk->sgid;
|
tbl.proc_uid.sgid = tsk->sgid;
|
||||||
tbl.proc_uid.fsgid = tsk->fsgid;
|
tbl.proc_uid.fsgid = tsk->fsgid;
|
||||||
|
|
||||||
tbl.proc_uid.pid = tsk->pid;
|
tbl.proc_uid.pid = tsk->pid;
|
||||||
tbl.proc_uid.pgrp = tsk->pgrp;
|
tbl.proc_uid.pgrp = tsk->pgrp;
|
||||||
tbl.proc_uid.ppid = tsk->p_pptr->pid;
|
tbl.proc_uid.ppid = tsk->p_pptr->pid;
|
||||||
|
|
||||||
tbl.proc_uid.session = tsk->session;
|
tbl.proc_uid.session = tsk->session;
|
||||||
tbl.proc_uid.tty = tsk->tty ?
|
tbl.proc_uid.tty = tsk->tty ?
|
||||||
kdev_t_to_nr (tsk->tty->device) : 0;
|
kdev_t_to_nr (tsk->tty->device) : 0;
|
||||||
tbl.proc_uid.tpgid = tsk->tty ? tsk->tty->pgrp : -1;
|
tbl.proc_uid.tpgid = tsk->tty ? tsk->tty->pgrp : -1;
|
||||||
|
|
||||||
tbl.proc_uid.priority = tsk->priority;
|
tbl.proc_uid.priority = tsk->priority;
|
||||||
tbl.proc_uid.counter = tsk->counter;
|
tbl.proc_uid.counter = tsk->counter;
|
||||||
tbl.proc_uid.def_priority = DEF_PRIORITY;
|
tbl.proc_uid.def_priority = DEF_PRIORITY;
|
||||||
@@ -322,7 +322,7 @@ sys_table (int type, union table *buf, const void *param)
|
|||||||
unsigned long sig_ign = 0, sig_caught = 0;
|
unsigned long sig_ign = 0, sig_caught = 0;
|
||||||
unsigned long bit = 1;
|
unsigned long bit = 1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
switch((unsigned long) action->sa_handler) {
|
switch((unsigned long) action->sa_handler) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -376,7 +376,7 @@ sys_table (int type, union table *buf, const void *param)
|
|||||||
while (vma) {
|
while (vma) {
|
||||||
pgd_t *pgd = pgd_offset(tsk->mm, vma->vm_start);
|
pgd_t *pgd = pgd_offset(tsk->mm, vma->vm_start);
|
||||||
int pages = 0, shared = 0, dirty = 0, total = 0;
|
int pages = 0, shared = 0, dirty = 0, total = 0;
|
||||||
|
|
||||||
vsize += vma->vm_end - vma->vm_start;
|
vsize += vma->vm_end - vma->vm_start;
|
||||||
|
|
||||||
statm_pgd_range (pgd, vma->vm_start, vma->vm_end,
|
statm_pgd_range (pgd, vma->vm_start, vma->vm_end,
|
||||||
@@ -428,10 +428,10 @@ sys_table (int type, union table *buf, const void *param)
|
|||||||
tbl.proc_kernel.cmin_flt = tsk->cmin_flt;
|
tbl.proc_kernel.cmin_flt = tsk->cmin_flt;
|
||||||
tbl.proc_kernel.maj_flt = tsk->maj_flt;
|
tbl.proc_kernel.maj_flt = tsk->maj_flt;
|
||||||
tbl.proc_kernel.cmaj_flt = tsk->cmaj_flt;
|
tbl.proc_kernel.cmaj_flt = tsk->cmaj_flt;
|
||||||
|
|
||||||
tbl.proc_kernel.kesp = tsk->kernel_stack_page ? KSTK_EIP(tsk) : 0;
|
tbl.proc_kernel.kesp = tsk->kernel_stack_page ? KSTK_EIP(tsk) : 0;
|
||||||
tbl.proc_kernel.keip = tsk->kernel_stack_page ? KSTK_ESP(tsk) : 0;
|
tbl.proc_kernel.keip = tsk->kernel_stack_page ? KSTK_ESP(tsk) : 0;
|
||||||
|
|
||||||
tbl.proc_kernel.nswap = tsk->nswap;
|
tbl.proc_kernel.nswap = tsk->nswap;
|
||||||
tbl.proc_kernel.cnswap = tsk->cnswap;
|
tbl.proc_kernel.cnswap = tsk->cnswap;
|
||||||
|
|
||||||
@@ -442,10 +442,10 @@ sys_table (int type, union table *buf, const void *param)
|
|||||||
for (rule = chain->chain; rule; rule = rule->next) {
|
for (rule = chain->chain; rule; rule = rule->next) {
|
||||||
const char *name = rule->ipfw.fw_vianame;
|
const char *name = rule->ipfw.fw_vianame;
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
if (name [0] && !strncmp (param, name, 5))
|
if (name [0] && !strncmp (param, name, 5))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (k = 0; k < NUM_SLOTS; k++) {
|
for (k = 0; k < NUM_SLOTS; k++) {
|
||||||
tbl.netacct.packets +=
|
tbl.netacct.packets +=
|
||||||
rule->counters[k].pcnt;
|
rule->counters[k].pcnt;
|
||||||
|
@@ -237,7 +237,7 @@ if (__res>=0) \
|
|||||||
return (type) __res; \
|
return (type) __res; \
|
||||||
errno=-__res; \
|
errno=-__res; \
|
||||||
return -1; \
|
return -1; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
|
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
|
||||||
type5,arg5) \
|
type5,arg5) \
|
||||||
|
@@ -140,7 +140,7 @@ static unsigned long get_wchan(struct task_struct *p)
|
|||||||
return ((unsigned long *)schedule_frame)[12];
|
return ((unsigned long *)schedule_frame)[12];
|
||||||
}
|
}
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
#elif defined(__mc68000__)
|
#elif defined(__mc68000__)
|
||||||
{
|
{
|
||||||
unsigned long fp, pc;
|
unsigned long fp, pc;
|
||||||
@@ -388,7 +388,7 @@ table_fkt (int type, union table *buf, const void *param)
|
|||||||
if ((plistargs.which & TABLE_EXCLUDE_NOTTY) &&
|
if ((plistargs.which & TABLE_EXCLUDE_NOTTY) &&
|
||||||
(tsk->tty == NULL))
|
(tsk->tty == NULL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tbl.proclist.pids [tindex++] = tsk->pid;
|
tbl.proclist.pids [tindex++] = tsk->pid;
|
||||||
}
|
}
|
||||||
tbl.proclist.nr_running = nr_running;
|
tbl.proclist.nr_running = nr_running;
|
||||||
@@ -397,7 +397,7 @@ table_fkt (int type, union table *buf, const void *param)
|
|||||||
read_unlock(&tasklist_lock);
|
read_unlock(&tasklist_lock);
|
||||||
break;
|
break;
|
||||||
case TABLE_CPU:
|
case TABLE_CPU:
|
||||||
tbl.cpu.total = jiffies;
|
tbl.cpu.total = jiffies;
|
||||||
tbl.cpu.user = kstat.cpu_user;
|
tbl.cpu.user = kstat.cpu_user;
|
||||||
tbl.cpu.nice = kstat.cpu_nice;
|
tbl.cpu.nice = kstat.cpu_nice;
|
||||||
tbl.cpu.sys = kstat.cpu_system;
|
tbl.cpu.sys = kstat.cpu_system;
|
||||||
@@ -446,21 +446,21 @@ table_fkt (int type, union table *buf, const void *param)
|
|||||||
tbl.proc_uid.euid = tsk->euid;
|
tbl.proc_uid.euid = tsk->euid;
|
||||||
tbl.proc_uid.suid = tsk->suid;
|
tbl.proc_uid.suid = tsk->suid;
|
||||||
tbl.proc_uid.fsuid = tsk->fsuid;
|
tbl.proc_uid.fsuid = tsk->fsuid;
|
||||||
|
|
||||||
tbl.proc_uid.gid = tsk->gid;
|
tbl.proc_uid.gid = tsk->gid;
|
||||||
tbl.proc_uid.egid = tsk->egid;
|
tbl.proc_uid.egid = tsk->egid;
|
||||||
tbl.proc_uid.sgid = tsk->sgid;
|
tbl.proc_uid.sgid = tsk->sgid;
|
||||||
tbl.proc_uid.fsgid = tsk->fsgid;
|
tbl.proc_uid.fsgid = tsk->fsgid;
|
||||||
|
|
||||||
tbl.proc_uid.pid = tsk->pid;
|
tbl.proc_uid.pid = tsk->pid;
|
||||||
tbl.proc_uid.pgrp = tsk->pgrp;
|
tbl.proc_uid.pgrp = tsk->pgrp;
|
||||||
tbl.proc_uid.ppid = tsk->p_pptr->pid;
|
tbl.proc_uid.ppid = tsk->p_pptr->pid;
|
||||||
|
|
||||||
tbl.proc_uid.session = tsk->session;
|
tbl.proc_uid.session = tsk->session;
|
||||||
tbl.proc_uid.tty = tsk->tty ?
|
tbl.proc_uid.tty = tsk->tty ?
|
||||||
kdev_t_to_nr (tsk->tty->device) : 0;
|
kdev_t_to_nr (tsk->tty->device) : 0;
|
||||||
tbl.proc_uid.tpgid = tsk->tty ? tsk->tty->pgrp : -1;
|
tbl.proc_uid.tpgid = tsk->tty ? tsk->tty->pgrp : -1;
|
||||||
|
|
||||||
tbl.proc_uid.priority = tsk->priority;
|
tbl.proc_uid.priority = tsk->priority;
|
||||||
tbl.proc_uid.counter = tsk->counter;
|
tbl.proc_uid.counter = tsk->counter;
|
||||||
tbl.proc_uid.def_priority = DEF_PRIORITY;
|
tbl.proc_uid.def_priority = DEF_PRIORITY;
|
||||||
@@ -520,7 +520,7 @@ table_fkt (int type, union table *buf, const void *param)
|
|||||||
while (vma) {
|
while (vma) {
|
||||||
pgd_t *pgd = pgd_offset(tsk->mm, vma->vm_start);
|
pgd_t *pgd = pgd_offset(tsk->mm, vma->vm_start);
|
||||||
int pages = 0, shared = 0, dirty = 0, total = 0;
|
int pages = 0, shared = 0, dirty = 0, total = 0;
|
||||||
|
|
||||||
vsize += vma->vm_end - vma->vm_start;
|
vsize += vma->vm_end - vma->vm_start;
|
||||||
|
|
||||||
statm_pgd_range (pgd, vma->vm_start, vma->vm_end,
|
statm_pgd_range (pgd, vma->vm_start, vma->vm_end,
|
||||||
@@ -584,10 +584,10 @@ table_fkt (int type, union table *buf, const void *param)
|
|||||||
tbl.proc_kernel.cmin_flt = tsk->cmin_flt;
|
tbl.proc_kernel.cmin_flt = tsk->cmin_flt;
|
||||||
tbl.proc_kernel.maj_flt = tsk->maj_flt;
|
tbl.proc_kernel.maj_flt = tsk->maj_flt;
|
||||||
tbl.proc_kernel.cmaj_flt = tsk->cmaj_flt;
|
tbl.proc_kernel.cmaj_flt = tsk->cmaj_flt;
|
||||||
|
|
||||||
tbl.proc_kernel.kesp = KSTK_ESP(tsk);
|
tbl.proc_kernel.kesp = KSTK_ESP(tsk);
|
||||||
tbl.proc_kernel.keip = KSTK_EIP(tsk);
|
tbl.proc_kernel.keip = KSTK_EIP(tsk);
|
||||||
|
|
||||||
tbl.proc_kernel.nswap = tsk->nswap;
|
tbl.proc_kernel.nswap = tsk->nswap;
|
||||||
tbl.proc_kernel.cnswap = tsk->cnswap;
|
tbl.proc_kernel.cnswap = tsk->cnswap;
|
||||||
|
|
||||||
|
@@ -259,7 +259,7 @@ __asm__ volatile ("int $0x80" \
|
|||||||
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
|
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
|
||||||
"d" ((long)(arg3)),"S" ((long)(arg4))); \
|
"d" ((long)(arg3)),"S" ((long)(arg4))); \
|
||||||
__syscall_return(type,__res); \
|
__syscall_return(type,__res); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
|
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
|
||||||
type5,arg5) \
|
type5,arg5) \
|
||||||
|
@@ -50,7 +50,7 @@ glibtop_call_l (glibtop *server, unsigned command, size_t send_size,
|
|||||||
} else {
|
} else {
|
||||||
cmnd.data_size = send_size;
|
cmnd.data_size = send_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
glibtop_write_l (server, sizeof (glibtop_command), &cmnd);
|
glibtop_write_l (server, sizeof (glibtop_command), &cmnd);
|
||||||
|
|
||||||
glibtop_read_l (server, sizeof (glibtop_response), &response);
|
glibtop_read_l (server, sizeof (glibtop_response), &response);
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
static void
|
static void
|
||||||
print_server_name (glibtop_server *server)
|
print_server_name (glibtop_server *server)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: ", server ?
|
fprintf (stderr, "%s: ", server ?
|
||||||
(server->name ? server->name : DEFAULT_NAME)
|
(server->name ? server->name : DEFAULT_NAME)
|
||||||
: DEFAULT_NAME);
|
: DEFAULT_NAME);
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ print_server_name (glibtop_server *server)
|
|||||||
void
|
void
|
||||||
glibtop_error_vr (glibtop_server *server, char *format, va_list args)
|
glibtop_error_vr (glibtop_server *server, char *format, va_list args)
|
||||||
{
|
{
|
||||||
print_server_name (server);
|
print_server_name (server);
|
||||||
vfprintf (stderr, format, args);
|
vfprintf (stderr, format, args);
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@ GType
|
|||||||
glibtop_backend_get_type (void)
|
glibtop_backend_get_type (void)
|
||||||
{
|
{
|
||||||
static GType glibtop_backend_type = 0;
|
static GType glibtop_backend_type = 0;
|
||||||
|
|
||||||
if (!glibtop_backend_type) {
|
if (!glibtop_backend_type) {
|
||||||
static const GTypeInfo glibtop_backend_info = {
|
static const GTypeInfo glibtop_backend_info = {
|
||||||
sizeof (glibtop_backend_class),
|
sizeof (glibtop_backend_class),
|
||||||
@@ -66,7 +66,7 @@ glibtop_backend_get_type (void)
|
|||||||
16, /* n_preallocs */
|
16, /* n_preallocs */
|
||||||
(GInstanceInitFunc) glibtop_backend_init,
|
(GInstanceInitFunc) glibtop_backend_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
glibtop_backend_type = g_type_register_static
|
glibtop_backend_type = g_type_register_static
|
||||||
(G_TYPE_OBJECT, "glibtop_backend", &glibtop_backend_info, 0);
|
(G_TYPE_OBJECT, "glibtop_backend", &glibtop_backend_info, 0);
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ glibtop_backend_class_init (glibtop_backend_class *class)
|
|||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) class;
|
gobject_class = (GObjectClass *) class;
|
||||||
|
|
||||||
parent_class = g_type_class_ref (G_TYPE_OBJECT);
|
parent_class = g_type_class_ref (G_TYPE_OBJECT);
|
||||||
|
|
||||||
gobject_class->finalize = glibtop_backend_finalize;
|
gobject_class->finalize = glibtop_backend_finalize;
|
||||||
@@ -100,12 +100,12 @@ glibtop_backend_finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
glibtop_backend *glibtop;
|
glibtop_backend *glibtop;
|
||||||
glibtop_backend_private *priv = NULL;
|
glibtop_backend_private *priv = NULL;
|
||||||
|
|
||||||
glibtop = GLIBTOP_BACKEND (object);
|
glibtop = GLIBTOP_BACKEND (object);
|
||||||
priv = glibtop->_priv;
|
priv = glibtop->_priv;
|
||||||
|
|
||||||
g_free (priv);
|
g_free (priv);
|
||||||
|
|
||||||
if (G_OBJECT_CLASS (parent_class)->finalize)
|
if (G_OBJECT_CLASS (parent_class)->finalize)
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ GType
|
|||||||
glibtop_client_get_type (void)
|
glibtop_client_get_type (void)
|
||||||
{
|
{
|
||||||
static GType glibtop_client_type = 0;
|
static GType glibtop_client_type = 0;
|
||||||
|
|
||||||
if (!glibtop_client_type) {
|
if (!glibtop_client_type) {
|
||||||
static const GTypeInfo glibtop_client_info = {
|
static const GTypeInfo glibtop_client_info = {
|
||||||
sizeof (glibtop_client_class),
|
sizeof (glibtop_client_class),
|
||||||
@@ -60,7 +60,7 @@ glibtop_client_get_type (void)
|
|||||||
16, /* n_preallocs */
|
16, /* n_preallocs */
|
||||||
(GInstanceInitFunc) glibtop_client_init,
|
(GInstanceInitFunc) glibtop_client_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
glibtop_client_type = g_type_register_static
|
glibtop_client_type = g_type_register_static
|
||||||
(G_TYPE_OBJECT, "glibtop_client", &glibtop_client_info, 0);
|
(G_TYPE_OBJECT, "glibtop_client", &glibtop_client_info, 0);
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ glibtop_client_class_init (glibtop_client_class *klass)
|
|||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
glibtop_client_signals [GLIBTOP_CLIENT_SIGNAL_ERROR] =
|
glibtop_client_signals [GLIBTOP_CLIENT_SIGNAL_ERROR] =
|
||||||
@@ -122,7 +122,7 @@ glibtop_client_class_init (glibtop_client_class *klass)
|
|||||||
|
|
||||||
klass->error = glibtop_client_error_handler;
|
klass->error = glibtop_client_error_handler;
|
||||||
klass->warning = glibtop_client_warning_handler;
|
klass->warning = glibtop_client_warning_handler;
|
||||||
|
|
||||||
gobject_class->finalize = glibtop_client_finalize;
|
gobject_class->finalize = glibtop_client_finalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ static void
|
|||||||
glibtop_client_init (glibtop_client *glibtop)
|
glibtop_client_init (glibtop_client *glibtop)
|
||||||
{
|
{
|
||||||
glibtop_client_private *priv;
|
glibtop_client_private *priv;
|
||||||
|
|
||||||
priv = g_new0 (glibtop_client_private, 1);
|
priv = g_new0 (glibtop_client_private, 1);
|
||||||
glibtop->_priv = priv;
|
glibtop->_priv = priv;
|
||||||
}
|
}
|
||||||
@@ -141,16 +141,16 @@ glibtop_client_finalize (GObject *object)
|
|||||||
glibtop_client *glibtop;
|
glibtop_client *glibtop;
|
||||||
glibtop_client_private *priv = NULL;
|
glibtop_client_private *priv = NULL;
|
||||||
GSList *c;
|
GSList *c;
|
||||||
|
|
||||||
glibtop = GLIBTOP_CLIENT (object);
|
glibtop = GLIBTOP_CLIENT (object);
|
||||||
priv = glibtop->_priv;
|
priv = glibtop->_priv;
|
||||||
|
|
||||||
for (c = priv->backend_list; c; c = c->next)
|
for (c = priv->backend_list; c; c = c->next)
|
||||||
g_object_unref (G_OBJECT (c->data));
|
g_object_unref (G_OBJECT (c->data));
|
||||||
g_slist_free (priv->backend_list);
|
g_slist_free (priv->backend_list);
|
||||||
|
|
||||||
g_free (priv);
|
g_free (priv);
|
||||||
|
|
||||||
if (G_OBJECT_CLASS (parent_class)->finalize)
|
if (G_OBJECT_CLASS (parent_class)->finalize)
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ glibtop_client_propagate_error (glibtop_client *client, GError *error)
|
|||||||
g_signal_emitv (params,
|
g_signal_emitv (params,
|
||||||
glibtop_client_signals [GLIBTOP_CLIENT_SIGNAL_ERROR],
|
glibtop_client_signals [GLIBTOP_CLIENT_SIGNAL_ERROR],
|
||||||
0, NULL);
|
0, NULL);
|
||||||
|
|
||||||
g_value_unset (params + 1);
|
g_value_unset (params + 1);
|
||||||
g_value_unset (params + 0);
|
g_value_unset (params + 0);
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ glibtop_client_propagate_warning (glibtop_client *client, GError *error)
|
|||||||
g_signal_emitv (params,
|
g_signal_emitv (params,
|
||||||
glibtop_client_signals [GLIBTOP_CLIENT_SIGNAL_WARNING],
|
glibtop_client_signals [GLIBTOP_CLIENT_SIGNAL_WARNING],
|
||||||
0, NULL);
|
0, NULL);
|
||||||
|
|
||||||
g_value_unset (params + 1);
|
g_value_unset (params + 1);
|
||||||
g_value_unset (params + 0);
|
g_value_unset (params + 0);
|
||||||
}
|
}
|
||||||
|
44
lib/init.c
44
lib/init.c
@@ -50,7 +50,7 @@ _init_server (glibtop *server, const unsigned features)
|
|||||||
if (server->server_rsh == NULL) {
|
if (server->server_rsh == NULL) {
|
||||||
const char *temp = getenv ("LIBGTOP_RSH") ?
|
const char *temp = getenv ("LIBGTOP_RSH") ?
|
||||||
getenv ("LIBGTOP_RSH") : "/usr/bin/ssh";
|
getenv ("LIBGTOP_RSH") : "/usr/bin/ssh";
|
||||||
|
|
||||||
server->server_rsh = g_strdup (temp);
|
server->server_rsh = g_strdup (temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,15 +78,15 @@ _init_server (glibtop *server, const unsigned features)
|
|||||||
|
|
||||||
/* If the first character of 'server_command' is a colon,
|
/* If the first character of 'server_command' is a colon,
|
||||||
* the first field is the method to connect to the server. */
|
* the first field is the method to connect to the server. */
|
||||||
|
|
||||||
/* Everything up to the next colon is the method. */
|
/* Everything up to the next colon is the method. */
|
||||||
|
|
||||||
command = g_strdup (server->server_command+1);
|
command = g_strdup (server->server_command+1);
|
||||||
temp = strstr (command, ":");
|
temp = strstr (command, ":");
|
||||||
if (temp) *temp = 0;
|
if (temp) *temp = 0;
|
||||||
|
|
||||||
/* Dispatch method. */
|
/* Dispatch method. */
|
||||||
|
|
||||||
if (!strcmp (command, "direct")) {
|
if (!strcmp (command, "direct")) {
|
||||||
/* Use sysdeps dir instead of connecting to server
|
/* Use sysdeps dir instead of connecting to server
|
||||||
* even if using the server would be required on
|
* even if using the server would be required on
|
||||||
@@ -106,16 +106,16 @@ _init_server (glibtop *server, const unsigned features)
|
|||||||
} else {
|
} else {
|
||||||
char *temp2 = strstr (temp+1, ":");
|
char *temp2 = strstr (temp+1, ":");
|
||||||
if (temp2) *temp2 = 0;
|
if (temp2) *temp2 = 0;
|
||||||
|
|
||||||
/* Override default. */
|
/* Override default. */
|
||||||
if (server->server_host)
|
if (server->server_host)
|
||||||
g_free ((char *) server->server_host);
|
g_free ((char *) server->server_host);
|
||||||
|
|
||||||
server->server_host = g_strdup (temp+1);
|
server->server_host = g_strdup (temp+1);
|
||||||
|
|
||||||
temp = temp2;
|
temp = temp2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (temp == NULL) {
|
if (temp == NULL) {
|
||||||
/* If no value was set, we use DEFAULT_PORT. */
|
/* If no value was set, we use DEFAULT_PORT. */
|
||||||
if (server->server_port == 0)
|
if (server->server_port == 0)
|
||||||
@@ -123,10 +123,10 @@ _init_server (glibtop *server, const unsigned features)
|
|||||||
} else {
|
} else {
|
||||||
char *temp2 = strstr (temp+1, ":");
|
char *temp2 = strstr (temp+1, ":");
|
||||||
if (temp2) *temp2 = 0;
|
if (temp2) *temp2 = 0;
|
||||||
|
|
||||||
if (sscanf (temp+1, "%ld", &server->server_port) != 1)
|
if (sscanf (temp+1, "%ld", &server->server_port) != 1)
|
||||||
server->server_port = DEFAULT_PORT;
|
server->server_port = DEFAULT_PORT;
|
||||||
|
|
||||||
temp = temp2 ? temp2 + 1 : temp2;
|
temp = temp2 ? temp2 + 1 : temp2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ _init_server (glibtop *server, const unsigned features)
|
|||||||
server->server_command+1);
|
server->server_command+1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (command);
|
g_free (command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,27 +173,27 @@ glibtop_init_r (glibtop **server_ptr, unsigned long features, unsigned flags)
|
|||||||
if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) {
|
if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) {
|
||||||
if (flags & GLIBTOP_FEATURES_EXCEPT)
|
if (flags & GLIBTOP_FEATURES_EXCEPT)
|
||||||
features = ~features & GLIBTOP_SYSDEPS_ALL;
|
features = ~features & GLIBTOP_SYSDEPS_ALL;
|
||||||
|
|
||||||
if (features == 0)
|
if (features == 0)
|
||||||
features = GLIBTOP_SYSDEPS_ALL;
|
features = GLIBTOP_SYSDEPS_ALL;
|
||||||
|
|
||||||
if (flags & GLIBTOP_FEATURES_NO_SERVER) {
|
if (flags & GLIBTOP_FEATURES_NO_SERVER) {
|
||||||
server->method = GLIBTOP_METHOD_DIRECT;
|
server->method = GLIBTOP_METHOD_DIRECT;
|
||||||
features = 0;
|
features = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
server->features = features;
|
server->features = features;
|
||||||
|
|
||||||
_init_server (server, features);
|
_init_server (server, features);
|
||||||
|
|
||||||
server->flags |= _GLIBTOP_INIT_STATE_INIT;
|
server->flags |= _GLIBTOP_INIT_STATE_INIT;
|
||||||
|
|
||||||
switch (server->method) {
|
switch (server->method) {
|
||||||
case GLIBTOP_METHOD_PIPE:
|
case GLIBTOP_METHOD_PIPE:
|
||||||
case GLIBTOP_METHOD_UNIX:
|
case GLIBTOP_METHOD_UNIX:
|
||||||
if (glibtop_server_features & features)
|
if (glibtop_server_features & features)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
server->method = GLIBTOP_METHOD_DIRECT;
|
server->method = GLIBTOP_METHOD_DIRECT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -205,11 +205,11 @@ glibtop_init_r (glibtop **server_ptr, unsigned long features, unsigned flags)
|
|||||||
return server;
|
return server;
|
||||||
|
|
||||||
/* Open server, but only if not already opened. */
|
/* Open server, but only if not already opened. */
|
||||||
|
|
||||||
if ((server->flags & _GLIBTOP_INIT_STATE_OPEN) == 0)
|
if ((server->flags & _GLIBTOP_INIT_STATE_OPEN) == 0)
|
||||||
glibtop_open_l (glibtop_global_server, "glibtop",
|
glibtop_open_l (glibtop_global_server, "glibtop",
|
||||||
features, flags);
|
features, flags);
|
||||||
|
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ glibtop_init_s (glibtop **server_ptr, unsigned long features, unsigned flags)
|
|||||||
{
|
{
|
||||||
glibtop *server;
|
glibtop *server;
|
||||||
glibtop_init_func_t *init_fkt;
|
glibtop_init_func_t *init_fkt;
|
||||||
|
|
||||||
if (server_ptr == NULL)
|
if (server_ptr == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ glibtop_init_s (glibtop **server_ptr, unsigned long features, unsigned flags)
|
|||||||
|
|
||||||
for (init_fkt = _glibtop_init_hook_s; *init_fkt; init_fkt++)
|
for (init_fkt = _glibtop_init_hook_s; *init_fkt; init_fkt++)
|
||||||
(*init_fkt) (server);
|
(*init_fkt) (server);
|
||||||
|
|
||||||
server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
|
server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,9 +59,9 @@ glibtop_inodedb_open_s (glibtop *server, unsigned databases,
|
|||||||
|
|
||||||
pwd = getpwuid (getuid ());
|
pwd = getpwuid (getuid ());
|
||||||
if (!pwd) glibtop_error_io_r (server, "getpwuid");
|
if (!pwd) glibtop_error_io_r (server, "getpwuid");
|
||||||
|
|
||||||
sprintf (filename, "%s/var/libgtop/inodedb.db", pwd->pw_dir);
|
sprintf (filename, "%s/var/libgtop/inodedb.db", pwd->pw_dir);
|
||||||
|
|
||||||
if (stat (filename, &statb))
|
if (stat (filename, &statb))
|
||||||
databases &= ~GLIBTOP_INODEDB_USER;
|
databases &= ~GLIBTOP_INODEDB_USER;
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ glibtop_inodedb_close_s (glibtop *server, glibtop_inodedb *inodedb)
|
|||||||
{
|
{
|
||||||
if (inodedb->system_dbf)
|
if (inodedb->system_dbf)
|
||||||
gdbm_close (inodedb->system_dbf);
|
gdbm_close (inodedb->system_dbf);
|
||||||
|
|
||||||
if (inodedb->user_dbf)
|
if (inodedb->user_dbf)
|
||||||
gdbm_close (inodedb->user_dbf);
|
gdbm_close (inodedb->user_dbf);
|
||||||
|
|
||||||
|
26
lib/open.c
26
lib/open.c
@@ -62,17 +62,17 @@ glibtop_open_l (glibtop *server, const char *program_name,
|
|||||||
fprintf (stderr, "Connecting to '%s' port %ld.\n",
|
fprintf (stderr, "Connecting to '%s' port %ld.\n",
|
||||||
server->server_host, server->server_port);
|
server->server_host, server->server_port);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
connect_type = glibtop_make_connection
|
connect_type = glibtop_make_connection
|
||||||
(server->server_host, server->server_port,
|
(server->server_host, server->server_port,
|
||||||
&server->socket);
|
&server->socket);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf (stderr, "Connect Type is %d.\n", connect_type);
|
fprintf (stderr, "Connect Type is %d.\n", connect_type);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
server->flags |= _GLIBTOP_INIT_STATE_SERVER;
|
server->flags |= _GLIBTOP_INIT_STATE_SERVER;
|
||||||
|
|
||||||
server->features = -1;
|
server->features = -1;
|
||||||
break;
|
break;
|
||||||
case GLIBTOP_METHOD_UNIX:
|
case GLIBTOP_METHOD_UNIX:
|
||||||
@@ -83,7 +83,7 @@ glibtop_open_l (glibtop *server, const char *program_name,
|
|||||||
connect_type = glibtop_make_connection
|
connect_type = glibtop_make_connection
|
||||||
("unix", 0, &server->socket);
|
("unix", 0, &server->socket);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf (stderr, "Connect Type is %d.\n", connect_type);
|
fprintf (stderr, "Connect Type is %d.\n", connect_type);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ glibtop_open_l (glibtop *server, const char *program_name,
|
|||||||
glibtop_error_io_r (server, "cannot make a pipe");
|
glibtop_error_io_r (server, "cannot make a pipe");
|
||||||
|
|
||||||
server->pid = fork ();
|
server->pid = fork ();
|
||||||
|
|
||||||
if (server->pid < 0) {
|
if (server->pid < 0) {
|
||||||
glibtop_error_io_r (server, "fork failed");
|
glibtop_error_io_r (server, "fork failed");
|
||||||
} else if (server->pid == 0) {
|
} else if (server->pid == 0) {
|
||||||
@@ -119,7 +119,7 @@ glibtop_open_l (glibtop *server, const char *program_name,
|
|||||||
close (server->output [0]);
|
close (server->output [0]);
|
||||||
|
|
||||||
server->flags |= _GLIBTOP_INIT_STATE_SERVER;
|
server->flags |= _GLIBTOP_INIT_STATE_SERVER;
|
||||||
|
|
||||||
server->features = -1;
|
server->features = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -141,25 +141,25 @@ glibtop_open_l (glibtop *server, const char *program_name,
|
|||||||
sizeof (glibtop_sysdeps));
|
sizeof (glibtop_sysdeps));
|
||||||
|
|
||||||
size = strlen (version) + 1;
|
size = strlen (version) + 1;
|
||||||
|
|
||||||
glibtop_read_l (server, sizeof (nbytes), &nbytes);
|
glibtop_read_l (server, sizeof (nbytes), &nbytes);
|
||||||
|
|
||||||
if (nbytes != size)
|
if (nbytes != size)
|
||||||
glibtop_error_r (server,
|
glibtop_error_r (server,
|
||||||
"Requested %u bytes but got %u.",
|
"Requested %u bytes but got %u.",
|
||||||
size, nbytes);
|
size, nbytes);
|
||||||
|
|
||||||
glibtop_read_l (server, nbytes, buffer);
|
glibtop_read_l (server, nbytes, buffer);
|
||||||
|
|
||||||
if (memcmp (version, buffer, size))
|
if (memcmp (version, buffer, size))
|
||||||
glibtop_error_r (server, "server version is not %s",
|
glibtop_error_r (server, "server version is not %s",
|
||||||
LIBGTOP_VERSION);
|
LIBGTOP_VERSION);
|
||||||
|
|
||||||
/* Now ask it for its features. */
|
/* Now ask it for its features. */
|
||||||
|
|
||||||
glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL,
|
glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL,
|
||||||
sizeof (glibtop_sysdeps), &sysdeps);
|
sizeof (glibtop_sysdeps), &sysdeps);
|
||||||
|
|
||||||
server->features = sysdeps.features;
|
server->features = sysdeps.features;
|
||||||
|
|
||||||
memcpy (&server->sysdeps, &sysdeps, sizeof (glibtop_sysdeps));
|
memcpy (&server->sysdeps, &sysdeps, sizeof (glibtop_sysdeps));
|
||||||
@@ -176,6 +176,6 @@ glibtop_open_l (glibtop *server, const char *program_name,
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf (stderr, "Calling sysdeps open function.\n");
|
fprintf (stderr, "Calling sysdeps open function.\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glibtop_init_s (&server, features, flags);
|
glibtop_init_s (&server, features, flags);
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,7 @@ do_read (int s, void *ptr, size_t total_size)
|
|||||||
int nread;
|
int nread;
|
||||||
size_t already_read = 0, remaining = total_size;
|
size_t already_read = 0, remaining = total_size;
|
||||||
char *tmp_ptr;
|
char *tmp_ptr;
|
||||||
|
|
||||||
while (already_read < total_size) {
|
while (already_read < total_size) {
|
||||||
nread = recv (s, ptr, remaining, 0);
|
nread = recv (s, ptr, remaining, 0);
|
||||||
|
|
||||||
@@ -42,12 +42,12 @@ do_read (int s, void *ptr, size_t total_size)
|
|||||||
close (s);
|
close (s);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nread <= 0) {
|
if (nread <= 0) {
|
||||||
glibtop_error_io ("recv");
|
glibtop_error_io ("recv");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_read += nread;
|
already_read += nread;
|
||||||
remaining -= nread;
|
remaining -= nread;
|
||||||
/* (char *) ptr += nread; */
|
/* (char *) ptr += nread; */
|
||||||
|
@@ -54,10 +54,10 @@ glibtop_read_data_l (glibtop *server)
|
|||||||
fprintf (stderr, "LIBRARY: really reading %d data bytes (ret = %d).\n", size, ret);
|
fprintf (stderr, "LIBRARY: really reading %d data bytes (ret = %d).\n", size, ret);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!size) return NULL;
|
if (!size) return NULL;
|
||||||
|
|
||||||
ptr = g_malloc (size);
|
ptr = g_malloc (size);
|
||||||
|
|
||||||
if (server->socket) {
|
if (server->socket) {
|
||||||
ret = recv (server->socket, ptr, size, 0);
|
ret = recv (server->socket, ptr, size, 0);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
* 4. Altered versions must be plainly marked as such, and must not be
|
* 4. Altered versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software and/or documentation.
|
* misrepresented as being the original software and/or documentation.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
@@ -1,22 +1,22 @@
|
|||||||
/* -*-C-*-
|
/* -*-C-*-
|
||||||
* Server code for handling requests from clients and forwarding them
|
* Server code for handling requests from clients and forwarding them
|
||||||
* on to the GNU Emacs process.
|
* on to the GNU Emacs process.
|
||||||
*
|
*
|
||||||
* This file is part of GNU Emacs.
|
* This file is part of GNU Emacs.
|
||||||
*
|
*
|
||||||
* Copying is permitted under those conditions described by the GNU
|
* Copying is permitted under those conditions described by the GNU
|
||||||
* General Public License.
|
* General Public License.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1989 Free Software Foundation, Inc.
|
* Copyright (C) 1989 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* Author: Andy Norman (ange@hplb.hpl.hp.com), based on 'etc/server.c'
|
* Author: Andy Norman (ange@hplb.hpl.hp.com), based on 'etc/server.c'
|
||||||
* from the 18.52 GNU Emacs distribution.
|
* from the 18.52 GNU Emacs distribution.
|
||||||
*
|
*
|
||||||
* Please mail bugs and suggestions to the author at the above address.
|
* Please mail bugs and suggestions to the author at the above address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* HISTORY
|
/* HISTORY
|
||||||
* 11-Nov-1990 bristor@simba
|
* 11-Nov-1990 bristor@simba
|
||||||
* Added EOT stuff.
|
* Added EOT stuff.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -192,17 +192,17 @@ permitted (u_long host_addr, int fd)
|
|||||||
auth_protocol);
|
auth_protocol);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp (auth_protocol, MCOOKIE_NAME)) {
|
if (!strcmp (auth_protocol, MCOOKIE_NAME)) {
|
||||||
/*
|
/*
|
||||||
* doing magic cookie auth
|
* doing magic cookie auth
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (timed_read (fd, buf, 10, AUTH_TIMEOUT, 1) <= 0)
|
if (timed_read (fd, buf, 10, AUTH_TIMEOUT, 1) <= 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
auth_data_len = atoi (buf);
|
auth_data_len = atoi (buf);
|
||||||
|
|
||||||
if (auth_data_len < 1 || (size_t)auth_data_len > sizeof(buf)) {
|
if (auth_data_len < 1 || (size_t)auth_data_len > sizeof(buf)) {
|
||||||
syslog_message(LOG_WARNING, "Invalid data length supplied by client");
|
syslog_message(LOG_WARNING, "Invalid data length supplied by client");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -222,7 +222,7 @@ permitted (u_long host_addr, int fd)
|
|||||||
"not compiled with Xauth");
|
"not compiled with Xauth");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* auth failed, but allow this to fall through to the
|
* auth failed, but allow this to fall through to the
|
||||||
* GNU_SECURE protocol....
|
* GNU_SECURE protocol....
|
||||||
*/
|
*/
|
||||||
@@ -238,12 +238,12 @@ permitted (u_long host_addr, int fd)
|
|||||||
"trying GNU_SECURE auth...");
|
"trying GNU_SECURE auth...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Other auth protocols go here, and should execute only if
|
/* Other auth protocols go here, and should execute only if
|
||||||
* the * auth_protocol name matches. */
|
* the * auth_protocol name matches. */
|
||||||
|
|
||||||
/* Now, try the old GNU_SECURE stuff... */
|
/* Now, try the old GNU_SECURE stuff... */
|
||||||
|
|
||||||
if (enable_debug)
|
if (enable_debug)
|
||||||
syslog_message (LOG_DEBUG, "Doing GNU_SECURE auth ...");
|
syslog_message (LOG_DEBUG, "Doing GNU_SECURE auth ...");
|
||||||
|
|
||||||
@@ -257,7 +257,7 @@ permitted (u_long host_addr, int fd)
|
|||||||
if (host_addr == permitted_hosts [i])
|
if (host_addr == permitted_hosts [i])
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,7 +362,7 @@ internet_init (void)
|
|||||||
syslog_io_message (LOG_ERR, "unable to create socket");
|
syslog_io_message (LOG_ERR, "unable to create socket");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bind the listen address to the socket. */
|
/* Bind the listen address to the socket. */
|
||||||
if (bind (ls, (struct sockaddr *) &server,
|
if (bind (ls, (struct sockaddr *) &server,
|
||||||
sizeof (struct sockaddr_in)) == -1) {
|
sizeof (struct sockaddr_in)) == -1) {
|
||||||
@@ -433,7 +433,7 @@ handle_internet_request (int ls)
|
|||||||
|
|
||||||
close (s);
|
close (s);
|
||||||
|
|
||||||
if (verbose_output)
|
if (verbose_output)
|
||||||
syslog_message (LOG_INFO, "Closed connection to %s port %u.",
|
syslog_message (LOG_INFO, "Closed connection to %s port %u.",
|
||||||
inet_ntoa (peer.sin_addr), ntohs (peer.sin_port));
|
inet_ntoa (peer.sin_addr), ntohs (peer.sin_port));
|
||||||
|
|
||||||
@@ -477,7 +477,7 @@ main (int argc, const char **argv)
|
|||||||
/* On non-glibc systems, this is not set up for us. */
|
/* On non-glibc systems, this is not set up for us. */
|
||||||
if (!program_invocation_name) {
|
if (!program_invocation_name) {
|
||||||
char *arg;
|
char *arg;
|
||||||
|
|
||||||
program_invocation_name = (char *) argv[0];
|
program_invocation_name = (char *) argv[0];
|
||||||
arg = strrchr (argv[0], '/');
|
arg = strrchr (argv[0], '/');
|
||||||
program_invocation_short_name =
|
program_invocation_short_name =
|
||||||
@@ -533,7 +533,7 @@ main (int argc, const char **argv)
|
|||||||
* SERVER_GID. Otherwise we completely drop any priviledges.
|
* SERVER_GID. Otherwise we completely drop any priviledges.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (enable_debug)
|
if (enable_debug)
|
||||||
syslog_message (LOG_DEBUG, "Parent ID: (%d, %d) - (%d, %d)",
|
syslog_message (LOG_DEBUG, "Parent ID: (%d, %d) - (%d, %d)",
|
||||||
getuid (), geteuid (), getgid (), getegid ());
|
getuid (), geteuid (), getgid (), getegid ());
|
||||||
|
|
||||||
@@ -618,7 +618,7 @@ main (int argc, const char **argv)
|
|||||||
if (verbose_output)
|
if (verbose_output)
|
||||||
syslog_message (LOG_INFO, "Child %d exited.", ret);
|
syslog_message (LOG_INFO, "Child %d exited.", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
FD_ZERO (&rmask);
|
FD_ZERO (&rmask);
|
||||||
|
|
||||||
/* Only the child accepts connections from standard
|
/* Only the child accepts connections from standard
|
||||||
|
@@ -64,18 +64,18 @@ handle_parent_connection (int s)
|
|||||||
syslog_message (LOG_DEBUG,
|
syslog_message (LOG_DEBUG,
|
||||||
"Parent (%d) received command %d from client.",
|
"Parent (%d) received command %d from client.",
|
||||||
getpid (), (int) cmnd->command);
|
getpid (), (int) cmnd->command);
|
||||||
|
|
||||||
if (cmnd->data_size >= BUFSIZ) {
|
if (cmnd->data_size >= BUFSIZ) {
|
||||||
syslog_message (LOG_WARNING,
|
syslog_message (LOG_WARNING,
|
||||||
"Client sent %d bytes, but buffer is %d",
|
"Client sent %d bytes, but buffer is %d",
|
||||||
cmnd->data_size, BUFSIZ);
|
cmnd->data_size, BUFSIZ);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (resp, 0, sizeof (glibtop_response));
|
memset (resp, 0, sizeof (glibtop_response));
|
||||||
|
|
||||||
memset (parameter, 0, sizeof (parameter));
|
memset (parameter, 0, sizeof (parameter));
|
||||||
|
|
||||||
if (cmnd->data_size) {
|
if (cmnd->data_size) {
|
||||||
if (enable_debug)
|
if (enable_debug)
|
||||||
syslog_message (LOG_DEBUG, "Client has %d bytes of data.",
|
syslog_message (LOG_DEBUG, "Client has %d bytes of data.",
|
||||||
@@ -92,7 +92,7 @@ handle_parent_connection (int s)
|
|||||||
do_output (s, resp, 0, 0, NULL);
|
do_output (s, resp, 0, 0, NULL);
|
||||||
return;
|
return;
|
||||||
case GLIBTOP_CMND_SYSDEPS:
|
case GLIBTOP_CMND_SYSDEPS:
|
||||||
memcpy (&resp->u.sysdeps, &server->sysdeps,
|
memcpy (&resp->u.sysdeps, &server->sysdeps,
|
||||||
sizeof (glibtop_sysdeps));
|
sizeof (glibtop_sysdeps));
|
||||||
resp->u.sysdeps.features = GLIBTOP_SYSDEPS_ALL;
|
resp->u.sysdeps.features = GLIBTOP_SYSDEPS_ALL;
|
||||||
do_output (s, resp, _offset_union (sysdeps), 0, NULL);
|
do_output (s, resp, _offset_union (sysdeps), 0, NULL);
|
||||||
|
@@ -95,7 +95,7 @@ main(int argc, char *argv[])
|
|||||||
_exit (1);
|
_exit (1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glibtop_init_p (glibtop_global_server, 0, 0);
|
glibtop_init_p (glibtop_global_server, 0, 0);
|
||||||
|
|
||||||
if (setreuid (euid, uid)) _exit (1);
|
if (setreuid (euid, uid)) _exit (1);
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#define HOST_TABLE_ENTRIES 1
|
#define HOST_TABLE_ENTRIES 1
|
||||||
|
|
||||||
const char *permitted_host_names [HOST_TABLE_ENTRIES] =
|
const char *permitted_host_names [HOST_TABLE_ENTRIES] =
|
||||||
{ NULL };
|
{ NULL };
|
||||||
|
|
||||||
unsigned long permitted_hosts [HOST_TABLE_ENTRIES];
|
unsigned long permitted_hosts [HOST_TABLE_ENTRIES];
|
||||||
|
@@ -44,7 +44,7 @@ handle_slave_connection (int input, int output)
|
|||||||
fprintf (stderr, "Slave %d received command "
|
fprintf (stderr, "Slave %d received command "
|
||||||
"%d from client.\n", getpid (), cmnd->command);
|
"%d from client.\n", getpid (), cmnd->command);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (cmnd->data_size >= BUFSIZ)
|
if (cmnd->data_size >= BUFSIZ)
|
||||||
glibtop_error ("Client sent %d bytes, "
|
glibtop_error ("Client sent %d bytes, "
|
||||||
"but buffer is %d",
|
"but buffer is %d",
|
||||||
@@ -53,19 +53,19 @@ handle_slave_connection (int input, int output)
|
|||||||
memset (resp, 0, sizeof (glibtop_response));
|
memset (resp, 0, sizeof (glibtop_response));
|
||||||
|
|
||||||
memset (parameter, 0, sizeof (parameter));
|
memset (parameter, 0, sizeof (parameter));
|
||||||
|
|
||||||
if (cmnd->data_size) {
|
if (cmnd->data_size) {
|
||||||
#ifdef SLAVE_DEBUG
|
#ifdef SLAVE_DEBUG
|
||||||
fprintf (stderr, "Client has %d bytes of data.\n",
|
fprintf (stderr, "Client has %d bytes of data.\n",
|
||||||
cmnd->data_size);
|
cmnd->data_size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
do_read (input, parameter, cmnd->data_size);
|
do_read (input, parameter, cmnd->data_size);
|
||||||
|
|
||||||
} else if (cmnd->size) {
|
} else if (cmnd->size) {
|
||||||
memcpy (parameter, cmnd->parameter, cmnd->size);
|
memcpy (parameter, cmnd->parameter, cmnd->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cmnd->command) {
|
switch (cmnd->command) {
|
||||||
case GLIBTOP_CMND_QUIT:
|
case GLIBTOP_CMND_QUIT:
|
||||||
do_output (output, resp, 0, 0, NULL);
|
do_output (output, resp, 0, 0, NULL);
|
||||||
@@ -124,7 +124,7 @@ handle_slave_command (glibtop_command *cmnd, glibtop_response *resp,
|
|||||||
|
|
||||||
switch (cmnd->command) {
|
switch (cmnd->command) {
|
||||||
case GLIBTOP_CMND_SYSDEPS:
|
case GLIBTOP_CMND_SYSDEPS:
|
||||||
memcpy (&resp->u.sysdeps, &server->sysdeps,
|
memcpy (&resp->u.sysdeps, &server->sysdeps,
|
||||||
sizeof (glibtop_sysdeps));
|
sizeof (glibtop_sysdeps));
|
||||||
resp->u.sysdeps.features = glibtop_server_features;
|
resp->u.sysdeps.features = glibtop_server_features;
|
||||||
resp->u.sysdeps.flags = glibtop_server_features |
|
resp->u.sysdeps.flags = glibtop_server_features |
|
||||||
|
@@ -37,7 +37,7 @@ glibtop_send_version (glibtop *server, int fd)
|
|||||||
sizeof (glibtop_response),
|
sizeof (glibtop_response),
|
||||||
sizeof (glibtop_union),
|
sizeof (glibtop_union),
|
||||||
sizeof (glibtop_sysdeps));
|
sizeof (glibtop_sysdeps));
|
||||||
|
|
||||||
size = strlen (buffer) + 1;
|
size = strlen (buffer) + 1;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@@ -61,23 +61,23 @@ main (int argc, char *argv [])
|
|||||||
|
|
||||||
if (dirname [len-1] == '\n')
|
if (dirname [len-1] == '\n')
|
||||||
dirname [len-1] = 0;
|
dirname [len-1] = 0;
|
||||||
|
|
||||||
if (stat (dirname, &statb))
|
if (stat (dirname, &statb))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (S_ISREG (statb.st_mode)) {
|
if (S_ISREG (statb.st_mode)) {
|
||||||
glibtop_inodedb_key key;
|
glibtop_inodedb_key key;
|
||||||
datum d_key, d_content;
|
datum d_key, d_content;
|
||||||
|
|
||||||
d_key.dptr = (void *) &key;
|
d_key.dptr = (void *) &key;
|
||||||
d_key.dsize = sizeof (key);
|
d_key.dsize = sizeof (key);
|
||||||
|
|
||||||
d_content.dptr = dirname;
|
d_content.dptr = dirname;
|
||||||
d_content.dsize = strlen (dirname) + 1;
|
d_content.dsize = strlen (dirname) + 1;
|
||||||
|
|
||||||
key.device = (guint64) statb.st_dev;
|
key.device = (guint64) statb.st_dev;
|
||||||
key.inode = (guint64) statb.st_ino;
|
key.inode = (guint64) statb.st_ino;
|
||||||
|
|
||||||
if (gdbm_store (dbf, d_key, d_content, GDBM_REPLACE))
|
if (gdbm_store (dbf, d_key, d_content, GDBM_REPLACE))
|
||||||
glibtop_error_io ("gdbm_store (%s)", dirname);
|
glibtop_error_io ("gdbm_store (%s)", dirname);
|
||||||
|
|
||||||
@@ -98,9 +98,9 @@ main (int argc, char *argv [])
|
|||||||
glibtop_inodedb_key key;
|
glibtop_inodedb_key key;
|
||||||
char filename [BUFSIZ];
|
char filename [BUFSIZ];
|
||||||
datum d_key, d_content;
|
datum d_key, d_content;
|
||||||
|
|
||||||
sprintf (filename, "%s/%s", dirname, entry->d_name);
|
sprintf (filename, "%s/%s", dirname, entry->d_name);
|
||||||
|
|
||||||
if (stat (filename, &statb))
|
if (stat (filename, &statb))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -112,10 +112,10 @@ main (int argc, char *argv [])
|
|||||||
|
|
||||||
d_content.dptr = filename;
|
d_content.dptr = filename;
|
||||||
d_content.dsize = strlen (filename) + 1;
|
d_content.dsize = strlen (filename) + 1;
|
||||||
|
|
||||||
key.device = (guint64) statb.st_dev;
|
key.device = (guint64) statb.st_dev;
|
||||||
key.inode = (guint64) statb.st_ino;
|
key.inode = (guint64) statb.st_ino;
|
||||||
|
|
||||||
if (gdbm_store (dbf, d_key, d_content, GDBM_REPLACE))
|
if (gdbm_store (dbf, d_key, d_content, GDBM_REPLACE))
|
||||||
glibtop_error_io ("gdbm_store (%s)", filename);
|
glibtop_error_io ("gdbm_store (%s)", filename);
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ main (int argc, char *argv [])
|
|||||||
filename, (unsigned long) statb.st_dev,
|
filename, (unsigned long) statb.st_dev,
|
||||||
(unsigned long) statb.st_ino);
|
(unsigned long) statb.st_ino);
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir (directory);
|
closedir (directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include <utils.h>
|
#include <utils.h>
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_cpu =
|
static const unsigned long _glibtop_sysdeps_cpu =
|
||||||
(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
|
(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
|
||||||
(1L << GLIBTOP_CPU_SYS) + (1L << GLIBTOP_CPU_IDLE) +
|
(1L << GLIBTOP_CPU_SYS) + (1L << GLIBTOP_CPU_IDLE) +
|
||||||
(1L << GLIBTOP_CPU_NICE) + (1 << GLIBTOP_CPU_FREQUENCY) +
|
(1L << GLIBTOP_CPU_NICE) + (1 << GLIBTOP_CPU_FREQUENCY) +
|
||||||
@@ -80,7 +80,7 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
|
|||||||
|
|
||||||
result = _glibtop_get_kmem_info(server, server->machine.cpuinfo_offset,
|
result = _glibtop_get_kmem_info(server, server->machine.cpuinfo_offset,
|
||||||
server->machine.cpuinfo,
|
server->machine.cpuinfo,
|
||||||
_system_configuration.ncpus
|
_system_configuration.ncpus
|
||||||
* sizeof(struct cpuinfo));
|
* sizeof(struct cpuinfo));
|
||||||
|
|
||||||
if (result <= 0)
|
if (result <= 0)
|
||||||
@@ -88,7 +88,7 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
|
|||||||
glibtop_error_io_r (server, "Cannot read cpuinfo");
|
glibtop_error_io_r (server, "Cannot read cpuinfo");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->idle = 0;
|
buf->idle = 0;
|
||||||
buf->user = 0;
|
buf->user = 0;
|
||||||
buf->sys = 0;
|
buf->sys = 0;
|
||||||
@@ -97,7 +97,7 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
|
|||||||
{
|
{
|
||||||
if (cpu < GLIBTOP_NCPU)
|
if (cpu < GLIBTOP_NCPU)
|
||||||
{
|
{
|
||||||
buf->xcpu_idle[cpu] =
|
buf->xcpu_idle[cpu] =
|
||||||
server->machine.cpuinfo[cpu].cpu[CPU_IDLE];
|
server->machine.cpuinfo[cpu].cpu[CPU_IDLE];
|
||||||
buf->xcpu_user[cpu] =
|
buf->xcpu_user[cpu] =
|
||||||
server->machine.cpuinfo[cpu].cpu[CPU_USER];
|
server->machine.cpuinfo[cpu].cpu[CPU_USER];
|
||||||
@@ -119,7 +119,7 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
|
|||||||
|
|
||||||
buf->total = buf->idle + buf->user + buf->sys + buf->nice ;
|
buf->total = buf->idle + buf->user + buf->sys + buf->nice ;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->frequency = sysconf(_SC_CLK_TCK);
|
buf->frequency = sysconf(_SC_CLK_TCK);
|
||||||
buf->flags = _glibtop_sysdeps_cpu;
|
buf->flags = _glibtop_sysdeps_cpu;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This file is part of LibGTop 1.0.
|
This file is part of LibGTop 1.0.
|
||||||
|
|
||||||
Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999.
|
Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999.
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include <glibtop_suid.h>
|
#include <glibtop_suid.h>
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_loadavg =
|
static const unsigned long _glibtop_sysdeps_loadavg =
|
||||||
(1 << GLIBTOP_LOADAVG_LOADAVG);
|
(1 << GLIBTOP_LOADAVG_LOADAVG);
|
||||||
|
|
||||||
/* Init function. */
|
/* Init function. */
|
||||||
|
@@ -22,13 +22,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/vminfo.h>
|
#include <sys/vminfo.h>
|
||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/error.h>
|
#include <glibtop/error.h>
|
||||||
#include <glibtop/mem.h>
|
#include <glibtop/mem.h>
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_mem =
|
static const unsigned long _glibtop_sysdeps_mem =
|
||||||
(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) +
|
(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) +
|
||||||
(1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_LOCKED);
|
(1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_LOCKED);
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
#include <glibtop/error.h>
|
#include <glibtop/error.h>
|
||||||
#include <glibtop/msg_limits.h>
|
#include <glibtop/msg_limits.h>
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_msg_limits =
|
static const unsigned long _glibtop_sysdeps_msg_limits =
|
||||||
(1 << GLIBTOP_IPC_MSGMAX) + (1 << GLIBTOP_IPC_MSGMNB) +
|
(1 << GLIBTOP_IPC_MSGMAX) + (1 << GLIBTOP_IPC_MSGMNB) +
|
||||||
(1 << GLIBTOP_IPC_MSGMNI) + (1 << GLIBTOP_IPC_MSGTQL);
|
(1 << GLIBTOP_IPC_MSGMNI) + (1 << GLIBTOP_IPC_MSGTQL);
|
||||||
|
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_netload =
|
static const unsigned long _glibtop_sysdeps_netload =
|
||||||
(1 << GLIBTOP_NETLOAD_IF_FLAGS) + (1 << GLIBTOP_NETLOAD_MTU) +
|
(1 << GLIBTOP_NETLOAD_IF_FLAGS) + (1 << GLIBTOP_NETLOAD_MTU) +
|
||||||
(1 << GLIBTOP_NETLOAD_SUBNET) + (1 << GLIBTOP_NETLOAD_ADDRESS) +
|
(1 << GLIBTOP_NETLOAD_SUBNET) + (1 << GLIBTOP_NETLOAD_ADDRESS) +
|
||||||
(1 << GLIBTOP_NETLOAD_PACKETS_IN) + (1 << GLIBTOP_NETLOAD_PACKETS_OUT) +
|
(1 << GLIBTOP_NETLOAD_PACKETS_IN) + (1 << GLIBTOP_NETLOAD_PACKETS_OUT) +
|
||||||
@@ -182,7 +182,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
|||||||
buf->if_flags |= (1 << GLIBTOP_IF_FLAGS_MULTICAST);
|
buf->if_flags |= (1 << GLIBTOP_IF_FLAGS_MULTICAST);
|
||||||
|
|
||||||
buf->mtu = ifnet.if_mtu;
|
buf->mtu = ifnet.if_mtu;
|
||||||
|
|
||||||
get_ifaddr(server, ifnet.if_addrlist, &addr, &mask);
|
get_ifaddr(server, ifnet.if_addrlist, &addr, &mask);
|
||||||
|
|
||||||
buf->subnet = addr & mask;
|
buf->subnet = addr & mask;
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_proc_args =
|
static const unsigned long _glibtop_sysdeps_proc_args =
|
||||||
(1 << GLIBTOP_PROC_ARGS_SIZE);
|
(1 << GLIBTOP_PROC_ARGS_SIZE);
|
||||||
|
|
||||||
/* Init function. */
|
/* Init function. */
|
||||||
@@ -71,7 +71,7 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = max_len != 0 ? max_len : 4096;
|
size = max_len != 0 ? max_len : 4096;
|
||||||
args_buffer = g_malloc (size);
|
args_buffer = g_malloc (size);
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/proclist.h>
|
#include <glibtop/proclist.h>
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_proclist =
|
static const unsigned long _glibtop_sysdeps_proclist =
|
||||||
(1 << GLIBTOP_PROCLIST_NUMBER) + (1 << GLIBTOP_PROCLIST_TOTAL) +
|
(1 << GLIBTOP_PROCLIST_NUMBER) + (1 << GLIBTOP_PROCLIST_TOTAL) +
|
||||||
(1 << GLIBTOP_PROCLIST_SIZE);
|
(1 << GLIBTOP_PROCLIST_SIZE);
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GLIBTOP_KERN_PROC_PGRP:
|
case GLIBTOP_KERN_PROC_PGRP:
|
||||||
@@ -184,7 +184,7 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count >= BLOCK_COUNT)
|
if (count >= BLOCK_COUNT)
|
||||||
{
|
{
|
||||||
/* The following call to g_realloc will be
|
/* The following call to g_realloc will be
|
||||||
|
@@ -42,8 +42,8 @@ glibtop_map_entry *
|
|||||||
glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
||||||
{
|
{
|
||||||
glibtop_init_p (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0);
|
glibtop_init_p (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_map));
|
memset (buf, 0, sizeof (glibtop_proc_map));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -31,9 +31,9 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_proc_mem =
|
static const unsigned long _glibtop_sysdeps_proc_mem =
|
||||||
(1 << GLIBTOP_PROC_MEM_SIZE) + (1 << GLIBTOP_PROC_MEM_VSIZE) +
|
(1 << GLIBTOP_PROC_MEM_SIZE) + (1 << GLIBTOP_PROC_MEM_VSIZE) +
|
||||||
(1 << GLIBTOP_PROC_MEM_RESIDENT) + (1 << GLIBTOP_PROC_MEM_RSS) +
|
(1 << GLIBTOP_PROC_MEM_RESIDENT) + (1 << GLIBTOP_PROC_MEM_RSS) +
|
||||||
(1 << GLIBTOP_PROC_MEM_RSS_RLIM);
|
(1 << GLIBTOP_PROC_MEM_RSS_RLIM);
|
||||||
|
|
||||||
/* Init function. */
|
/* Init function. */
|
||||||
@@ -62,7 +62,7 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf,
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pagesize = sysconf(_SC_PAGESIZE);
|
pagesize = sysconf(_SC_PAGESIZE);
|
||||||
|
|
||||||
buf->vsize = buf->size = pinfo->pi_size * pagesize;
|
buf->vsize = buf->size = pinfo->pi_size * pagesize;
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_proc_segment =
|
static const unsigned long _glibtop_sysdeps_proc_segment =
|
||||||
(1 << GLIBTOP_PROC_SEGMENT_TEXT_RSS) + (1 << GLIBTOP_PROC_SEGMENT_SHLIB_RSS) +
|
(1 << GLIBTOP_PROC_SEGMENT_TEXT_RSS) + (1 << GLIBTOP_PROC_SEGMENT_SHLIB_RSS) +
|
||||||
(1 << GLIBTOP_PROC_SEGMENT_DATA_RSS) + (1 << GLIBTOP_PROC_SEGMENT_STACK_RSS);
|
(1 << GLIBTOP_PROC_SEGMENT_DATA_RSS) + (1 << GLIBTOP_PROC_SEGMENT_STACK_RSS);
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_proc_signal =
|
static const unsigned long _glibtop_sysdeps_proc_signal =
|
||||||
(1 <<GLIBTOP_PROC_SIGNAL_SIGNAL) + (1 <<GLIBTOP_PROC_SIGNAL_BLOCKED) +
|
(1 <<GLIBTOP_PROC_SIGNAL_SIGNAL) + (1 <<GLIBTOP_PROC_SIGNAL_BLOCKED) +
|
||||||
(1 <<GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1 <<GLIBTOP_PROC_SIGNAL_SIGCATCH);
|
(1 <<GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1 <<GLIBTOP_PROC_SIGNAL_SIGCATCH);
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf,
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pending signals */
|
/* pending signals */
|
||||||
|
|
||||||
#define NB_BITS (8 * sizeof(guint64))
|
#define NB_BITS (8 * sizeof(guint64))
|
||||||
@@ -84,6 +84,6 @@ glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf,
|
|||||||
if (pinfo->pi_signal[i] == (long)SIG_CATCH)
|
if (pinfo->pi_signal[i] == (long)SIG_CATCH)
|
||||||
buf->sigcatch[i / NB_BITS] |= bit;
|
buf->sigcatch[i / NB_BITS] |= bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->flags = _glibtop_sysdeps_proc_signal;
|
buf->flags = _glibtop_sysdeps_proc_signal;
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_proc_state =
|
static const unsigned long _glibtop_sysdeps_proc_state =
|
||||||
(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_STATE) +
|
(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_STATE) +
|
||||||
(1 << GLIBTOP_PROC_STATE_UID) + (1 << GLIBTOP_PROC_STATE_GID);
|
(1 << GLIBTOP_PROC_STATE_UID) + (1 << GLIBTOP_PROC_STATE_GID);
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf,
|
|||||||
|
|
||||||
buf->uid = pinfo->pi_uid;
|
buf->uid = pinfo->pi_uid;
|
||||||
buf->gid = pinfo->pi_cred.cr_gid;
|
buf->gid = pinfo->pi_cred.cr_gid;
|
||||||
|
|
||||||
if (pinfo->pi_state == SZOMB)
|
if (pinfo->pi_state == SZOMB)
|
||||||
{
|
{
|
||||||
buf->state = 'Z';
|
buf->state = 'Z';
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_proc_uid =
|
static const unsigned long _glibtop_sysdeps_proc_uid =
|
||||||
(1 << GLIBTOP_PROC_UID_UID) + (1 << GLIBTOP_PROC_UID_EUID) +
|
(1 << GLIBTOP_PROC_UID_UID) + (1 << GLIBTOP_PROC_UID_EUID) +
|
||||||
(1 << GLIBTOP_PROC_UID_GID) + (1 << GLIBTOP_PROC_UID_EGID) +
|
(1 << GLIBTOP_PROC_UID_GID) + (1 << GLIBTOP_PROC_UID_EGID) +
|
||||||
(1 << GLIBTOP_PROC_UID_PID) + (1 << GLIBTOP_PROC_UID_PPID) +
|
(1 << GLIBTOP_PROC_UID_PID) + (1 << GLIBTOP_PROC_UID_PPID) +
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_sem_limits =
|
static const unsigned long _glibtop_sysdeps_sem_limits =
|
||||||
(1 << GLIBTOP_IPC_SEMMNI) + (1 << GLIBTOP_IPC_SEMMSL) +
|
(1 << GLIBTOP_IPC_SEMMNI) + (1 << GLIBTOP_IPC_SEMMSL) +
|
||||||
(1 << GLIBTOP_IPC_SEMOPM) + (1 << GLIBTOP_IPC_SEMUME) +
|
(1 << GLIBTOP_IPC_SEMOPM) + (1 << GLIBTOP_IPC_SEMUME) +
|
||||||
(1 << GLIBTOP_IPC_SEMUSZ) + (1 << GLIBTOP_IPC_SEMVMX) +
|
(1 << GLIBTOP_IPC_SEMUSZ) + (1 << GLIBTOP_IPC_SEMVMX) +
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
#include <glibtop/error.h>
|
#include <glibtop/error.h>
|
||||||
#include <glibtop/shm_limits.h>
|
#include <glibtop/shm_limits.h>
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_shm_limits =
|
static const unsigned long _glibtop_sysdeps_shm_limits =
|
||||||
(1L << GLIBTOP_IPC_SHMMAX) + (1L << GLIBTOP_IPC_SHMMIN) +
|
(1L << GLIBTOP_IPC_SHMMAX) + (1L << GLIBTOP_IPC_SHMMIN) +
|
||||||
(1L << GLIBTOP_IPC_SHMMNI);
|
(1L << GLIBTOP_IPC_SHMMNI);
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
#include <glibtop/error.h>
|
#include <glibtop/error.h>
|
||||||
#include <glibtop/swap.h>
|
#include <glibtop/swap.h>
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_swap =
|
static const unsigned long _glibtop_sysdeps_swap =
|
||||||
(1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) +
|
(1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) +
|
||||||
(1 << GLIBTOP_SWAP_FREE) + (1 << GLIBTOP_SWAP_PAGEIN) +
|
(1 << GLIBTOP_SWAP_FREE) + (1 << GLIBTOP_SWAP_PAGEIN) +
|
||||||
(1 << GLIBTOP_SWAP_PAGEOUT);
|
(1 << GLIBTOP_SWAP_PAGEOUT);
|
||||||
|
@@ -164,7 +164,7 @@ static void init_sysinfo(void)
|
|||||||
if (_system_configuration.cache_attrib & (1 << 31))
|
if (_system_configuration.cache_attrib & (1 << 31))
|
||||||
{
|
{
|
||||||
/* L1 cache is present */
|
/* L1 cache is present */
|
||||||
|
|
||||||
sprintf(buf,"%d", _system_configuration.icache_size);
|
sprintf(buf,"%d", _system_configuration.icache_size);
|
||||||
add_info( &sysinfo.cpuinfo[cpu], "L1 instruction cache size", buf);
|
add_info( &sysinfo.cpuinfo[cpu], "L1 instruction cache size", buf);
|
||||||
|
|
||||||
|
@@ -54,7 +54,7 @@ glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
|
|||||||
glibtop_cpu cpu;
|
glibtop_cpu cpu;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_uptime));
|
memset (buf, 0, sizeof (glibtop_uptime));
|
||||||
|
|
||||||
/* We simply calculate it from the CPU usage. */
|
/* We simply calculate it from the CPU usage. */
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This file is part of LibGTop 1.0.
|
This file is part of LibGTop 1.0.
|
||||||
|
|
||||||
Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999.
|
Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999.
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
extern off_t
|
extern off_t
|
||||||
_glibtop_get_kmem_offset(glibtop* server, char* kname);
|
_glibtop_get_kmem_offset(glibtop* server, char* kname);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
static void
|
static void
|
||||||
print_server_name (glibtop *server)
|
print_server_name (glibtop *server)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: ", server ?
|
fprintf (stderr, "%s: ", server ?
|
||||||
(server->name ? server->name : DEFAULT_NAME)
|
(server->name ? server->name : DEFAULT_NAME)
|
||||||
: DEFAULT_NAME);
|
: DEFAULT_NAME);
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ print_server_name (glibtop *server)
|
|||||||
void
|
void
|
||||||
glibtop_error_vr (glibtop *server, char *format, va_list args)
|
glibtop_error_vr (glibtop *server, char *format, va_list args)
|
||||||
{
|
{
|
||||||
print_server_name (server);
|
print_server_name (server);
|
||||||
vfprintf (stderr, format, args);
|
vfprintf (stderr, format, args);
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
static void
|
static void
|
||||||
print_server_name (glibtop_server *server)
|
print_server_name (glibtop_server *server)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: ", server ?
|
fprintf (stderr, "%s: ", server ?
|
||||||
(server->name ? server->name : DEFAULT_NAME)
|
(server->name ? server->name : DEFAULT_NAME)
|
||||||
: DEFAULT_NAME);
|
: DEFAULT_NAME);
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ print_server_name (glibtop_server *server)
|
|||||||
void
|
void
|
||||||
glibtop_error_vr (glibtop_server *server, char *format, va_list args)
|
glibtop_error_vr (glibtop_server *server, char *format, va_list args)
|
||||||
{
|
{
|
||||||
print_server_name (server);
|
print_server_name (server);
|
||||||
vfprintf (stderr, format, args);
|
vfprintf (stderr, format, args);
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* fsusage-frontend.c -- return space usage of mounted filesystems.
|
/* fsusage-frontend.c -- return space usage of mounted filesystems.
|
||||||
|
|
||||||
Copyright (C) 2003 Ole Laursen.
|
Copyright (C) 2003 Ole Laursen.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
@@ -51,10 +51,10 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf,
|
|||||||
struct fs_usage fsp;
|
struct fs_usage fsp;
|
||||||
|
|
||||||
glibtop_init_r (&server, 0, 0);
|
glibtop_init_r (&server, 0, 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_fsusage));
|
memset (buf, 0, sizeof (glibtop_fsusage));
|
||||||
memset (&fsp, 0, sizeof (struct fs_usage));
|
memset (&fsp, 0, sizeof (struct fs_usage));
|
||||||
|
|
||||||
if (glibtop_private_get_fs_usage (disk, disk, &fsp) != 0)
|
if (glibtop_private_get_fs_usage (disk, disk, &fsp) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -1,22 +1,22 @@
|
|||||||
/* -*-C-*-
|
/* -*-C-*-
|
||||||
* Common library code for the GNU Emacs server and client.
|
* Common library code for the GNU Emacs server and client.
|
||||||
*
|
*
|
||||||
* This file is part of GNU Emacs.
|
* This file is part of GNU Emacs.
|
||||||
*
|
*
|
||||||
* Copying is permitted under those conditions described by the GNU
|
* Copying is permitted under those conditions described by the GNU
|
||||||
* General Public License.
|
* General Public License.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1989 Free Software Foundation, Inc.
|
* Copyright (C) 1989 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* Author: Andy Norman (ange@hplb.hpl.hp.com), based on
|
* Author: Andy Norman (ange@hplb.hpl.hp.com), based on
|
||||||
* 'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
|
* 'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
|
||||||
* Emacs distribution.
|
* Emacs distribution.
|
||||||
*
|
*
|
||||||
* Please mail bugs and suggestions to the author at the above address.
|
* Please mail bugs and suggestions to the author at the above address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* HISTORY
|
/* HISTORY
|
||||||
* 11-Nov-1990 bristor@simba
|
* 11-Nov-1990 bristor@simba
|
||||||
* Added EOT stuff.
|
* Added EOT stuff.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ connect_to_unix_server (void)
|
|||||||
* internet_addr -- return the internet addr of the hostname or
|
* internet_addr -- return the internet addr of the hostname or
|
||||||
* internet address passed. Return -1 on error.
|
* internet address passed. Return -1 on error.
|
||||||
*/
|
*/
|
||||||
long
|
long
|
||||||
glibtop_internet_addr (host)
|
glibtop_internet_addr (host)
|
||||||
const char *host;
|
const char *host;
|
||||||
{
|
{
|
||||||
@@ -228,7 +228,7 @@ static Xauth *server_xauth = NULL;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* connect_to_internet_server -- establish connection with server process via
|
* connect_to_internet_server -- establish connection with server process via
|
||||||
* an internet domain socket. Returns socket
|
* an internet domain socket. Returns socket
|
||||||
* descriptor for server if successful.
|
* descriptor for server if successful.
|
||||||
*/
|
*/
|
||||||
@@ -257,7 +257,7 @@ connect_to_internet_server (const char *serverhost, u_short port)
|
|||||||
else
|
else
|
||||||
peeraddr_in.sin_port = sp->s_port;
|
peeraddr_in.sin_port = sp->s_port;
|
||||||
}
|
}
|
||||||
/* if */
|
/* if */
|
||||||
else
|
else
|
||||||
peeraddr_in.sin_port = htons (port);
|
peeraddr_in.sin_port = htons (port);
|
||||||
|
|
||||||
@@ -326,7 +326,7 @@ disconnect_from_server (s, echo)
|
|||||||
send_string (s, EOT_STR); /* make sure server gets string */
|
send_string (s, EOT_STR); /* make sure server gets string */
|
||||||
|
|
||||||
#if !defined (linux) && !defined (_SCO_DS)
|
#if !defined (linux) && !defined (_SCO_DS)
|
||||||
/*
|
/*
|
||||||
* shutdown is completely hozed under linux. If s is a unix domain socket,
|
* shutdown is completely hozed under linux. If s is a unix domain socket,
|
||||||
* you'll get EOPNOTSUPP back from it. If s is an internet socket, you get
|
* you'll get EOPNOTSUPP back from it. If s is an internet socket, you get
|
||||||
* a broken pipe when you try to read a bit later. The latter
|
* a broken pipe when you try to read a bit later. The latter
|
||||||
|
@@ -59,9 +59,9 @@ glibtop_inodedb_open_s (glibtop *server, unsigned databases,
|
|||||||
|
|
||||||
pwd = getpwuid (getuid ());
|
pwd = getpwuid (getuid ());
|
||||||
if (!pwd) glibtop_error_io_r (server, "getpwuid");
|
if (!pwd) glibtop_error_io_r (server, "getpwuid");
|
||||||
|
|
||||||
sprintf (filename, "%s/var/libgtop/inodedb.db", pwd->pw_dir);
|
sprintf (filename, "%s/var/libgtop/inodedb.db", pwd->pw_dir);
|
||||||
|
|
||||||
if (stat (filename, &statb))
|
if (stat (filename, &statb))
|
||||||
databases &= ~GLIBTOP_INODEDB_USER;
|
databases &= ~GLIBTOP_INODEDB_USER;
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ glibtop_inodedb_close_s (glibtop *server, glibtop_inodedb *inodedb)
|
|||||||
{
|
{
|
||||||
if (inodedb->system_dbf)
|
if (inodedb->system_dbf)
|
||||||
gdbm_close (inodedb->system_dbf);
|
gdbm_close (inodedb->system_dbf);
|
||||||
|
|
||||||
if (inodedb->user_dbf)
|
if (inodedb->user_dbf)
|
||||||
gdbm_close (inodedb->user_dbf);
|
gdbm_close (inodedb->user_dbf);
|
||||||
|
|
||||||
|
@@ -605,7 +605,7 @@ glibtop_get_mountlist_s (glibtop *server, glibtop_mountlist *buf, int all_fs)
|
|||||||
|
|
||||||
for (count = 0, tmp = me; tmp; count++, tmp = next) {
|
for (count = 0, tmp = me; tmp; count++, tmp = next) {
|
||||||
|
|
||||||
g_strlcpy (mount_list [count].devname, tmp->me_devname,
|
g_strlcpy (mount_list [count].devname, tmp->me_devname,
|
||||||
GLIBTOP_MOUNTENTRY_LEN);
|
GLIBTOP_MOUNTENTRY_LEN);
|
||||||
g_strlcpy (mount_list [count].mountdir, tmp->me_mountdir,
|
g_strlcpy (mount_list [count].mountdir, tmp->me_mountdir,
|
||||||
GLIBTOP_MOUNTENTRY_LEN);
|
GLIBTOP_MOUNTENTRY_LEN);
|
||||||
|
@@ -84,9 +84,9 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
|
|||||||
/* sysctl vars*/
|
/* sysctl vars*/
|
||||||
struct clockinfo ci;
|
struct clockinfo ci;
|
||||||
size_t length;
|
size_t length;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_CPU), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_CPU), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_cpu));
|
memset (buf, 0, sizeof (glibtop_cpu));
|
||||||
|
|
||||||
/* If this fails, the nlist may not be valid. */
|
/* If this fails, the nlist may not be valid. */
|
||||||
@@ -106,7 +106,7 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Get the clockrate data */
|
/* Get the clockrate data */
|
||||||
length = sizeof (struct clockinfo);
|
length = sizeof (struct clockinfo);
|
||||||
if (sysctl (mib, mib_length, &ci, &length, NULL, 0)) {
|
if (sysctl (mib, mib_length, &ci, &length, NULL, 0)) {
|
||||||
@@ -122,12 +122,12 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
|
|||||||
buf->sys = cpts [CP_SYS];
|
buf->sys = cpts [CP_SYS];
|
||||||
/* set idle time */
|
/* set idle time */
|
||||||
buf->idle = cpts [CP_IDLE];
|
buf->idle = cpts [CP_IDLE];
|
||||||
|
|
||||||
/* set frequency */
|
/* set frequency */
|
||||||
/*
|
/*
|
||||||
FIXME -- is hz, tick, profhz or stathz wanted?
|
FIXME -- is hz, tick, profhz or stathz wanted?
|
||||||
buf->frequency = sysctl("kern.clockrate", ...);
|
buf->frequency = sysctl("kern.clockrate", ...);
|
||||||
|
|
||||||
struct clockinfo
|
struct clockinfo
|
||||||
*/
|
*/
|
||||||
buf->frequency = ci.hz;
|
buf->frequency = ci.hz;
|
||||||
|
@@ -55,7 +55,7 @@ struct _glibtop_machine
|
|||||||
{
|
{
|
||||||
uid_t uid, euid;
|
uid_t uid, euid;
|
||||||
gid_t gid, egid;
|
gid_t gid, egid;
|
||||||
|
|
||||||
/* The kernel descriptor, used by kvm_* calls. We keep and re-use
|
/* The kernel descriptor, used by kvm_* calls. We keep and re-use
|
||||||
* it rather than re-getting it for almost all function
|
* it rather than re-getting it for almost all function
|
||||||
* invocations. */
|
* invocations. */
|
||||||
|
@@ -40,6 +40,6 @@ glibtop_init_r (glibtop **server,
|
|||||||
glibtop_open (glibtop_global_server, "glibtop",
|
glibtop_open (glibtop_global_server, "glibtop",
|
||||||
features, flags);
|
features, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
return *server = glibtop_global_server;
|
return *server = glibtop_global_server;
|
||||||
}
|
}
|
||||||
|
@@ -43,15 +43,15 @@ glibtop_init_loadavg_p (glibtop *server)
|
|||||||
void
|
void
|
||||||
glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf)
|
glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf)
|
||||||
{
|
{
|
||||||
double ldavg[3];
|
double ldavg[3];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_LOADAVG), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_LOADAVG), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_loadavg));
|
memset (buf, 0, sizeof (glibtop_loadavg));
|
||||||
|
|
||||||
getloadavg (ldavg, 3);
|
getloadavg (ldavg, 3);
|
||||||
|
|
||||||
/* fill in the struct */
|
/* fill in the struct */
|
||||||
buf->flags = _glibtop_sysdeps_loadavg;
|
buf->flags = _glibtop_sysdeps_loadavg;
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
|
@@ -130,7 +130,7 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
|
|||||||
int bufspace;
|
int bufspace;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MEM), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MEM), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_mem));
|
memset (buf, 0, sizeof (glibtop_mem));
|
||||||
|
|
||||||
if (server->sysdeps.mem == 0)
|
if (server->sysdeps.mem == 0)
|
||||||
@@ -167,7 +167,7 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
|
|||||||
glibtop_warn_io_r (server, "kvm_read (bufspace)");
|
glibtop_warn_io_r (server, "kvm_read (bufspace)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert memory stats to Kbytes */
|
/* convert memory stats to Kbytes */
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
|
@@ -64,7 +64,7 @@ static const unsigned long _glibtop_sysdeps_msg_limits =
|
|||||||
* read it once during initialization. We have to use the name `_msginfo'
|
* read it once during initialization. We have to use the name `_msginfo'
|
||||||
* since `msginfo' is already declared external in <sys/msg.h>. */
|
* since `msginfo' is already declared external in <sys/msg.h>. */
|
||||||
static struct msginfo _msginfo;
|
static struct msginfo _msginfo;
|
||||||
|
|
||||||
/* nlist structure for kernel access */
|
/* nlist structure for kernel access */
|
||||||
static struct nlist nlst [] = {
|
static struct nlist nlst [] = {
|
||||||
{ "_msginfo" },
|
{ "_msginfo" },
|
||||||
@@ -80,7 +80,7 @@ glibtop_init_msg_limits_p (glibtop *server)
|
|||||||
glibtop_warn_io_r (server, "kvm_nlist (msg_limits)");
|
glibtop_warn_io_r (server, "kvm_nlist (msg_limits)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kvm_read (server->machine.kd, nlst [0].n_value,
|
if (kvm_read (server->machine.kd, nlst [0].n_value,
|
||||||
&_msginfo, sizeof (_msginfo)) != sizeof (_msginfo)) {
|
&_msginfo, sizeof (_msginfo)) != sizeof (_msginfo)) {
|
||||||
glibtop_warn_io_r (server, "kvm_read (msginfo)");
|
glibtop_warn_io_r (server, "kvm_read (msginfo)");
|
||||||
@@ -96,7 +96,7 @@ void
|
|||||||
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
|
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
|
||||||
{
|
{
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_msg_limits));
|
memset (buf, 0, sizeof (glibtop_msg_limits));
|
||||||
|
|
||||||
if (server->sysdeps.msg_limits == 0)
|
if (server->sysdeps.msg_limits == 0)
|
||||||
@@ -107,8 +107,8 @@ glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
|
|||||||
buf->msgmnb = _msginfo.msgmnb;
|
buf->msgmnb = _msginfo.msgmnb;
|
||||||
buf->msgtql = _msginfo.msgtql;
|
buf->msgtql = _msginfo.msgtql;
|
||||||
buf->msgssz = _msginfo.msgtql;
|
buf->msgssz = _msginfo.msgtql;
|
||||||
|
|
||||||
buf->flags = _glibtop_sysdeps_msg_limits;
|
buf->flags = _glibtop_sysdeps_msg_limits;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* either a newer BSDI or no BSDI at all. */
|
#endif /* either a newer BSDI or no BSDI at all. */
|
||||||
|
@@ -89,15 +89,15 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
|||||||
struct ifaddr ifa;
|
struct ifaddr ifa;
|
||||||
struct in_ifaddr in;
|
struct in_ifaddr in;
|
||||||
} ifaddr;
|
} ifaddr;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_NETLOAD), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_NETLOAD), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_netload));
|
memset (buf, 0, sizeof (glibtop_netload));
|
||||||
|
|
||||||
if (kvm_read (server->machine.kd, nlst [0].n_value,
|
if (kvm_read (server->machine.kd, nlst [0].n_value,
|
||||||
&ifnetaddr, sizeof (ifnetaddr)) != sizeof (ifnetaddr))
|
&ifnetaddr, sizeof (ifnetaddr)) != sizeof (ifnetaddr))
|
||||||
glibtop_error_io_r (server, "kvm_read (ifnet)");
|
glibtop_error_io_r (server, "kvm_read (ifnet)");
|
||||||
|
|
||||||
ifaddraddr = 0;
|
ifaddraddr = 0;
|
||||||
while (ifnetaddr || ifaddraddr) {
|
while (ifnetaddr || ifaddraddr) {
|
||||||
struct sockaddr_in *sin;
|
struct sockaddr_in *sin;
|
||||||
@@ -134,11 +134,11 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
|||||||
if ((kvm_read (server->machine.kd, ifaddraddr, &ifaddr,
|
if ((kvm_read (server->machine.kd, ifaddraddr, &ifaddr,
|
||||||
sizeof (ifaddr)) != sizeof (ifaddr)))
|
sizeof (ifaddr)) != sizeof (ifaddr)))
|
||||||
glibtop_error_io_r (server, "kvm_read (ifaddraddr)");
|
glibtop_error_io_r (server, "kvm_read (ifaddraddr)");
|
||||||
|
|
||||||
#define CP(x) ((char *)(x))
|
#define CP(x) ((char *)(x))
|
||||||
cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) +
|
cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) +
|
||||||
CP(&ifaddr); sa = (struct sockaddr *)cp;
|
CP(&ifaddr); sa = (struct sockaddr *)cp;
|
||||||
|
|
||||||
if (!strcmp (interface, tname) && (sa->sa_family == AF_INET)) {
|
if (!strcmp (interface, tname) && (sa->sa_family == AF_INET)) {
|
||||||
sin = (struct sockaddr_in *)sa;
|
sin = (struct sockaddr_in *)sa;
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
|||||||
ifaddraddr = (u_long)ifaddr.ifa.ifa_list.tqe_next;
|
ifaddraddr = (u_long)ifaddr.ifa.ifa_list.tqe_next;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000)
|
#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||||
ifnetaddr = (u_long) ifnet.if_link.tqe_next;
|
ifnetaddr = (u_long) ifnet.if_link.tqe_next;
|
||||||
#elif defined(__FreeBSD__) || defined(__bsdi__)
|
#elif defined(__FreeBSD__) || defined(__bsdi__)
|
||||||
|
@@ -42,7 +42,7 @@ glibtop_init_p (glibtop *server, const unsigned long features,
|
|||||||
|
|
||||||
for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
|
for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
|
||||||
(*init_fkt) (server);
|
(*init_fkt) (server);
|
||||||
|
|
||||||
server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
|
server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ glibtop_open_p (glibtop *server, const char *program_name,
|
|||||||
const unsigned flags)
|
const unsigned flags)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf (stderr, "DEBUG (%d): glibtop_open_p ()\n", getpid ());
|
fprintf (stderr, "DEBUG (%d): glibtop_open_p ()\n", getpid ());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
|
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
|
||||||
@@ -66,23 +66,23 @@ glibtop_open_p (glibtop *server, const char *program_name,
|
|||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
server->os_version_code = __FreeBSD_version;
|
server->os_version_code = __FreeBSD_version;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Setup machine-specific data */
|
/* Setup machine-specific data */
|
||||||
server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "kvm_open");
|
server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "kvm_open");
|
||||||
|
|
||||||
if (server->machine.kd == NULL)
|
if (server->machine.kd == NULL)
|
||||||
glibtop_error_io_r (server, "kvm_open");
|
glibtop_error_io_r (server, "kvm_open");
|
||||||
|
|
||||||
/* Drop priviledges. */
|
/* Drop priviledges. */
|
||||||
|
|
||||||
if (setreuid (server->machine.euid, server->machine.uid))
|
if (setreuid (server->machine.euid, server->machine.uid))
|
||||||
_exit (1);
|
_exit (1);
|
||||||
|
|
||||||
if (setregid (server->machine.egid, server->machine.gid))
|
if (setregid (server->machine.egid, server->machine.gid))
|
||||||
_exit (1);
|
_exit (1);
|
||||||
|
|
||||||
/* !!! END OF SUID ROOT PART !!! */
|
/* !!! END OF SUID ROOT PART !!! */
|
||||||
|
|
||||||
/* Our effective uid is now those of the user invoking the server,
|
/* Our effective uid is now those of the user invoking the server,
|
||||||
* so we do no longer have any priviledges. */
|
* so we do no longer have any priviledges. */
|
||||||
|
|
||||||
|
@@ -100,7 +100,7 @@ glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device)
|
|||||||
int phase;
|
int phase;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PPP), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PPP), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_ppp));
|
memset (buf, 0, sizeof (glibtop_ppp));
|
||||||
|
|
||||||
if (kvm_read (server->machine.kd, nlst [0].n_value,
|
if (kvm_read (server->machine.kd, nlst [0].n_value,
|
||||||
|
@@ -59,7 +59,7 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_ARGS), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_ARGS), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_args));
|
memset (buf, 0, sizeof (glibtop_proc_args));
|
||||||
|
|
||||||
/* swapper, init, pagedaemon, vmdaemon, update - this doen't work. */
|
/* swapper, init, pagedaemon, vmdaemon, update - this doen't work. */
|
||||||
|
@@ -85,9 +85,9 @@ glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid)
|
|||||||
struct stat statb;
|
struct stat statb;
|
||||||
int nread;
|
int nread;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
glibtop_init_r (&server, 0, 0);
|
glibtop_init_r (&server, 0, 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_procdata));
|
memset (buf, 0, sizeof (glibtop_procdata));
|
||||||
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
@@ -97,27 +97,27 @@ glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sprintf (input, "/proc/%d/stat", pid);
|
sprintf (input, "/proc/%d/stat", pid);
|
||||||
|
|
||||||
if (stat (input, &statb)) return;
|
if (stat (input, &statb)) return;
|
||||||
|
|
||||||
buf->uid = statb.st_uid;
|
buf->uid = statb.st_uid;
|
||||||
|
|
||||||
f = fopen (input, "r");
|
f = fopen (input, "r");
|
||||||
if (!f) return;
|
if (!f) return;
|
||||||
|
|
||||||
nread = fread (input, 1, BUFSIZ, f);
|
nread = fread (input, 1, BUFSIZ, f);
|
||||||
|
|
||||||
if (nread < 0) {
|
if (nread < 0) {
|
||||||
fclose (f);
|
fclose (f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
input [nread] = 0;
|
input [nread] = 0;
|
||||||
|
|
||||||
/* This is from guile-utils/gtop/proc/readproc.c */
|
/* This is from guile-utils/gtop/proc/readproc.c */
|
||||||
|
|
||||||
/* split into "PID (cmd" and "<rest>" */
|
/* split into "PID (cmd" and "<rest>" */
|
||||||
tmp = strrchr (input, ')');
|
tmp = strrchr (input, ')');
|
||||||
*tmp = '\0'; /* replace trailing ')' with NUL */
|
*tmp = '\0'; /* replace trailing ')' with NUL */
|
||||||
@@ -142,7 +142,7 @@ glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid)
|
|||||||
if (buf->tty == 0)
|
if (buf->tty == 0)
|
||||||
/* the old notty val, update elsewhere bef. moving to 0 */
|
/* the old notty val, update elsewhere bef. moving to 0 */
|
||||||
buf->tty = -1;
|
buf->tty = -1;
|
||||||
|
|
||||||
fclose (f);
|
fclose (f);
|
||||||
|
|
||||||
sprintf (input, "/proc/%d/statm", pid);
|
sprintf (input, "/proc/%d/statm", pid);
|
||||||
|
@@ -104,7 +104,7 @@ glibtop_get_proc_kernel_p (glibtop *server,
|
|||||||
struct stat statb;
|
struct stat statb;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_kernel));
|
memset (buf, 0, sizeof (glibtop_proc_kernel));
|
||||||
|
|
||||||
if (server->sysdeps.proc_time == 0)
|
if (server->sysdeps.proc_time == 0)
|
||||||
@@ -112,7 +112,7 @@ glibtop_get_proc_kernel_p (glibtop *server,
|
|||||||
|
|
||||||
/* It does not work for the swapper task. */
|
/* It does not work for the swapper task. */
|
||||||
if (pid == 0) return;
|
if (pid == 0) return;
|
||||||
|
|
||||||
/* Get the process information */
|
/* Get the process information */
|
||||||
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
||||||
if ((pinfo == NULL) || (count != 1))
|
if ((pinfo == NULL) || (count != 1))
|
||||||
@@ -189,7 +189,7 @@ glibtop_get_proc_kernel_p (glibtop *server,
|
|||||||
buf->maj_flt = (guint64) pstats.p_ru.ru_majflt;
|
buf->maj_flt = (guint64) pstats.p_ru.ru_majflt;
|
||||||
buf->cmin_flt = (guint64) pstats.p_cru.ru_minflt;
|
buf->cmin_flt = (guint64) pstats.p_cru.ru_minflt;
|
||||||
buf->cmaj_flt = (guint64) pstats.p_cru.ru_majflt;
|
buf->cmaj_flt = (guint64) pstats.p_cru.ru_majflt;
|
||||||
|
|
||||||
buf->flags |= _glibtop_sysdeps_proc_kernel_pstats;
|
buf->flags |= _glibtop_sysdeps_proc_kernel_pstats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -67,7 +67,7 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
|
|||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proclist));
|
memset (buf, 0, sizeof (glibtop_proclist));
|
||||||
|
|
||||||
which = (int)(real_which & GLIBTOP_KERN_PROC_MASK);
|
which = (int)(real_which & GLIBTOP_KERN_PROC_MASK);
|
||||||
|
@@ -112,12 +112,12 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
|||||||
int update = 0;
|
int update = 0;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MAP), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MAP), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_map));
|
memset (buf, 0, sizeof (glibtop_proc_map));
|
||||||
|
|
||||||
/* It does not work for the swapper task. */
|
/* It does not work for the swapper task. */
|
||||||
if (pid == 0) return NULL;
|
if (pid == 0) return NULL;
|
||||||
|
|
||||||
glibtop_suid_enter (server);
|
glibtop_suid_enter (server);
|
||||||
|
|
||||||
/* Get the process data */
|
/* Get the process data */
|
||||||
@@ -132,7 +132,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
|||||||
(unsigned long) pinfo [0].ki_vmspace,
|
(unsigned long) pinfo [0].ki_vmspace,
|
||||||
#else
|
#else
|
||||||
(unsigned long) pinfo [0].kp_proc.p_vmspace,
|
(unsigned long) pinfo [0].kp_proc.p_vmspace,
|
||||||
#endif
|
#endif
|
||||||
(char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace))
|
(char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace))
|
||||||
glibtop_error_io_r (server, "kvm_read (vmspace)");
|
glibtop_error_io_r (server, "kvm_read (vmspace)");
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
|||||||
|
|
||||||
if (!object.handle)
|
if (!object.handle)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (kvm_read (server->machine.kd,
|
if (kvm_read (server->machine.kd,
|
||||||
(unsigned long) object.handle,
|
(unsigned long) object.handle,
|
||||||
&vnode, sizeof (vnode)) != sizeof (vnode))
|
&vnode, sizeof (vnode)) != sizeof (vnode))
|
||||||
|
@@ -129,7 +129,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
|
|||||||
int count;
|
int count;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MEM), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MEM), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_mem));
|
memset (buf, 0, sizeof (glibtop_proc_mem));
|
||||||
|
|
||||||
if (server->sysdeps.proc_mem == 0)
|
if (server->sysdeps.proc_mem == 0)
|
||||||
@@ -137,7 +137,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
|
|||||||
|
|
||||||
/* It does not work for the swapper task. */
|
/* It does not work for the swapper task. */
|
||||||
if (pid == 0) return;
|
if (pid == 0) return;
|
||||||
|
|
||||||
/* Get the process data */
|
/* Get the process data */
|
||||||
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
||||||
if ((pinfo == NULL) || (count < 1)) {
|
if ((pinfo == NULL) || (count < 1)) {
|
||||||
@@ -167,14 +167,14 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->rss_rlim = (guint64)
|
buf->rss_rlim = (guint64)
|
||||||
(plimit.pl_rlimit [RLIMIT_RSS].rlim_cur);
|
(plimit.pl_rlimit [RLIMIT_RSS].rlim_cur);
|
||||||
|
|
||||||
vms = &pinfo [0].kp_eproc.e_vm;
|
vms = &pinfo [0].kp_eproc.e_vm;
|
||||||
|
|
||||||
buf->vsize = buf->size = (guint64) pagetok
|
buf->vsize = buf->size = (guint64) pagetok
|
||||||
(vms->vm_tsize + vms->vm_dsize + vms->vm_ssize) << LOG1024;
|
(vms->vm_tsize + vms->vm_dsize + vms->vm_ssize) << LOG1024;
|
||||||
|
|
||||||
buf->resident = buf->rss = (guint64) pagetok
|
buf->resident = buf->rss = (guint64) pagetok
|
||||||
(vms->vm_rssize) << LOG1024;
|
(vms->vm_rssize) << LOG1024;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -49,7 +49,7 @@ glibtop_get_proc_segment_p (glibtop *server,
|
|||||||
pid_t pid)
|
pid_t pid)
|
||||||
{
|
{
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_segment));
|
memset (buf, 0, sizeof (glibtop_proc_segment));
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -71,7 +71,7 @@ glibtop_get_proc_segment_p (glibtop *server,
|
|||||||
/* dt: dirty pages
|
/* dt: dirty pages
|
||||||
*/
|
*/
|
||||||
/* start_code: address of beginning of code segment
|
/* start_code: address of beginning of code segment
|
||||||
|
|
||||||
*/
|
*/
|
||||||
/* end_code: address of end of code segment
|
/* end_code: address of end of code segment
|
||||||
*/
|
*/
|
||||||
|
@@ -56,12 +56,12 @@ glibtop_get_proc_signal_p (glibtop *server,
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_signal));
|
memset (buf, 0, sizeof (glibtop_proc_signal));
|
||||||
|
|
||||||
/* It does not work for the swapper task. */
|
/* It does not work for the swapper task. */
|
||||||
if (pid == 0) return;
|
if (pid == 0) return;
|
||||||
|
|
||||||
/* Get the process information */
|
/* Get the process information */
|
||||||
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
||||||
if ((pinfo == NULL) || (count != 1)) {
|
if ((pinfo == NULL) || (count != 1)) {
|
||||||
@@ -108,7 +108,7 @@ glibtop_get_proc_signal_p (glibtop *server,
|
|||||||
#else
|
#else
|
||||||
buf->blocked [0] = pinfo [0].kp_proc.p_sigmask;
|
buf->blocked [0] = pinfo [0].kp_proc.p_sigmask;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* sigignore: mask of ignored signals.
|
/* sigignore: mask of ignored signals.
|
||||||
* pinfo [0].kp_proc.p_sigignore
|
* pinfo [0].kp_proc.p_sigignore
|
||||||
*/
|
*/
|
||||||
@@ -120,7 +120,7 @@ glibtop_get_proc_signal_p (glibtop *server,
|
|||||||
#else
|
#else
|
||||||
buf->sigignore [0] = pinfo [0].kp_proc.p_sigignore;
|
buf->sigignore [0] = pinfo [0].kp_proc.p_sigignore;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* sigcatch: mask of caught signals.
|
/* sigcatch: mask of caught signals.
|
||||||
* pinfo [0].kp_proc.p_sigcatch
|
* pinfo [0].kp_proc.p_sigcatch
|
||||||
*/
|
*/
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <glibtop_suid.h>
|
#include <glibtop_suid.h>
|
||||||
|
|
||||||
#if !defined(__OpenBSD__)
|
#if !defined(__OpenBSD__)
|
||||||
//&& (!defined __bsdi__)
|
//&& (!defined __bsdi__)
|
||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -59,12 +59,12 @@ glibtop_get_proc_state_p (glibtop *server,
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_STATE), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_STATE), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_state));
|
memset (buf, 0, sizeof (glibtop_proc_state));
|
||||||
|
|
||||||
/* It does not work for the swapper task. */
|
/* It does not work for the swapper task. */
|
||||||
if (pid == 0) return;
|
if (pid == 0) return;
|
||||||
|
|
||||||
/* Get the process information */
|
/* Get the process information */
|
||||||
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
||||||
if ((pinfo == NULL) || (count != 1)) {
|
if ((pinfo == NULL) || (count != 1)) {
|
||||||
|
@@ -138,12 +138,12 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
|
|||||||
struct stat statb;
|
struct stat statb;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_time));
|
memset (buf, 0, sizeof (glibtop_proc_time));
|
||||||
|
|
||||||
/* It does not work for the swapper task. */
|
/* It does not work for the swapper task. */
|
||||||
if (pid == 0) return;
|
if (pid == 0) return;
|
||||||
|
|
||||||
#if (defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000))
|
#if (defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000))
|
||||||
if (server->sysdeps.proc_time == 0)
|
if (server->sysdeps.proc_time == 0)
|
||||||
return;
|
return;
|
||||||
@@ -188,7 +188,7 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
|
|||||||
|
|
||||||
buf->utime = tv2sec (pstats.p_ru.ru_utime);
|
buf->utime = tv2sec (pstats.p_ru.ru_utime);
|
||||||
buf->stime = tv2sec (pstats.p_ru.ru_stime);
|
buf->stime = tv2sec (pstats.p_ru.ru_stime);
|
||||||
|
|
||||||
buf->cutime = tv2sec (pstats.p_cru.ru_utime);
|
buf->cutime = tv2sec (pstats.p_cru.ru_utime);
|
||||||
buf->cstime = tv2sec (pstats.p_cru.ru_stime);
|
buf->cstime = tv2sec (pstats.p_cru.ru_stime);
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
|
|||||||
|
|
||||||
buf->utime = tv2sec (pstats.p_ru.ru_utime);
|
buf->utime = tv2sec (pstats.p_ru.ru_utime);
|
||||||
buf->stime = tv2sec (pstats.p_ru.ru_stime);
|
buf->stime = tv2sec (pstats.p_ru.ru_stime);
|
||||||
|
|
||||||
buf->cutime = tv2sec (pstats.p_cru.ru_utime);
|
buf->cutime = tv2sec (pstats.p_cru.ru_utime);
|
||||||
buf->cstime = tv2sec (pstats.p_cru.ru_stime);
|
buf->cstime = tv2sec (pstats.p_cru.ru_stime);
|
||||||
|
|
||||||
|
@@ -63,12 +63,12 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_UID), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_UID), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_uid));
|
memset (buf, 0, sizeof (glibtop_proc_uid));
|
||||||
|
|
||||||
/* It does not work for the swapper task. */
|
/* It does not work for the swapper task. */
|
||||||
if (pid == 0) return;
|
if (pid == 0) return;
|
||||||
|
|
||||||
/* Get the process information */
|
/* Get the process information */
|
||||||
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
||||||
if ((pinfo == NULL) || (count != 1)) {
|
if ((pinfo == NULL) || (count != 1)) {
|
||||||
|
@@ -66,7 +66,7 @@ static unsigned long _glibtop_sysdeps_sem_limits =
|
|||||||
* read it once during initialization. We have to use the name `_seminfo'
|
* read it once during initialization. We have to use the name `_seminfo'
|
||||||
* since `seminfo' is already declared external in <sys/sem.h>. */
|
* since `seminfo' is already declared external in <sys/sem.h>. */
|
||||||
static struct seminfo _seminfo;
|
static struct seminfo _seminfo;
|
||||||
|
|
||||||
/* nlist structure for kernel access */
|
/* nlist structure for kernel access */
|
||||||
static struct nlist nlst [] = {
|
static struct nlist nlst [] = {
|
||||||
{ "_seminfo" },
|
{ "_seminfo" },
|
||||||
@@ -82,7 +82,7 @@ glibtop_init_sem_limits_p (glibtop *server)
|
|||||||
glibtop_warn_io_r (server, "kvm_nlist (sem_limits)");
|
glibtop_warn_io_r (server, "kvm_nlist (sem_limits)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kvm_read (server->machine.kd, nlst [0].n_value,
|
if (kvm_read (server->machine.kd, nlst [0].n_value,
|
||||||
&_seminfo, sizeof (_seminfo)) != sizeof (_seminfo)) {
|
&_seminfo, sizeof (_seminfo)) != sizeof (_seminfo)) {
|
||||||
glibtop_warn_io_r (server, "kvm_read (seminfo)");
|
glibtop_warn_io_r (server, "kvm_read (seminfo)");
|
||||||
@@ -98,9 +98,9 @@ void
|
|||||||
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
|
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
|
||||||
{
|
{
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_sem_limits));
|
memset (buf, 0, sizeof (glibtop_sem_limits));
|
||||||
|
|
||||||
if (server->sysdeps.sem_limits == 0)
|
if (server->sysdeps.sem_limits == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
|
|||||||
buf->semopm = _seminfo.semopm;
|
buf->semopm = _seminfo.semopm;
|
||||||
buf->semvmx = _seminfo.semvmx;
|
buf->semvmx = _seminfo.semvmx;
|
||||||
buf->semaem = _seminfo.semaem;
|
buf->semaem = _seminfo.semaem;
|
||||||
|
|
||||||
buf->flags = _glibtop_sysdeps_sem_limits;
|
buf->flags = _glibtop_sysdeps_sem_limits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -64,7 +64,7 @@ static unsigned long _glibtop_sysdeps_shm_limits =
|
|||||||
* read it once during initialization. We have to use the name `_shminfo'
|
* read it once during initialization. We have to use the name `_shminfo'
|
||||||
* since `shminfo' is already declared external in <sys/shm.h>. */
|
* since `shminfo' is already declared external in <sys/shm.h>. */
|
||||||
static struct shminfo _shminfo;
|
static struct shminfo _shminfo;
|
||||||
|
|
||||||
/* nlist structure for kernel access */
|
/* nlist structure for kernel access */
|
||||||
static struct nlist nlst [] = {
|
static struct nlist nlst [] = {
|
||||||
{ "_shminfo" },
|
{ "_shminfo" },
|
||||||
@@ -80,7 +80,7 @@ glibtop_init_shm_limits_p (glibtop *server)
|
|||||||
glibtop_warn_io_r (server, "kvm_nlist (shm_limits)");
|
glibtop_warn_io_r (server, "kvm_nlist (shm_limits)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kvm_read (server->machine.kd, nlst [0].n_value,
|
if (kvm_read (server->machine.kd, nlst [0].n_value,
|
||||||
&_shminfo, sizeof (_shminfo)) != sizeof (_shminfo)) {
|
&_shminfo, sizeof (_shminfo)) != sizeof (_shminfo)) {
|
||||||
glibtop_warn_io_r (server, "kvm_read (shminfo)");
|
glibtop_warn_io_r (server, "kvm_read (shminfo)");
|
||||||
@@ -96,7 +96,7 @@ void
|
|||||||
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
|
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
|
||||||
{
|
{
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_shm_limits));
|
memset (buf, 0, sizeof (glibtop_shm_limits));
|
||||||
|
|
||||||
if (server->sysdeps.shm_limits == 0)
|
if (server->sysdeps.shm_limits == 0)
|
||||||
|
@@ -147,7 +147,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
|||||||
struct kvm_swap kvmsw[16];
|
struct kvm_swap kvmsw[16];
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#elif defined(__bsdi__)
|
#elif defined(__bsdi__)
|
||||||
struct swapstats swap;
|
struct swapstats swap;
|
||||||
#elif defined(__NetBSD__)
|
#elif defined(__NetBSD__)
|
||||||
struct swapent *swaplist;
|
struct swapent *swaplist;
|
||||||
@@ -167,7 +167,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
|||||||
static int swappgsout = -1;
|
static int swappgsout = -1;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SWAP), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SWAP), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_swap));
|
memset (buf, 0, sizeof (glibtop_swap));
|
||||||
|
|
||||||
if (server->sysdeps.swap == 0)
|
if (server->sysdeps.swap == 0)
|
||||||
@@ -181,7 +181,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* This is used to get the `pagein' and `pageout' members. */
|
/* This is used to get the `pagein' and `pageout' members. */
|
||||||
|
|
||||||
if (kvm_read (server->machine.kd, nlst2[0].n_value,
|
if (kvm_read (server->machine.kd, nlst2[0].n_value,
|
||||||
&vmm, sizeof (vmm)) != sizeof (vmm)) {
|
&vmm, sizeof (vmm)) != sizeof (vmm)) {
|
||||||
glibtop_warn_io_r (server, "kvm_read (cnt)");
|
glibtop_warn_io_r (server, "kvm_read (cnt)");
|
||||||
|
@@ -73,7 +73,7 @@ glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
|
|||||||
glibtop_cpu cpu;
|
glibtop_cpu cpu;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_uptime));
|
memset (buf, 0, sizeof (glibtop_uptime));
|
||||||
|
|
||||||
/* We simply calculate it from the CPU usage. */
|
/* We simply calculate it from the CPU usage. */
|
||||||
|
@@ -45,14 +45,14 @@ void
|
|||||||
glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
|
glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
|
||||||
{
|
{
|
||||||
union table tbl;
|
union table tbl;
|
||||||
|
|
||||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_LOADAVG, 0);
|
glibtop_init_s (&server, GLIBTOP_SYSDEPS_LOADAVG, 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_loadavg));
|
memset (buf, 0, sizeof (glibtop_loadavg));
|
||||||
|
|
||||||
if (table (TABLE_LOADAVG, &tbl, NULL))
|
if (table (TABLE_LOADAVG, &tbl, NULL))
|
||||||
glibtop_error_io_r (server, "table(TABLE_LOADAVG)");
|
glibtop_error_io_r (server, "table(TABLE_LOADAVG)");
|
||||||
|
|
||||||
buf->flags = _glibtop_sysdeps_loadavg;
|
buf->flags = _glibtop_sysdeps_loadavg;
|
||||||
|
|
||||||
buf->loadavg [0] = tbl.loadavg.loadavg [0];
|
buf->loadavg [0] = tbl.loadavg.loadavg [0];
|
||||||
|
@@ -47,7 +47,7 @@ void
|
|||||||
glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
|
glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
|
||||||
{
|
{
|
||||||
union table tbl;
|
union table tbl;
|
||||||
|
|
||||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
|
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_mem));
|
memset (buf, 0, sizeof (glibtop_mem));
|
||||||
|
@@ -46,15 +46,15 @@ void
|
|||||||
glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
|
glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
|
||||||
{
|
{
|
||||||
struct msginfo msginfo;
|
struct msginfo msginfo;
|
||||||
|
|
||||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0);
|
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_msg_limits));
|
memset (buf, 0, sizeof (glibtop_msg_limits));
|
||||||
|
|
||||||
buf->flags = _glibtop_sysdeps_msg_limits;
|
buf->flags = _glibtop_sysdeps_msg_limits;
|
||||||
|
|
||||||
msgctl (0, IPC_INFO, (struct msqid_ds *) &msginfo);
|
msgctl (0, IPC_INFO, (struct msqid_ds *) &msginfo);
|
||||||
|
|
||||||
buf->msgpool = msginfo.msgpool;
|
buf->msgpool = msginfo.msgpool;
|
||||||
buf->msgmap = msginfo.msgmap;
|
buf->msgmap = msginfo.msgmap;
|
||||||
buf->msgmax = msginfo.msgmax;
|
buf->msgmax = msginfo.msgmax;
|
||||||
|
@@ -36,7 +36,7 @@ static int linux_version_code = 0;
|
|||||||
static void set_linux_version(void) {
|
static void set_linux_version(void) {
|
||||||
static struct utsname uts;
|
static struct utsname uts;
|
||||||
int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
|
int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
|
||||||
|
|
||||||
if (linux_version_code) return;
|
if (linux_version_code) return;
|
||||||
if (uname(&uts) == -1) /* failure most likely implies impending death */
|
if (uname(&uts) == -1) /* failure most likely implies impending death */
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -57,7 +57,7 @@ glibtop_open_s (glibtop *server, const char *program_name,
|
|||||||
const unsigned long features, const unsigned flags)
|
const unsigned long features, const unsigned flags)
|
||||||
{
|
{
|
||||||
server->name = program_name;
|
server->name = program_name;
|
||||||
|
|
||||||
set_linux_version ();
|
set_linux_version ();
|
||||||
server->os_version_code = (unsigned long) linux_version_code;
|
server->os_version_code = (unsigned long) linux_version_code;
|
||||||
}
|
}
|
||||||
|
@@ -86,9 +86,9 @@ glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid)
|
|||||||
struct stat statb;
|
struct stat statb;
|
||||||
int nread;
|
int nread;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
glibtop_init_s (&server, 0, 0);
|
glibtop_init_s (&server, 0, 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_procdata));
|
memset (buf, 0, sizeof (glibtop_procdata));
|
||||||
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
@@ -98,27 +98,27 @@ glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sprintf (input, "/proc/%d/stat", pid);
|
sprintf (input, "/proc/%d/stat", pid);
|
||||||
|
|
||||||
if (stat (input, &statb)) return;
|
if (stat (input, &statb)) return;
|
||||||
|
|
||||||
buf->uid = statb.st_uid;
|
buf->uid = statb.st_uid;
|
||||||
|
|
||||||
f = fopen (input, "r");
|
f = fopen (input, "r");
|
||||||
if (!f) return;
|
if (!f) return;
|
||||||
|
|
||||||
nread = fread (input, 1, BUFSIZ, f);
|
nread = fread (input, 1, BUFSIZ, f);
|
||||||
|
|
||||||
if (nread < 0) {
|
if (nread < 0) {
|
||||||
fclose (f);
|
fclose (f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
input [nread] = 0;
|
input [nread] = 0;
|
||||||
|
|
||||||
/* This is from guile-utils/gtop/proc/readproc.c */
|
/* This is from guile-utils/gtop/proc/readproc.c */
|
||||||
|
|
||||||
/* split into "PID (cmd" and "<rest>" */
|
/* split into "PID (cmd" and "<rest>" */
|
||||||
tmp = strrchr (input, ')');
|
tmp = strrchr (input, ')');
|
||||||
*tmp = '\0'; /* replace trailing ')' with NUL */
|
*tmp = '\0'; /* replace trailing ')' with NUL */
|
||||||
@@ -152,7 +152,7 @@ glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid)
|
|||||||
if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1)
|
if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1)
|
||||||
/* when tty wasn't full devno */
|
/* when tty wasn't full devno */
|
||||||
buf->tty = 4*0x100 + buf->tty;
|
buf->tty = 4*0x100 + buf->tty;
|
||||||
|
|
||||||
fclose (f);
|
fclose (f);
|
||||||
|
|
||||||
sprintf (input, "/proc/%d/statm", pid);
|
sprintf (input, "/proc/%d/statm", pid);
|
||||||
|
@@ -48,16 +48,16 @@ glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf,
|
|||||||
pid_t pid)
|
pid_t pid)
|
||||||
{
|
{
|
||||||
union table tbl;
|
union table tbl;
|
||||||
|
|
||||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0);
|
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_kernel));
|
memset (buf, 0, sizeof (glibtop_proc_kernel));
|
||||||
|
|
||||||
if (table (TABLE_PROC_KERNEL, &tbl, &pid))
|
if (table (TABLE_PROC_KERNEL, &tbl, &pid))
|
||||||
glibtop_error_io_r (server, "table(TABLE_PROC_KERNEL)");
|
glibtop_error_io_r (server, "table(TABLE_PROC_KERNEL)");
|
||||||
|
|
||||||
buf->flags = _glibtop_sysdeps_proc_kernel;
|
buf->flags = _glibtop_sysdeps_proc_kernel;
|
||||||
|
|
||||||
buf->min_flt = tbl.proc_kernel.min_flt;
|
buf->min_flt = tbl.proc_kernel.min_flt;
|
||||||
buf->cmin_flt = tbl.proc_kernel.cmin_flt;
|
buf->cmin_flt = tbl.proc_kernel.cmin_flt;
|
||||||
buf->maj_flt = tbl.proc_kernel.maj_flt;
|
buf->maj_flt = tbl.proc_kernel.maj_flt;
|
||||||
|
@@ -41,8 +41,8 @@ glibtop_map_entry *
|
|||||||
glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
||||||
{
|
{
|
||||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0);
|
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_map));
|
memset (buf, 0, sizeof (glibtop_proc_map));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user