procps: add support for linux namespaces
Each process in Linux has a /proc/<pid>/ns directory which contains symbolic links to pipes that identify which namespaces that process belongs to. This patch adds support for ps to display that information optionally. Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
This commit is contained in:
@@ -31,6 +31,18 @@ EXTERN_C_BEGIN
|
||||
// neither tgid nor tid seemed correct. (in other words, FIXME)
|
||||
#define XXXID tid
|
||||
|
||||
#define NUM_NS 6
|
||||
enum ns_type {
|
||||
IPCNS = 0,
|
||||
MNTNS,
|
||||
NETNS,
|
||||
PIDNS,
|
||||
USERNS,
|
||||
UTSNS
|
||||
};
|
||||
extern const char *get_ns_name(int id);
|
||||
extern int get_ns_id(const char *name);
|
||||
|
||||
// Basic data structure which holds all information we can get about a process.
|
||||
// (unless otherwise specified, fields are read from /proc/#/stat)
|
||||
//
|
||||
@@ -157,6 +169,8 @@ typedef struct proc_t {
|
||||
oom_score, // oom_score (badness for OOM killer)
|
||||
oom_adj; // oom_adj (adjustment to OOM score)
|
||||
#endif
|
||||
ino_t
|
||||
ns[NUM_NS]; // ns/* inode number of /proc/<pid>/ns/*
|
||||
} proc_t;
|
||||
|
||||
// PROCTAB: data structure holding the persistent information readproc needs
|
||||
@@ -266,6 +280,7 @@ extern proc_t * get_proc_stats(pid_t pid, proc_t *p);
|
||||
#define PROC_FILLCGROUP 0x0200 // alloc and fill in `cgroup`
|
||||
#define PROC_FILLSUPGRP 0x0400 // resolve supplementary group id -> group name
|
||||
#define PROC_FILLOOM 0x0800 // fill in proc_t oom_score and oom_adj
|
||||
#define PROC_FILLNS 0x8000 // fill in proc_t namespace information
|
||||
|
||||
#define PROC_LOOSE_TASKS 0x2000 // treat threads as if they were processes
|
||||
|
||||
|
Reference in New Issue
Block a user