From 07d991f383abdd1c31eedefe22d43f797d771d2f Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 20 Oct 2003 21:27:31 +0000 Subject: [PATCH] Apply patch by the_h1ghlander@yahoo.com and Cory Omand 2003-10-20 Bastien Nocera * include/glibtop/cpu.h: * include/glibtop/procstate.h: * include/glibtop/procuid.h: * include/glibtop/uptime.h: * lib/sysdeps.c: * sysdeps/names/cpu.c: * sysdeps/names/procstate.c: * sysdeps/names/procuid.c: * sysdeps/names/uptime.c: Apply patch by the_h1ghlander@yahoo.com and Cory Omand for Solaris support --- ChangeLog | 13 ++++++++ include/glibtop/cpu.h | 6 ++-- include/glibtop/procstate.h | 25 +++++++++++--- include/glibtop/procuid.h | 35 ++++++++++++++------ include/glibtop/uptime.h | 4 ++- lib/sysdeps.c | 64 ++++++++++++++++++++++++++++++++++++ sysdeps/names/cpu.c | 8 +++-- sysdeps/names/procstate.c | 18 +++++++--- sysdeps/names/procuid.c | 34 +++++++++---------- sysdeps/names/uptime.c | 10 +++--- sysdeps/solaris/ChangeLog | 6 ++++ sysdeps/solaris/shm_limits.c | 6 ++-- 12 files changed, 180 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index c58b7243..3664079b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2003-10-20 Bastien Nocera + + * include/glibtop/cpu.h: + * include/glibtop/procstate.h: + * include/glibtop/procuid.h: + * include/glibtop/uptime.h: + * lib/sysdeps.c: + * sysdeps/names/cpu.c: + * sysdeps/names/procstate.c: + * sysdeps/names/procuid.c: + * sysdeps/names/uptime.c: Apply patch by the_h1ghlander@yahoo.com and + Cory Omand for Solaris support + 2003-10-20 Bastien Nocera * src/inodedb/Makefile.am: link to libgtop_suid_common-2.0.la diff --git a/include/glibtop/cpu.h b/include/glibtop/cpu.h index cbe081e7..ef5aaab3 100644 --- a/include/glibtop/cpu.h +++ b/include/glibtop/cpu.h @@ -41,8 +41,9 @@ G_BEGIN_DECLS #define GLIBTOP_XCPU_NICE 8 #define GLIBTOP_XCPU_SYS 9 #define GLIBTOP_XCPU_IDLE 10 +#define GLIBTOP_XCPU_FLAGS 11 -#define GLIBTOP_MAX_CPU 11 +#define GLIBTOP_MAX_CPU 12 /* Nobody should really be using more than 4 processors. */ #define GLIBTOP_NCPU 4 @@ -62,7 +63,8 @@ struct _glibtop_cpu xcpu_user [GLIBTOP_NCPU], /* GLIBTOP_XCPU_USER */ xcpu_nice [GLIBTOP_NCPU], /* GLIBTOP_XCPU_NICE */ xcpu_sys [GLIBTOP_NCPU], /* GLIBTOP_XCPU_SYS */ - xcpu_idle [GLIBTOP_NCPU]; /* GLIBTOP_XCPU_IDLE */ + xcpu_idle [GLIBTOP_NCPU], /* GLIBTOP_XCPU_IDLE */ + xcpu_flags; /* GLIBTOP_XCPU_IDLE */ }; #define glibtop_get_cpu(cpu) glibtop_get_cpu_l(glibtop_global_server, cpu) diff --git a/include/glibtop/procstate.h b/include/glibtop/procstate.h index 6decb2df..53b5ab6a 100644 --- a/include/glibtop/procstate.h +++ b/include/glibtop/procstate.h @@ -33,8 +33,20 @@ G_BEGIN_DECLS #define GLIBTOP_PROC_STATE_STATE 1 #define GLIBTOP_PROC_STATE_UID 2 #define GLIBTOP_PROC_STATE_GID 3 +#define GLIBTOP_PROC_STATE_RUID 4 +#define GLIBTOP_PROC_STATE_RGID 5 +#define GLIBTOP_PROC_STATE_HAS_CPU 6 +#define GLIBTOP_PROC_STATE_PROCESSOR 7 +#define GLIBTOP_PROC_STATE_LAST_PROCESSOR 8 -#define GLIBTOP_MAX_PROC_STATE 4 +#define GLIBTOP_MAX_PROC_STATE 9 + +#define GLIBTOP_PROCESS_RUNNING 1 +#define GLIBTOP_PROCESS_INTERRUPTIBLE 2 +#define GLIBTOP_PROCESS_UNINTERRUPTIBLE 4 +#define GLIBTOP_PROCESS_ZOMBIE 8 +#define GLIBTOP_PROCESS_STOPPED 16 +#define GLIBTOP_PROCESS_SWAPPING 32 typedef struct _glibtop_proc_state glibtop_proc_state; @@ -43,9 +55,9 @@ typedef struct _glibtop_proc_state glibtop_proc_state; struct _glibtop_proc_state { guint64 flags; - char cmd[40], /* basename of executable file in + char cmd[40]; /* basename of executable file in * call to exec(2) */ - state; /* single-char code for process state + unsigned state; /* single-char code for process state * (S=sleeping) */ /* NOTE: when porting the library, TRY HARD to implement the * following two fields. */ @@ -53,7 +65,12 @@ struct _glibtop_proc_state * only to set the flags value for those two * fields if their values are corrent ! */ int uid, /* UID of process */ - gid; /* GID of process */ + gid, /* GID of process */ + ruid, + rgid; + int has_cpu, + processor, + last_processor; }; #define glibtop_get_proc_state(p1, p2) glibtop_get_proc_state_l(glibtop_global_server, p1, p2) diff --git a/include/glibtop/procuid.h b/include/glibtop/procuid.h index d5bccd63..801e948d 100644 --- a/include/glibtop/procuid.h +++ b/include/glibtop/procuid.h @@ -33,19 +33,27 @@ G_BEGIN_DECLS #define GLIBTOP_PROC_UID_EUID 1 #define GLIBTOP_PROC_UID_GID 2 #define GLIBTOP_PROC_UID_EGID 3 -#define GLIBTOP_PROC_UID_PID 4 -#define GLIBTOP_PROC_UID_PPID 5 -#define GLIBTOP_PROC_UID_PGRP 6 -#define GLIBTOP_PROC_UID_SESSION 7 -#define GLIBTOP_PROC_UID_TTY 8 -#define GLIBTOP_PROC_UID_TPGID 9 -#define GLIBTOP_PROC_UID_PRIORITY 10 -#define GLIBTOP_PROC_UID_NICE 11 +#define GLIBTOP_PROC_UID_SUID 4 +#define GLIBTOP_PROC_UID_SGID 5 +#define GLIBTOP_PROC_UID_FSUID 6 +#define GLIBTOP_PROC_UID_FSGID 7 +#define GLIBTOP_PROC_UID_PID 8 +#define GLIBTOP_PROC_UID_PPID 9 +#define GLIBTOP_PROC_UID_PGRP 10 +#define GLIBTOP_PROC_UID_SESSION 11 +#define GLIBTOP_PROC_UID_TTY 12 +#define GLIBTOP_PROC_UID_TPGID 13 +#define GLIBTOP_PROC_UID_PRIORITY 14 +#define GLIBTOP_PROC_UID_NICE 15 +#define GLIBTOP_PROC_UID_NGROUPS 16 +#define GLIBTOP_PROC_UID_GROUPS 17 -#define GLIBTOP_MAX_PROC_UID 12 +#define GLIBTOP_MAX_PROC_UID 18 typedef struct _glibtop_proc_uid glibtop_proc_uid; +#define GLIBTOP_MAX_GROUPS 64 + /* User, Group, Terminal and session */ struct _glibtop_proc_uid @@ -55,6 +63,10 @@ struct _glibtop_proc_uid euid, /* effective user id */ gid, /* group id */ egid, /* effective group id */ + suid, /* set user id */ + sgid, /* set group id */ + fsuid, /* ??? user id */ + fsgid, /* ??? group id */ pid, /* process id */ ppid, /* pid of parent process */ pgrp, /* process group id */ @@ -62,7 +74,10 @@ struct _glibtop_proc_uid tty, /* full device number of controlling terminal */ tpgid, /* terminal process group id */ priority, /* kernel scheduling priority */ - nice; /* standard unix nice level of process */ + nice, /* standard unix nice level of process */ + ngroups, + groups [GLIBTOP_MAX_GROUPS]; + }; #define glibtop_get_proc_uid(p1, p2) glibtop_get_proc_uid_l(glibtop_global_server, p1, p2) diff --git a/include/glibtop/uptime.h b/include/glibtop/uptime.h index 5f7f2199..94c9f8da 100644 --- a/include/glibtop/uptime.h +++ b/include/glibtop/uptime.h @@ -31,8 +31,9 @@ G_BEGIN_DECLS #define GLIBTOP_UPTIME_UPTIME 0 #define GLIBTOP_UPTIME_IDLETIME 1 +#define GLIBTOP_UPTIME_BOOT_TIME 2 -#define GLIBTOP_MAX_UPTIME 2 +#define GLIBTOP_MAX_UPTIME 3 typedef struct _glibtop_uptime glibtop_uptime; @@ -41,6 +42,7 @@ struct _glibtop_uptime guint64 flags; double uptime, /* GLIBTOP_UPTIME_UPTIME */ idletime; /* GLIBTOP_UPTIME_IDLETIME */ + guint64 boot_time; }; #define glibtop_get_uptime(uptime) glibtop_get_uptime_l(glibtop_global_server, uptime) diff --git a/lib/sysdeps.c b/lib/sysdeps.c index 94ab190d..5bc3e6f1 100644 --- a/lib/sysdeps.c +++ b/lib/sysdeps.c @@ -109,6 +109,70 @@ glibtop_init_func_t _glibtop_init_hook_s [] = { NULL }; +glibtop_init_func_t _glibtop_init_hook_p [] = { +#if GLIBTOP_SUID_CPU + glibtop_init_cpu_p, +#endif +#if GLIBTOP_SUID_MEM + glibtop_init_mem_p, +#endif +#if GLIBTOP_SUID_SWAP + glibtop_init_swap_p, +#endif +#if GLIBTOP_SUID_UPTIME + glibtop_init_uptime_p, +#endif +#if GLIBTOP_SUID_LOADAVG + glibtop_init_loadavg_p, +#endif +#if GLIBTOP_SUID_SHM_LIMITS + glibtop_init_shm_limits_p, +#endif +#if GLIBTOP_SUID_MSG_LIMITS + glibtop_init_msg_limits_p, +#endif +#if GLIBTOP_SUID_SEM_LIMITS + glibtop_init_sem_limits_p, +#endif +#if GLIBTOP_SUID_PROCLIST + glibtop_init_proclist_p, +#endif +#if GLIBTOP_SUID_PROC_STATE + glibtop_init_proc_state_p, +#endif +#if GLIBTOP_SUID_PROC_UID + glibtop_init_proc_uid_p, +#endif +#if GLIBTOP_SUID_PROC_MEM + glibtop_init_proc_mem_p, +#endif +#if GLIBTOP_SUID_PROC_TIME + glibtop_init_proc_time_p, +#endif +#if GLIBTOP_SUID_PROC_SIGNAL + glibtop_init_proc_signal_p, +#endif +#if GLIBTOP_SUID_PROC_KERNEL + glibtop_init_proc_kernel_p, +#endif +#if GLIBTOP_SUID_PROC_SEGMENT + glibtop_init_proc_segment_p, +#endif +#if GLIBTOP_SUID_PROC_ARGS + glibtop_init_proc_args_p, +#endif +#if GLIBTOP_SUID_PROC_MAP + glibtop_init_proc_map_p, +#endif +#if GLIBTOP_SUID_NETLOAD + glibtop_init_netload_p, +#endif +#if GLIBTOP_SUID_PPP + glibtop_init_ppp_p, +#endif + NULL +}; + /* Checks which features are implemented. */ void diff --git a/sysdeps/names/cpu.c b/sysdeps/names/cpu.c index 24952379..6c385ce1 100644 --- a/sysdeps/names/cpu.c +++ b/sysdeps/names/cpu.c @@ -28,7 +28,7 @@ const char *glibtop_names_cpu [GLIBTOP_MAX_CPU] = { "total", "user", "nice", "sys", "idle", "frequency", "xcpu_total", "xcpu_user", "xcpu_nice", "xcpu_sys", - "xcpu_idle" + "xcpu_idle", "xcpu_flags" }; const unsigned glibtop_types_cpu [GLIBTOP_MAX_CPU] = @@ -36,7 +36,7 @@ const unsigned glibtop_types_cpu [GLIBTOP_MAX_CPU] = GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, - GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG }; const char *glibtop_labels_cpu [GLIBTOP_MAX_CPU] = @@ -51,7 +51,8 @@ const char *glibtop_labels_cpu [GLIBTOP_MAX_CPU] = N_("SMP CPU Time in User Mode"), N_("SMP CPU Time in User Mode (nice)"), N_("SMP CPU Time in System Mode"), - N_("SMP CPU Time in the Idle Task") + N_("SMP CPU Time in the Idle Task"), + N_("SMP CPU Flags") }; const char *glibtop_descriptions_cpu [GLIBTOP_MAX_CPU] = @@ -67,4 +68,5 @@ const char *glibtop_descriptions_cpu [GLIBTOP_MAX_CPU] = N_("Number of clock ticks the system spent in user mode (nice)"), N_("Number of clock ticks the system spent in system mode"), N_("Number of clock ticks the system spent in the idle task"), + N_("Bit field indicating which CPU is currently running"), }; diff --git a/sysdeps/names/procstate.c b/sysdeps/names/procstate.c index 8e3ac0eb..ece3997e 100644 --- a/sysdeps/names/procstate.c +++ b/sysdeps/names/procstate.c @@ -27,18 +27,21 @@ const char *glibtop_names_proc_state [GLIBTOP_MAX_PROC_STATE] = { - "cmd", "state", "uid", "gid" + "cmd", "state", "uid", "gid", "ruid", "rgid", + "has_cpu", "processor", "last_processor" }; const unsigned glibtop_types_proc_state [GLIBTOP_MAX_PROC_STATE] = { - GLIBTOP_TYPE_STRING, GLIBTOP_TYPE_CHAR, - GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT + GLIBTOP_TYPE_STRING, GLIBTOP_TYPE_CHAR, GLIBTOP_TYPE_INT, + GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, + GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT }; const char *glibtop_labels_proc_state [GLIBTOP_MAX_PROC_STATE] = { - N_("Cmd"), N_("State"), N_("UID"), N_("GID") + N_("Cmd"), N_("State"), N_("UID"), N_("GID"), + N_("RGid"), N_("RUid"), N_("HasCPU"), N_("Proc"), N_("LProc") }; const char *glibtop_descriptions_proc_state [GLIBTOP_MAX_PROC_STATE] = @@ -46,5 +49,10 @@ const char *glibtop_descriptions_proc_state [GLIBTOP_MAX_PROC_STATE] = N_("Basename of executable file in call to exec()"), N_("Single-Char code for process state (S=sleeping)"), N_("UID of process"), - N_("GID of process") + N_("GID of process"), + N_("Real UID of process"), + N_("Real GID of process"), + N_("Has CPU"), + N_("Processor"), + N_("Last Processor"), }; diff --git a/sysdeps/names/procuid.c b/sysdeps/names/procuid.c index 1fd98cda..9f8341ba 100644 --- a/sysdeps/names/procuid.c +++ b/sysdeps/names/procuid.c @@ -25,27 +25,18 @@ #include #include -#define GLIBTOP_PROC_UID_UID 0 -#define GLIBTOP_PROC_UID_EUID 1 -#define GLIBTOP_PROC_UID_GID 2 -#define GLIBTOP_PROC_UID_EGID 3 -#define GLIBTOP_PROC_UID_PID 4 -#define GLIBTOP_PROC_UID_PPID 5 -#define GLIBTOP_PROC_UID_PGRP 6 -#define GLIBTOP_PROC_UID_SESSION 7 -#define GLIBTOP_PROC_UID_TTY 8 -#define GLIBTOP_PROC_UID_TPGID 9 -#define GLIBTOP_PROC_UID_PRIORITY 10 -#define GLIBTOP_PROC_UID_NICE 11 - const char *glibtop_names_proc_uid [GLIBTOP_MAX_PROC_UID] = { - "uid", "euid", "gid", "egid", "pid", "ppid", "pgrp", - "session", "tty", "tpgid", "priority", "nice" + "uid", "euid", "gid", "egid", "suid", "sgid", + "fsuid", "fsgid", "pid", "ppid", "pgrp", + "session", "tty", "tpgid", "priority", "nice", + "ngroups", "groups" }; const unsigned glibtop_types_proc_uid [GLIBTOP_MAX_PROC_UID] = { + GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, + GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, @@ -54,9 +45,10 @@ const unsigned glibtop_types_proc_uid [GLIBTOP_MAX_PROC_UID] = const char *glibtop_labels_proc_uid [GLIBTOP_MAX_PROC_UID] = { - N_("Uid"), N_("EUid"), N_("Gid"), N_("EGid"), N_("Pid"), + N_("Uid"), N_("EUid"), N_("Gid"), N_("EGid"), N_("SUid"), + N_("SGid"), N_("FSUid"), N_("FSGid"), N_("Pid"), N_("PPid"), N_("PGrp"), N_("Session"), N_("Tty"), - N_("TPGid"), N_("Priority"), N_("Nice") + N_("TPGid"), N_("Priority"), N_("Nice"), N_("NGroups"), N_("Groups") }; const char *glibtop_descriptions_proc_uid [GLIBTOP_MAX_PROC_UID] = @@ -65,6 +57,10 @@ const char *glibtop_descriptions_proc_uid [GLIBTOP_MAX_PROC_UID] = N_("Effective User ID"), N_("Group ID"), N_("Effective Group ID"), + N_("Set User ID"), + N_("Set Group ID"), + N_("Filesystem User ID"), + N_("Filesystem Group ID"), N_("Process ID"), N_("PID of parent process"), N_("Process group ID"), @@ -72,5 +68,7 @@ const char *glibtop_descriptions_proc_uid [GLIBTOP_MAX_PROC_UID] = N_("Full device number of controlling terminal"), N_("Terminal process group ID"), N_("Kernel scheduling priority"), - N_("Standard unix nice level of process") + N_("Standard unix nice level of process"), + N_("Number of additional process groups"), + N_("Array of additional process groups") }; diff --git a/sysdeps/names/uptime.c b/sysdeps/names/uptime.c index 9475128d..93c446a9 100644 --- a/sysdeps/names/uptime.c +++ b/sysdeps/names/uptime.c @@ -26,22 +26,24 @@ const char *glibtop_names_uptime [GLIBTOP_MAX_UPTIME] = { - "uptime", "idletime" + "uptime", "idletime", "boot_time" }; const unsigned glibtop_types_uptime [GLIBTOP_MAX_UPTIME] = { - GLIBTOP_TYPE_DOUBLE, GLIBTOP_TYPE_DOUBLE + GLIBTOP_TYPE_DOUBLE, GLIBTOP_TYPE_DOUBLE, GLIBTOP_TYPE_ULONG }; const char *glibtop_labels_uptime [GLIBTOP_MAX_UPTIME] = { N_("Uptime"), - N_("Idletime") + N_("Idletime"), + N_("BootTime") }; const char *glibtop_descriptions_uptime [GLIBTOP_MAX_UPTIME] = { N_("Time in seconds since system boot"), - N_("Time in seconds the system spent in the idle task since system boot") + N_("Time in seconds the system spent in the idle task since system boot"), + N_("Time of last system boot in seconds since the epoch"), }; diff --git a/sysdeps/solaris/ChangeLog b/sysdeps/solaris/ChangeLog index 0b8e6775..849be399 100644 --- a/sysdeps/solaris/ChangeLog +++ b/sysdeps/solaris/ChangeLog @@ -1,3 +1,9 @@ +2003-10-20 Bastien Nocera + + * shm_limits.c: (glibtop_get_shm_limits_p): Apply patch by + the_h1ghlander@yahoo.com and Cory Omand for + Solaris support + 2003-10-20 Bastien Nocera * mem.c: (glibtop_get_mem_s): diff --git a/sysdeps/solaris/shm_limits.c b/sysdeps/solaris/shm_limits.c index 24854b33..e50b8f9d 100644 --- a/sysdeps/solaris/shm_limits.c +++ b/sysdeps/solaris/shm_limits.c @@ -60,9 +60,11 @@ glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf) if(kvm_read(kd, nlst[0].n_value, (void *)&sinfo, sizeof(struct shminfo)) != sizeof(struct shminfo)) return; - buf->shmmax = sinfo.shmmax; - buf->shmmin = sinfo.shmmin; + buf->shmmax = sinfo.shmmax; buf->shmmni = sinfo.shmmni; +#if GLIBTOP_SOLARIS_RELEASE < 590 + buf->shmmin = sinfo.shmmin; buf->shmseg = sinfo.shmseg; +#endif buf->flags = _glibtop_sysdeps_shm_limits; }