library: bring namespaces up to date with linux kernel

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2022-05-05 00:00:00 -05:00 committed by Craig Small
parent 3f068a66c8
commit d1ae5276e9
5 changed files with 28 additions and 18 deletions

View File

@ -54,20 +54,22 @@ int procps_linux_version(void);
// //////////////////////////////////////////////////////////////////
// Runtime Particulars //////////////////////////////////////////////
int procps_loadavg (double *av1, double *av5, double *av15);
int procps_uptime(double *uptime_secs, double *idle_secs);
char *procps_uptime_sprint(void);
char *procps_uptime_sprint_short(void);
int procps_loadavg (double *av1, double *av5, double *av15);
int procps_uptime (double *uptime_secs, double *idle_secs);
char *procps_uptime_sprint (void);
char *procps_uptime_sprint_short (void);
// //////////////////////////////////////////////////////////////////
// Namespace Particulars ////////////////////////////////////////////
enum namespace_type {
PROCPS_NS_CGROUP,
PROCPS_NS_IPC,
PROCPS_NS_MNT,
PROCPS_NS_NET,
PROCPS_NS_PID,
PROCPS_NS_TIME,
PROCPS_NS_USER,
PROCPS_NS_UTS,
PROCPS_NS_COUNT // total namespaces (fencepost)

View File

@ -27,12 +27,14 @@
#define NSPATHLEN 64
static const char *ns_names[] = {
[PROCPS_NS_IPC] = "ipc",
[PROCPS_NS_MNT] = "mnt",
[PROCPS_NS_NET] = "net",
[PROCPS_NS_PID] = "pid",
[PROCPS_NS_USER] = "user",
[PROCPS_NS_UTS] = "uts",
[PROCPS_NS_CGROUP] = "cgroup",
[PROCPS_NS_IPC] = "ipc",
[PROCPS_NS_MNT] = "mnt",
[PROCPS_NS_NET] = "net",
[PROCPS_NS_PID] = "pid",
[PROCPS_NS_TIME] = "time",
[PROCPS_NS_USER] = "user",
[PROCPS_NS_UTS] = "uts"
};

View File

@ -217,12 +217,14 @@ CVT_set(MEM_VIRT, ul_int, size)
REG_set(MEM_VIRT_PGS, ul_int, size)
REG_set(NICE, s_int, nice)
REG_set(NLWP, s_int, nlwp)
REG_set(NS_IPC, ul_int, ns.ns[0])
REG_set(NS_MNT, ul_int, ns.ns[1])
REG_set(NS_NET, ul_int, ns.ns[2])
REG_set(NS_PID, ul_int, ns.ns[3])
REG_set(NS_USER, ul_int, ns.ns[4])
REG_set(NS_UTS, ul_int, ns.ns[5])
REG_set(NS_CGROUP, ul_int, ns.ns[0])
REG_set(NS_IPC, ul_int, ns.ns[1])
REG_set(NS_MNT, ul_int, ns.ns[2])
REG_set(NS_NET, ul_int, ns.ns[3])
REG_set(NS_PID, ul_int, ns.ns[4])
REG_set(NS_TIME, ul_int, ns.ns[5])
REG_set(NS_USER, ul_int, ns.ns[6])
REG_set(NS_UTS, ul_int, ns.ns[7])
REG_set(OOM_ADJ, s_int, oom_adj)
REG_set(OOM_SCORE, s_int, oom_score)
REG_set(PRIORITY, s_int, priority)
@ -506,10 +508,12 @@ static struct {
{ RS(MEM_VIRT_PGS), f_statm, NULL, QS(ul_int), 0, TS(ul_int) },
{ RS(NICE), f_stat, NULL, QS(s_int), 0, TS(s_int) },
{ RS(NLWP), f_either, NULL, QS(s_int), 0, TS(s_int) },
{ RS(NS_CGROUP), f_ns, NULL, QS(ul_int), 0, TS(ul_int) },
{ RS(NS_IPC), f_ns, NULL, QS(ul_int), 0, TS(ul_int) },
{ RS(NS_MNT), f_ns, NULL, QS(ul_int), 0, TS(ul_int) },
{ RS(NS_NET), f_ns, NULL, QS(ul_int), 0, TS(ul_int) },
{ RS(NS_PID), f_ns, NULL, QS(ul_int), 0, TS(ul_int) },
{ RS(NS_TIME), f_ns, NULL, QS(ul_int), 0, TS(ul_int) },
{ RS(NS_USER), f_ns, NULL, QS(ul_int), 0, TS(ul_int) },
{ RS(NS_UTS), f_ns, NULL, QS(ul_int), 0, TS(ul_int) },
{ RS(OOM_ADJ), f_oom, NULL, QS(s_int), 0, TS(s_int) },

View File

@ -100,10 +100,12 @@ enum pids_item {
PIDS_MEM_VIRT_PGS, // ul_int statm: size
PIDS_NICE, // s_int stat: nice
PIDS_NLWP, // s_int stat: num_threads or status: Threads
PIDS_NS_IPC, // ul_int ns/
PIDS_NS_CGROUP, // ul_int ns/
PIDS_NS_IPC, // ul_int "
PIDS_NS_MNT, // ul_int "
PIDS_NS_NET, // ul_int "
PIDS_NS_PID, // ul_int "
PIDS_NS_TIME, // ul_int "
PIDS_NS_USER, // ul_int "
PIDS_NS_UTS, // ul_int "
PIDS_OOM_ADJ, // s_int oom_score_adj

View File

@ -165,7 +165,7 @@ typedef struct proc_t {
int
oom_score, // oom_score (badness for OOM killer)
oom_adj; // oom_adj (adjustment to OOM score)
struct procps_ns ns; // (ns subdir) inode number of namespaces
struct procps_ns ns; // (ns subdir) inode number of namespaces
char
*sd_mach, // n/a systemd vm/container name
*sd_ouid, // n/a systemd session owner uid