diff options
35 files changed, 128 insertions, 111 deletions
@@ -1,5 +1,9 @@ 1998-07-30 Martin Baulig <martin@home-of-linux.org> + * include/glibtop/*.h: Using `u_int64_t' instead of `unsigned long' + and `long' to avoid problems when client is on a 32bit system and + the server on a 64bit system. + * sysdeps/common/gnuslib.c: Using `0xffffffff' instead of -1 as error code for inet_addr () since on 64bit systems, `inet_addr (some_error) != (INET_ADDR) -1'. diff --git a/examples/first.c b/examples/first.c index cc62861e..e3703714 100644 --- a/examples/first.c +++ b/examples/first.c @@ -71,14 +71,14 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_cpu (&data.cpu); - printf ("CPU (0x%08lx): %lu, %lu, %lu, %lu, %lu, %lu\n", + printf ("CPU (0x%08Lx): %Lu, %Lu, %Lu, %Lu, %Lu, %Lu\n", data.cpu.flags, data.cpu.total, data.cpu.user, data.cpu.nice, data.cpu.sys, data.cpu.idle, data.cpu.frequency); for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_mem (&data.mem); - printf ("Memory (0x%08lx): %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n", + printf ("Memory (0x%08Lx): %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu\n", data.mem.flags, data.mem.total, data.mem.used, data.mem.free, data.mem.shared, data.mem.buffer, data.mem.cached, data.mem.user, data.mem.locked); @@ -86,26 +86,26 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_swap (&data.swap); - printf ("Swap (0x%08lx): %lu, %lu, %lu\n", data.swap.flags, + printf ("Swap (0x%08Lx): %Lu, %Lu, %Lu\n", data.swap.flags, data.swap.total, data.swap.used, data.swap.free); for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_uptime (&data.uptime); - printf ("Uptime (0x%08lx): %f, %f\n", data.uptime.flags, + printf ("Uptime (0x%08Lx): %f, %f\n", data.uptime.flags, data.uptime.uptime, data.uptime.idletime); for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_loadavg (&data.loadavg); - printf ("Loadavg (0x%08lx): %f, %f, %f\n", data.loadavg.flags, + printf ("Loadavg (0x%08Lx): %f, %f, %f\n", data.loadavg.flags, data.loadavg.loadavg [0], data.loadavg.loadavg [1], data.loadavg.loadavg [2]); for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_shm_limits (&data.shm_limits); - printf ("Shm Limits (0x%08lx): %ld, %ld, %ld, %ld, %ld\n", + printf ("Shm Limits (0x%08Lx): %Lu, %Lu, %Lu, %Lu, %Lu\n", data.shm_limits.flags, data.shm_limits.shmmax, data.shm_limits.shmmin, data.shm_limits.shmmni, data.shm_limits.shmseg, data.shm_limits.shmall); @@ -113,7 +113,7 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_msg_limits (&data.msg_limits); - printf ("Msg Limits (0x%08lx): %ld, %ld, %ld, %ld, %ld, %ld, %ld\n", + printf ("Msg Limits (0x%08Lx): %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu\n", data.msg_limits.flags, data.msg_limits.msgpool, data.msg_limits.msgmap, data.msg_limits.msgmax, data.msg_limits.msgmnb, data.msg_limits.msgmni, @@ -122,8 +122,8 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_sem_limits (&data.sem_limits); - printf ("Sem Limits (0x%08lx): " - "%ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\n", + printf ("Sem Limits (0x%08Lx): " + "%Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu\n", data.sem_limits.flags, data.sem_limits.semmap, data.sem_limits.semmni, data.sem_limits.semmns, data.sem_limits.semmnu, data.sem_limits.semmsl, @@ -135,8 +135,8 @@ main (int argc, char *argv []) glibtop_get_sysdeps (&sysdeps); - printf ("Sysdeps (0x%08lx): %lu, %lu, %lu, %lu, %lu, " - "%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n", + printf ("Sysdeps (0x%08Lx): %Lu, %Lu, %Lu, %Lu, %Lu, " + "%Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu\n", sysdeps.flags, sysdeps.cpu, sysdeps.mem, sysdeps.swap, sysdeps.uptime, sysdeps.loadavg, sysdeps.shm_limits, sysdeps.msg_limits, sysdeps.sem_limits, @@ -149,7 +149,7 @@ main (int argc, char *argv []) ptr = glibtop_get_proclist (&data.proclist); - printf ("Proclist (0x%08lx): %ld, %ld, %ld\n", + printf ("Proclist (0x%08Lx): %Lu, %Lu, %Lu\n", data.proclist.flags, data.proclist.number, data.proclist.size, data.proclist.total); @@ -170,7 +170,7 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_state (&data.proc_state, pid); - printf ("Proc_State PID %5u (0x%08lx): '%s', %c, %u, %u\n", + printf ("Proc_State PID %5u (0x%08Lx): '%s', %c, %u, %u\n", pid, data.proc_state.flags, data.proc_state.cmd, data.proc_state.state, data.proc_state.uid, data.proc_state.gid); @@ -178,7 +178,7 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_uid (&data.proc_uid, pid); - printf ("Proc_Uid PID %5u (0x%08lx): " + printf ("Proc_Uid PID %5u (0x%08Lx): " "%d %d %d %d %d %d %d %d %d %d %d %d\n", pid, data.proc_uid.flags, data.proc_uid.uid, data.proc_uid.euid, data.proc_uid.gid, @@ -191,8 +191,8 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_mem (&data.proc_mem, pid); - printf ("Proc_Mem PID %5u (0x%08lx): " - "%ld %ld %ld %ld %ld %ld\n", pid, data.proc_mem.flags, + printf ("Proc_Mem PID %5u (0x%08Lx): " + "%Lu %Lu %Lu %Lu %Lu %Lu\n", pid, data.proc_mem.flags, data.proc_mem.size, data.proc_mem.vsize, data.proc_mem.resident, data.proc_mem.share, data.proc_mem.rss, data.proc_mem.rss_rlim); @@ -200,8 +200,8 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_time (&data.proc_time, pid); - printf ("Proc_Time PID %5u (0x%08lx): " - "%ld %ld %ld %ld %ld %ld %ld\n", pid, data.proc_time.flags, + printf ("Proc_Time PID %5u (0x%08Lx): " + "%Lu %Lu %Lu %Lu %Lu %Lu %Lu\n", pid, data.proc_time.flags, data.proc_time.start_time, data.proc_time.utime, data.proc_time.stime, data.proc_time.cutime, data.proc_time.cstime, data.proc_time.timeout, @@ -210,7 +210,7 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_signal (&data.proc_signal, pid); - printf ("Proc_Signal PID %5u (0x%08lx): " + printf ("Proc_Signal PID %5u (0x%08Lx): " "%Lu %Lu %Lu %Lu\n", pid, data.proc_signal.flags, data.proc_signal.signal, data.proc_signal.blocked, data.proc_signal.sigignore, data.proc_signal.sigcatch); @@ -218,8 +218,8 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_kernel (&data.proc_kernel, pid); - printf ("Proc_Kernel PID %5u (0x%08lx): " - "%lu %lu %lu %lu %lu %lu %lu %lu\n", pid, + printf ("Proc_Kernel PID %5u (0x%08Lx): " + "%Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu\n", pid, data.proc_kernel.flags, data.proc_kernel.k_flags, data.proc_kernel.min_flt, data.proc_kernel.maj_flt, data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, @@ -229,8 +229,8 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_segment (&data.proc_segment, pid); - printf ("Proc_Segment PID %5u (0x%08lx): " - "%ld %ld %ld %ld %lu %lu %lu\n", pid, data.proc_segment.flags, + printf ("Proc_Segment PID %5u (0x%08Lx): " + "%Lu %Lu %Lu %Lu %Lu %Lu %Lu\n", pid, data.proc_segment.flags, data.proc_segment.trs, data.proc_segment.lrs, data.proc_segment.drs, data.proc_segment.dt, data.proc_segment.start_code, data.proc_segment.end_code, @@ -241,7 +241,7 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_state (&data.proc_state, ppid); - printf ("Proc_State PPID %5u (0x%08lx): '%s', %c, %u, %u\n", + printf ("Proc_State PPID %5u (0x%08Lx): '%s', %c, %u, %u\n", ppid, data.proc_state.flags, data.proc_state.cmd, data.proc_state.state, data.proc_state.uid, data.proc_state.gid); @@ -249,7 +249,7 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_uid (&data.proc_uid, ppid); - printf ("Proc_Uid PPID %5u (0x%08lx): " + printf ("Proc_Uid PPID %5u (0x%08Lx): " "%d %d %d %d %d %d %d %d %d %d %d %d\n", ppid, data.proc_uid.flags, data.proc_uid.uid, data.proc_uid.euid, data.proc_uid.gid, @@ -262,8 +262,8 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_mem (&data.proc_mem, ppid); - printf ("Proc_Mem PPID %5u (0x%08lx): " - "%ld %ld %ld %ld %ld %ld\n", ppid, data.proc_mem.flags, + printf ("Proc_Mem PPID %5u (0x%08Lx): " + "%Lu %Lu %Lu %Lu %Lu %Lu\n", ppid, data.proc_mem.flags, data.proc_mem.size, data.proc_mem.vsize, data.proc_mem.resident, data.proc_mem.share, data.proc_mem.rss, data.proc_mem.rss_rlim); @@ -271,8 +271,8 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_time (&data.proc_time, ppid); - printf ("Proc_Time PPID %5u (0x%08lx): " - "%ld %ld %ld %ld %ld %ld %ld\n", ppid, data.proc_time.flags, + printf ("Proc_Time PPID %5u (0x%08Lx): " + "%Lu %Lu %Lu %Lu %Lu %Lu %Lu\n", ppid, data.proc_time.flags, data.proc_time.start_time, data.proc_time.utime, data.proc_time.stime, data.proc_time.cutime, data.proc_time.cstime, data.proc_time.timeout, @@ -281,7 +281,7 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_signal (&data.proc_signal, ppid); - printf ("Proc_Signal PPID %5u (0x%08lx): " + printf ("Proc_Signal PPID %5u (0x%08Lx): " "%Lu %Lu %Lu %Lu\n", ppid, data.proc_signal.flags, data.proc_signal.signal, data.proc_signal.blocked, data.proc_signal.sigignore, data.proc_signal.sigcatch); @@ -289,8 +289,8 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_kernel (&data.proc_kernel, ppid); - printf ("Proc_Kernel PPID %5u (0x%08lx): " - "%lu %lu %lu %lu %lu %lu %lu %lu\n", ppid, + printf ("Proc_Kernel PPID %5u (0x%08Lx): " + "%Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu\n", ppid, data.proc_kernel.flags, data.proc_kernel.k_flags, data.proc_kernel.min_flt, data.proc_kernel.maj_flt, data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, @@ -300,8 +300,8 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_segment (&data.proc_segment, ppid); - printf ("Proc_Segment PPID %5u (0x%08lx): " - "%ld %ld %ld %ld %lu %lu %lu\n", ppid, data.proc_segment.flags, + printf ("Proc_Segment PPID %5u (0x%08Lx): " + "%Lu %Lu %Lu %Lu %Lu %Lu %Lu\n", ppid, data.proc_segment.flags, data.proc_segment.trs, data.proc_segment.lrs, data.proc_segment.drs, data.proc_segment.dt, data.proc_segment.start_code, data.proc_segment.end_code, @@ -312,7 +312,7 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_state (&data.proc_state, 1); - printf ("Proc_State INIT %5u (0x%08lx): '%s', %c, %u, %u\n", + printf ("Proc_State INIT %5u (0x%08Lx): '%s', %c, %u, %u\n", 1, data.proc_state.flags, data.proc_state.cmd, data.proc_state.state, data.proc_state.uid, data.proc_state.gid); @@ -320,7 +320,7 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_uid (&data.proc_uid, 1); - printf ("Proc_Uid INIT %5u (0x%08lx): " + printf ("Proc_Uid INIT %5u (0x%08Lx): " "%d %d %d %d %d %d %d %d %d %d %d %d\n", 1, data.proc_uid.flags, data.proc_uid.uid, data.proc_uid.euid, data.proc_uid.gid, @@ -333,8 +333,8 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_mem (&data.proc_mem, 1); - printf ("Proc_Mem INIT %5u (0x%08lx): " - "%ld %ld %ld %ld %ld %ld\n", 1, data.proc_mem.flags, + printf ("Proc_Mem INIT %5u (0x%08Lx): " + "%Lu %Lu %Lu %Lu %Lu %Lu\n", 1, data.proc_mem.flags, data.proc_mem.size, data.proc_mem.vsize, data.proc_mem.resident, data.proc_mem.share, data.proc_mem.rss, data.proc_mem.rss_rlim); @@ -342,8 +342,8 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_time (&data.proc_time, 1); - printf ("Proc_Time INIT %5u (0x%08lx): " - "%ld %ld %ld %ld %ld %ld %ld\n", 1, data.proc_time.flags, + printf ("Proc_Time INIT %5u (0x%08Lx): " + "%Lu %Lu %Lu %Lu %Lu %Lu %Lu\n", 1, data.proc_time.flags, data.proc_time.start_time, data.proc_time.utime, data.proc_time.stime, data.proc_time.cutime, data.proc_time.cstime, data.proc_time.timeout, @@ -352,7 +352,7 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_signal (&data.proc_signal, 1); - printf ("Proc_Signal INIT %5u (0x%08lx): " + printf ("Proc_Signal INIT %5u (0x%08Lx): " "%Lu %Lu %Lu %Lu\n", 1, data.proc_signal.flags, data.proc_signal.signal, data.proc_signal.blocked, data.proc_signal.sigignore, data.proc_signal.sigcatch); @@ -360,8 +360,8 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_kernel (&data.proc_kernel, 1); - printf ("Proc_Kernel INIT %5u (0x%08lx): " - "%lu %lu %lu %lu %lu %lu %lu %lu\n", 1, + printf ("Proc_Kernel INIT %5u (0x%08Lx): " + "%Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu\n", 1, data.proc_kernel.flags, data.proc_kernel.k_flags, data.proc_kernel.min_flt, data.proc_kernel.maj_flt, data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, @@ -371,8 +371,8 @@ main (int argc, char *argv []) for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_segment (&data.proc_segment, 1); - printf ("Proc_Segment INIT %5u (0x%08lx): " - "%ld %ld %ld %ld %lu %lu %lu\n", 1, data.proc_segment.flags, + printf ("Proc_Segment INIT %5u (0x%08Lx): " + "%Lu %Lu %Lu %Lu %Lu %Lu %Lu\n", 1, data.proc_segment.flags, data.proc_segment.trs, data.proc_segment.lrs, data.proc_segment.drs, data.proc_segment.dt, data.proc_segment.start_code, data.proc_segment.end_code, diff --git a/examples/mountlist.c b/examples/mountlist.c index cca91d3f..af63afc7 100644 --- a/examples/mountlist.c +++ b/examples/mountlist.c @@ -94,7 +94,7 @@ main (int argc, char *argv []) glibtop_get_fsusage (&fsusage, mount_entries [index].mountdir); - printf ("Usage: %-16s %9lu %9lu %9lu %9lu %9lu\n", + printf ("Usage: %-16s %9Lu %9Lu %9Lu %9Lu %9Lu\n", mount_entries [index].mountdir, fsusage.blocks, fsusage.bfree, fsusage.bavail, fsusage.files, diff --git a/examples/second.c b/examples/second.c index 3f618a0e..305b056f 100644 --- a/examples/second.c +++ b/examples/second.c @@ -45,8 +45,8 @@ main (int argc, char *argv []) glibtop_get_sysdeps (&sysdeps); - fprintf (stderr, "Sysdeps (0x%08lx): %lu, %lu, %lu, %lu, %lu, " - "%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n", + fprintf (stderr, "Sysdeps (0x%08Lx): %Lu, %Lu, %Lu, %Lu, %Lu, " + "%Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu, %Lu\n", sysdeps.flags, sysdeps.cpu, sysdeps.mem, sysdeps.swap, sysdeps.uptime, sysdeps.loadavg, sysdeps.shm_limits, sysdeps.msg_limits, sysdeps.sem_limits, @@ -59,7 +59,7 @@ main (int argc, char *argv []) ptr = glibtop_get_proclist (&proclist); - fprintf (stderr, "Proclist (0x%08lx): %ld, %ld, %ld\n", + fprintf (stderr, "Proclist (0x%08Lx): %Ld, %Ld, %Ld\n", proclist.flags, proclist.number, proclist.size, proclist.total); @@ -73,14 +73,14 @@ main (int argc, char *argv []) glibtop_get_proc_state (&data.proc_state, pid); - fprintf (stderr, "Proc_State PID %5u (0x%08lx): " + fprintf (stderr, "Proc_State PID %5u (0x%08Lx): " "'%s', %c, %u, %u\n", pid, data.proc_state.flags, data.proc_state.cmd, data.proc_state.state, data.proc_state.uid, data.proc_state.gid); glibtop_get_proc_uid (&data.proc_uid, pid); - fprintf (stderr, "Proc_Uid PID %5u (0x%08lx): " + fprintf (stderr, "Proc_Uid PID %5u (0x%08Lx): " "%d %d %d %d %d %d %d %d %d %d %d %d\n", pid, data.proc_uid.flags, data.proc_uid.uid, data.proc_uid.euid, data.proc_uid.gid, @@ -92,16 +92,16 @@ main (int argc, char *argv []) glibtop_get_proc_mem (&data.proc_mem, pid); - fprintf (stderr, "Proc_Mem PID %5u (0x%08lx): " - "%ld %ld %ld %ld %ld %ld\n", pid, data.proc_mem.flags, + fprintf (stderr, "Proc_Mem PID %5u (0x%08Lx): " + "%Ld %Ld %Ld %Ld %Ld %Ld\n", pid, data.proc_mem.flags, data.proc_mem.size, data.proc_mem.vsize, data.proc_mem.resident, data.proc_mem.share, data.proc_mem.rss, data.proc_mem.rss_rlim); glibtop_get_proc_time (&data.proc_time, pid); - fprintf (stderr, "Proc_Time PID %5u (0x%08lx): " - "%ld %ld %ld %ld %ld %ld %ld\n", pid, data.proc_time.flags, + fprintf (stderr, "Proc_Time PID %5u (0x%08Lx): " + "%Ld %Ld %Ld %Ld %Ld %Ld %Ld\n", pid, data.proc_time.flags, data.proc_time.start_time, data.proc_time.utime, data.proc_time.stime, data.proc_time.cutime, data.proc_time.cstime, data.proc_time.timeout, @@ -109,15 +109,15 @@ main (int argc, char *argv []) glibtop_get_proc_signal (&data.proc_signal, pid); - fprintf (stderr, "Proc_Signal PID %5u (0x%08lx): " + fprintf (stderr, "Proc_Signal PID %5u (0x%08Lx): " "%Lu %Lu %Lu %Lu\n", pid, data.proc_signal.flags, data.proc_signal.signal, data.proc_signal.blocked, data.proc_signal.sigignore, data.proc_signal.sigcatch); glibtop_get_proc_kernel (&data.proc_kernel, pid); - fprintf (stderr, "Proc_Kernel PID %5u (0x%08lx): " - "%lu %lu %lu %lu %lu %lu %lu %lu\n", pid, + fprintf (stderr, "Proc_Kernel PID %5u (0x%08Lx): " + "%Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu\n", pid, data.proc_kernel.flags, data.proc_kernel.k_flags, data.proc_kernel.min_flt, data.proc_kernel.maj_flt, data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, @@ -126,8 +126,8 @@ main (int argc, char *argv []) glibtop_get_proc_segment (&data.proc_segment, pid); - fprintf (stderr, "Proc_Segment PID %5u (0x%08lx): " - "%ld %ld %ld %ld %lu %lu %lu\n", pid, data.proc_segment.flags, + fprintf (stderr, "Proc_Segment PID %5u (0x%08Lx): " + "%Ld %Ld %Ld %Ld %Lu %Lu %Lu\n", pid, data.proc_segment.flags, data.proc_segment.trs, data.proc_segment.lrs, data.proc_segment.drs, data.proc_segment.dt, data.proc_segment.start_code, data.proc_segment.end_code, diff --git a/include/glibtop/command.h b/include/glibtop/command.h index ddd00055..d70a08bb 100644 --- a/include/glibtop/command.h +++ b/include/glibtop/command.h @@ -62,9 +62,8 @@ typedef union _glibtop_response_union glibtop_response_union; struct _glibtop_command { - glibtop server; - unsigned command; - size_t size, data_size; + u_int64_t command; + u_int64_t size, data_size; char parameter [_GLIBTOP_PARAM_SIZE]; }; @@ -76,8 +75,8 @@ union _glibtop_response_union struct _glibtop_response { - off_t offset; - size_t size, data_size; + int64_t offset; + u_int64_t size, data_size; glibtop_response_union u; }; diff --git a/include/glibtop/cpu.h b/include/glibtop/cpu.h index f4e96afc..e367bd44 100644 --- a/include/glibtop/cpu.h +++ b/include/glibtop/cpu.h @@ -40,7 +40,7 @@ typedef struct _glibtop_cpu glibtop_cpu; struct _glibtop_cpu { - unsigned long flags, + u_int64_t flags, total, /* GLIBTOP_CPU_TOTAL */ user, /* GLIBTOP_CPU_USER */ nice, /* GLIBTOP_CPU_NICE */ diff --git a/include/glibtop/fsusage.h b/include/glibtop/fsusage.h index 462eb6cd..b9ab88d1 100644 --- a/include/glibtop/fsusage.h +++ b/include/glibtop/fsusage.h @@ -39,7 +39,7 @@ typedef struct _glibtop_fsusage glibtop_fsusage; struct _glibtop_fsusage { - unsigned long flags, + u_int64_t flags, blocks, /* Total blocks. */ bfree, /* Free blocks available to superuser. */ bavail, /* Free blocks available to non-superuser. */ diff --git a/include/glibtop/loadavg.h b/include/glibtop/loadavg.h index b5f267d0..cb3b7336 100644 --- a/include/glibtop/loadavg.h +++ b/include/glibtop/loadavg.h @@ -35,7 +35,7 @@ typedef struct _glibtop_loadavg glibtop_loadavg; struct _glibtop_loadavg { - unsigned long flags; + u_int64_t flags; double loadavg [3]; /* GLIBTOP_LOADAVG_LOADAVG */ }; diff --git a/include/glibtop/mem.h b/include/glibtop/mem.h index 5f490618..823deed9 100644 --- a/include/glibtop/mem.h +++ b/include/glibtop/mem.h @@ -42,7 +42,7 @@ typedef struct _glibtop_mem glibtop_mem; struct _glibtop_mem { - unsigned long flags, + u_int64_t flags, total, /* GLIBTOP_MEM_TOTAL */ used, /* GLIBTOP_MEM_USED */ free, /* GLIBTOP_MEM_FREE */ diff --git a/include/glibtop/mountlist.h b/include/glibtop/mountlist.h index 1fb588c6..54e58298 100644 --- a/include/glibtop/mountlist.h +++ b/include/glibtop/mountlist.h @@ -33,7 +33,7 @@ __BEGIN_DECLS #define GLIBTOP_MAX_MOUNTLIST 3 -#define GLIBTOP_MOUNTENTRY_LEN 80 +#define GLIBTOP_MOUNTENTRY_LEN 79 typedef struct _glibtop_mountentry glibtop_mountentry; @@ -41,15 +41,15 @@ typedef struct _glibtop_mountlist glibtop_mountlist; struct _glibtop_mountentry { + u_int64_t dev; char devname [GLIBTOP_MOUNTENTRY_LEN+1]; char mountdir [GLIBTOP_MOUNTENTRY_LEN+1]; char type [GLIBTOP_MOUNTENTRY_LEN+1]; - dev_t dev; }; struct _glibtop_mountlist { - unsigned long flags, + u_int64_t flags, number, /* GLIBTOP_MOUNTLIST_NUMBER */ total, /* GLIBTOP_MOUNTLIST_TOTAL */ size; /* GLIBTOP_MOUNTLIST_SIZE */ diff --git a/include/glibtop/msg_limits.h b/include/glibtop/msg_limits.h index c915b568..f5e4af61 100644 --- a/include/glibtop/msg_limits.h +++ b/include/glibtop/msg_limits.h @@ -41,7 +41,7 @@ typedef struct _glibtop_msg_limits glibtop_msg_limits; struct _glibtop_msg_limits { - unsigned long flags, + u_int64_t flags, msgpool, /* GLIBTOP_IPC_MSGPOOL */ msgmap, /* GLIBTOP_IPC_MSGMAP */ msgmax, /* GLIBTOP_IPC_MSGMAX */ diff --git a/include/glibtop/prockernel.h b/include/glibtop/prockernel.h index fed6fba6..7a9cc06b 100644 --- a/include/glibtop/prockernel.h +++ b/include/glibtop/prockernel.h @@ -44,8 +44,8 @@ typedef struct _glibtop_proc_kernel glibtop_proc_kernel; struct _glibtop_proc_kernel { - unsigned long flags; - unsigned long k_flags, /* kernel flags for the process */ + u_int64_t flags; + u_int64_t k_flags, /* kernel flags for the process */ min_flt, /* number of minor page faults since * process start */ maj_flt, /* number of major page faults since diff --git a/include/glibtop/proclist.h b/include/glibtop/proclist.h index ebc6512c..45dcb757 100644 --- a/include/glibtop/proclist.h +++ b/include/glibtop/proclist.h @@ -37,7 +37,7 @@ typedef struct _glibtop_proclist glibtop_proclist; struct _glibtop_proclist { - unsigned long flags, + u_int64_t flags, number, /* GLIBTOP_PROCLIST_NUMBER */ total, /* GLIBTOP_PROCLIST_TOTAL */ size; /* GLIBTOP_PROCLIST_SIZE */ diff --git a/include/glibtop/procmem.h b/include/glibtop/procmem.h index a2720169..ced5a520 100644 --- a/include/glibtop/procmem.h +++ b/include/glibtop/procmem.h @@ -42,8 +42,8 @@ typedef struct _glibtop_proc_mem glibtop_proc_mem; struct _glibtop_proc_mem { - unsigned long flags; - long size, /* total # of pages of memory */ + u_int64_t flags, + size, /* total # of pages of memory */ vsize, /* number of pages of virtual memory ... */ resident, /* number of resident set * (non-swapped) pages (4k) */ diff --git a/include/glibtop/procsegment.h b/include/glibtop/procsegment.h index 54f59d81..5d4249bb 100644 --- a/include/glibtop/procsegment.h +++ b/include/glibtop/procsegment.h @@ -43,12 +43,12 @@ typedef struct _glibtop_proc_segment glibtop_proc_segment; struct _glibtop_proc_segment { - unsigned long flags; - long trs, /* text resident set size */ + u_int64_t flags, + trs, /* text resident set size */ lrs, /* shared-lib resident set size */ drs, /* data resident set size */ - dt; /* dirty pages */ - unsigned long start_code, + dt, /* dirty pages */ + start_code, /* address of beginning of code segment */ end_code, /* address of end of code segment */ start_stack; /* address of the bottom of stack segment */ diff --git a/include/glibtop/procsignal.h b/include/glibtop/procsignal.h index 57373ca0..f95a8745 100644 --- a/include/glibtop/procsignal.h +++ b/include/glibtop/procsignal.h @@ -40,8 +40,8 @@ typedef struct _glibtop_proc_signal glibtop_proc_signal; struct _glibtop_proc_signal { - unsigned long flags; - unsigned long long signal, /* mask of pending signals */ + u_int64_t flags, + signal, /* mask of pending signals */ blocked, /* mask of blocked signals */ sigignore, /* mask of ignored signals */ sigcatch; /* mask of caught signals */ diff --git a/include/glibtop/procstate.h b/include/glibtop/procstate.h index 416a2d94..3de12b0d 100644 --- a/include/glibtop/procstate.h +++ b/include/glibtop/procstate.h @@ -40,7 +40,7 @@ typedef struct _glibtop_proc_state glibtop_proc_state; struct _glibtop_proc_state { - unsigned long flags; + u_int64_t flags; char cmd[40], /* basename of executable file in * call to exec(2) */ state; /* single-char code for process state diff --git a/include/glibtop/proctime.h b/include/glibtop/proctime.h index 40ae3aa5..6bce6b5b 100644 --- a/include/glibtop/proctime.h +++ b/include/glibtop/proctime.h @@ -43,8 +43,8 @@ typedef struct _glibtop_proc_time glibtop_proc_time; struct _glibtop_proc_time { - unsigned long flags; - long start_time, /* start time of process -- + u_int64_t flags, + start_time, /* start time of process -- * seconds since 1-1-70 */ utime, /* user-mode CPU time accumulated by process */ stime, /* kernel-mode CPU time accumulated by process */ diff --git a/include/glibtop/procuid.h b/include/glibtop/procuid.h index e478c2cb..4238f91b 100644 --- a/include/glibtop/procuid.h +++ b/include/glibtop/procuid.h @@ -48,7 +48,7 @@ typedef struct _glibtop_proc_uid glibtop_proc_uid; struct _glibtop_proc_uid { - unsigned long flags; + u_int64_t flags; int uid, /* user id */ euid, /* effective user id */ gid, /* group id */ diff --git a/include/glibtop/sem_limits.h b/include/glibtop/sem_limits.h index 19cefc95..71af5c68 100644 --- a/include/glibtop/sem_limits.h +++ b/include/glibtop/sem_limits.h @@ -44,7 +44,7 @@ typedef struct _glibtop_sem_limits glibtop_sem_limits; struct _glibtop_sem_limits { - unsigned long flags, + u_int64_t flags, semmap, /* GLIBTOP_IPC_SEMMAP */ semmni, /* GLIBTOP_IPC_SEMMNI */ semmns, /* GLIBTOP_IPC_SEMMNS */ diff --git a/include/glibtop/shm_limits.h b/include/glibtop/shm_limits.h index e068bd47..933d61c8 100644 --- a/include/glibtop/shm_limits.h +++ b/include/glibtop/shm_limits.h @@ -39,7 +39,7 @@ typedef struct _glibtop_shm_limits glibtop_shm_limits; struct _glibtop_shm_limits { - unsigned long flags, + u_int64_t flags, shmmax, /* GLIBTOP_IPC_SHMMAX */ shmmin, /* GLIBTOP_IPC_SHMMIN */ shmmni, /* GLIBTOP_IPC_SHMMNI */ diff --git a/include/glibtop/swap.h b/include/glibtop/swap.h index ce7ab57c..c85aac93 100644 --- a/include/glibtop/swap.h +++ b/include/glibtop/swap.h @@ -37,7 +37,7 @@ typedef struct _glibtop_swap glibtop_swap; struct _glibtop_swap { - unsigned long flags, + u_int64_t flags, total, /* GLIBTOP_SWAP_TOTAL */ used, /* GLIBTOP_SWAP_USED */ free; /* GLIBTOP_SWAP_FREE */ diff --git a/include/glibtop/sysdeps.h b/include/glibtop/sysdeps.h index b24e549e..80e66986 100644 --- a/include/glibtop/sysdeps.h +++ b/include/glibtop/sysdeps.h @@ -55,7 +55,7 @@ typedef struct _glibtop_sysdeps glibtop_sysdeps; struct _glibtop_sysdeps { - unsigned long flags, + u_int64_t flags, features, /* server features */ cpu, /* glibtop_cpu */ mem, /* glibtop_mem */ diff --git a/include/glibtop/uptime.h b/include/glibtop/uptime.h index 39c8dea5..8bb08053 100644 --- a/include/glibtop/uptime.h +++ b/include/glibtop/uptime.h @@ -36,7 +36,7 @@ typedef struct _glibtop_uptime glibtop_uptime; struct _glibtop_uptime { - unsigned long flags; + u_int64_t flags; double uptime, /* GLIBTOP_UPTIME_UPTIME */ idletime; /* GLIBTOP_UPTIME_IDLETIME */ }; diff --git a/lib/command.c b/lib/command.c index acd60081..17cda905 100644 --- a/lib/command.c +++ b/lib/command.c @@ -37,8 +37,6 @@ glibtop_call_l (glibtop *server, unsigned command, size_t send_size, memset (&cmnd, 0, sizeof (glibtop_command)); - memcpy (&cmnd.server, server, sizeof (glibtop)); - cmnd.command = command; /* If send_size is less than _GLIBTOP_PARAM_SIZE (normally 16 Bytes), we @@ -57,6 +57,13 @@ glibtop_open_l (glibtop *server, const char *program_name, server->features = features; +#ifdef DEBUG + fprintf (stderr, "SIZEOF: %u - %u - %u - %u - %u - %u\n", + sizeof (glibtop_command), sizeof (glibtop_response), + sizeof (glibtop_mountentry), sizeof (glibtop_union), + sizeof (glibtop_sysdeps), sizeof (glibtop_response_union)); +#endif + switch (server->method) { case GLIBTOP_METHOD_PIPE: case GLIBTOP_METHOD_UNIX: diff --git a/src/daemon/main.c b/src/daemon/main.c index 5e6f934a..abc9ae8d 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -35,6 +35,13 @@ handle_parent_connection (int s) fprintf (stderr, "Parent features = %lu\n", glibtop_server_features); +#ifdef DEBUG + fprintf (stderr, "SIZEOF: %u - %u - %u - %u - %u - %u\n", + sizeof (glibtop_command), sizeof (glibtop_response), + sizeof (glibtop_mountentry), sizeof (glibtop_union), + sizeof (glibtop_sysdeps), sizeof (glibtop_response_union)); +#endif + while (do_read (s, cmnd, sizeof (glibtop_command))) { #ifdef PARENT_DEBUG fprintf (stderr, "Parent (%d) received command %d from client.\n", @@ -42,15 +49,17 @@ handle_parent_connection (int s) #endif if (cmnd->data_size >= BUFSIZ) { - glibtop_warn ("Client sent %d bytes, but buffer is %d", cmnd->size, BUFSIZ); + glibtop_warn ("Client sent %d bytes, but buffer is %d", + cmnd->data_size, BUFSIZ); return; } - + memset (parameter, 0, sizeof (parameter)); - + if (cmnd->data_size) { #ifdef PARENT_DEBUG - fprintf (stderr, "Client has %d bytes of data.\n", cmnd->data_size); + fprintf (stderr, "Client has %d bytes of data.\n", + cmnd->data_size); #endif do_read (s, parameter, cmnd->data_size); diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c index 16f29939..a0e600cd 100644 --- a/sysdeps/linux/cpu.c +++ b/sysdeps/linux/cpu.c @@ -46,7 +46,7 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) f = fopen ("/proc/stat", "r"); if (!f) return; - fscanf (f, "cpu %lu %lu %lu %lu\n", + fscanf (f, "cpu %Lu %Lu %Lu %Lu\n", &buf->user, &buf->nice, &buf->sys, &buf->idle); buf->total = buf->user + buf->nice + buf->sys + buf->idle; diff --git a/sysdeps/linux/mem.c b/sysdeps/linux/mem.c index ca52092b..c9e46607 100644 --- a/sysdeps/linux/mem.c +++ b/sysdeps/linux/mem.c @@ -47,7 +47,7 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) f = fopen ("/proc/meminfo", "r"); if (!f) return; - fscanf (f, "%*[^\n]\nMem: %lu %lu %lu %lu %lu %lu\n", + fscanf (f, "%*[^\n]\nMem: %Lu %Lu %Lu %Lu %Lu %Lu\n", &buf->total, &buf->used, &buf->free, &buf->shared, &buf->buffer, &buf->cached); diff --git a/sysdeps/linux/prockernel.c b/sysdeps/linux/prockernel.c index 3264fb13..a68862a0 100644 --- a/sysdeps/linux/prockernel.c +++ b/sysdeps/linux/prockernel.c @@ -70,9 +70,9 @@ glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) /* parse these two strings separately, skipping the leading "(". */ sscanf(tmp + 2, /* skip space after ')' too */ - "%*c %*d %*d %*d %*d %*d %lu %lu %lu %lu %lu " + "%*c %*d %*d %*d %*d %*d %Lu %Lu %Lu %Lu %Lu " "%*d %*d %*d %*d %*d %*d %*u %*u %*d %*u " - "%*u %*u %*u %*u %*u %lu %lu %*d %*d %*d %*d %lu", + "%*u %*u %*u %*u %*u %Lu %Lu %*d %*d %*d %*d %Lu", &buf->k_flags, &buf->min_flt, &buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt, &buf->kstk_esp, &buf->kstk_eip, &buf->wchan); diff --git a/sysdeps/linux/procmem.c b/sysdeps/linux/procmem.c index dcbbc198..98a86fce 100644 --- a/sysdeps/linux/procmem.c +++ b/sysdeps/linux/procmem.c @@ -69,8 +69,8 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) /* parse these two strings separately, skipping the leading "(". */ sscanf(tmp + 2, /* skip space after ')' too */ "%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u " - "%*d %*d %*d %*d %*d %*d %*u %*u %*d %lu " - "%lu %lu", &buf->vsize, &buf->rss, &buf->rss_rlim); + "%*d %*d %*d %*d %*d %*d %*u %*u %*d %Lu " + "%Lu %Lu", &buf->vsize, &buf->rss, &buf->rss_rlim); fclose (f); @@ -88,7 +88,7 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) input [nread] = 0; - sscanf (input, "%ld %ld %ld", + sscanf (input, "%Lu %Lu %Lu", &buf->size, &buf->resident, &buf->share); fclose (f); diff --git a/sysdeps/linux/procsegment.c b/sysdeps/linux/procsegment.c index 5300b5f8..00ab96ec 100644 --- a/sysdeps/linux/procsegment.c +++ b/sysdeps/linux/procsegment.c @@ -72,7 +72,7 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, sscanf(tmp + 2, /* skip space after ')' too */ "%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u " "%*d %*d %*d %*d %*d %*d %*u %*u %*d %*u " - "%*u %*u %lu %lu %lu", &buf->start_code, + "%*u %*u %Lu %Lu %Lu", &buf->start_code, &buf->end_code, &buf->start_stack); fclose (f); @@ -91,7 +91,7 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, input [nread] = 0; - sscanf (input, "%*d %*d %*d %ld %ld %ld %ld", + sscanf (input, "%*d %*d %*d %Lu %Lu %Lu %Lu", &buf->trs, &buf->lrs, &buf->drs, &buf->dt); fclose (f); diff --git a/sysdeps/linux/procsignal.c b/sysdeps/linux/procsignal.c index 428463f7..b4009bdb 100644 --- a/sysdeps/linux/procsignal.c +++ b/sysdeps/linux/procsignal.c @@ -69,7 +69,7 @@ glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) sscanf(tmp + 2, /* skip space after ')' too */ "%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u " "%*d %*d %*d %*d %*d %*d %*u %*u %*d %*u " - "%*u %*u %*u %*u %*u %*u %*u %d %d %d %d", + "%*u %*u %*u %*u %*u %*u %*u %Lu %Lu %Lu %Lu", &buf->signal, &buf->blocked, &buf->sigignore, &buf->sigcatch); diff --git a/sysdeps/linux/proctime.c b/sysdeps/linux/proctime.c index fed8ad20..b37a4aa9 100644 --- a/sysdeps/linux/proctime.c +++ b/sysdeps/linux/proctime.c @@ -70,7 +70,7 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) /* parse these two strings separately, skipping the leading "(". */ sscanf(tmp + 2, /* skip space after ')' too */ "%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u " - "%ld %ld %ld %ld %*d %*d %lu %lu %ld", + "%Lu %Lu %Lu %Lu %*d %*d %Lu %Lu %Lu", &buf->utime, &buf->stime, &buf->cutime, &buf->cstime, &buf->timeout, &buf->it_real_value, &buf->start_time); diff --git a/sysdeps/linux/swap.c b/sysdeps/linux/swap.c index af316ead..85ef484d 100644 --- a/sysdeps/linux/swap.c +++ b/sysdeps/linux/swap.c @@ -45,7 +45,7 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) f = fopen ("/proc/meminfo", "r"); if (!f) return; - fscanf (f, "%*[^\n]\n%*[^\n]\nSwap: %lu %lu %lu\n", + fscanf (f, "%*[^\n]\n%*[^\n]\nSwap: %Lu %Lu %Lu\n", &buf->total, &buf->used, &buf->free); fclose (f); |