From c05bc7fb7d92f8aa176c45356f145a49ddc45fff Mon Sep 17 00:00:00 2001 From: Jerry Jelinek Date: Wed, 17 Jun 2015 14:18:41 +0000 Subject: OS-4430 need /proc/self/cgroup --- usr/src/uts/common/brand/lx/procfs/lx_proc.h | 2 ++ usr/src/uts/common/brand/lx/procfs/lx_prvnops.c | 32 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/usr/src/uts/common/brand/lx/procfs/lx_proc.h b/usr/src/uts/common/brand/lx/procfs/lx_proc.h index f59790cf61..e2765dbe07 100644 --- a/usr/src/uts/common/brand/lx/procfs/lx_proc.h +++ b/usr/src/uts/common/brand/lx/procfs/lx_proc.h @@ -107,6 +107,7 @@ extern "C" { typedef enum lxpr_nodetype { LXPR_PROCDIR, /* /proc */ LXPR_PIDDIR, /* /proc/ */ + LXPR_PID_CGROUP, /* /proc//cgroup */ LXPR_PID_CMDLINE, /* /proc//cmdline */ LXPR_PID_COMM, /* /proc//comm */ LXPR_PID_CPU, /* /proc//cpu */ @@ -125,6 +126,7 @@ typedef enum lxpr_nodetype { LXPR_PID_TASK_IDDIR, /* /proc//task/ */ LXPR_PID_FDDIR, /* /proc//fd */ LXPR_PID_FD_FD, /* /proc//fd/nn */ + LXPR_PID_TID_CGROUP, /* /proc//task//cgroup */ LXPR_PID_TID_CMDLINE, /* /proc//task//cmdline */ LXPR_PID_TID_COMM, /* /proc//task//comm */ LXPR_PID_TID_CPU, /* /proc//task//cpu */ diff --git a/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c b/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c index c49cfab774..fae0d90f6b 100644 --- a/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c +++ b/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c @@ -151,6 +151,7 @@ static void lxpr_read_swaps(lxpr_node_t *, lxpr_uiobuf_t *); static void lxpr_read_uptime(lxpr_node_t *, lxpr_uiobuf_t *); static void lxpr_read_version(lxpr_node_t *, lxpr_uiobuf_t *); +static void lxpr_read_pid_cgroup(lxpr_node_t *, lxpr_uiobuf_t *); static void lxpr_read_pid_cmdline(lxpr_node_t *, lxpr_uiobuf_t *); static void lxpr_read_pid_comm(lxpr_node_t *, lxpr_uiobuf_t *); static void lxpr_read_pid_env(lxpr_node_t *, lxpr_uiobuf_t *); @@ -274,6 +275,7 @@ static lxpr_dirent_t lx_procdir[] = { * Contents of an lx /proc/ directory. */ static lxpr_dirent_t piddir[] = { + { LXPR_PID_CGROUP, "cgroup" }, { LXPR_PID_CMDLINE, "cmdline" }, { LXPR_PID_COMM, "comm" }, { LXPR_PID_CPU, "cpu" }, @@ -298,6 +300,7 @@ static lxpr_dirent_t piddir[] = { * Contents of an lx /proc//task/ directory. */ static lxpr_dirent_t tiddir[] = { + { LXPR_PID_CGROUP, "cgroup" }, { LXPR_PID_CMDLINE, "cmdline" }, { LXPR_PID_TID_COMM, "comm" }, { LXPR_PID_CPU, "cpu" }, @@ -506,6 +509,7 @@ lxpr_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr, static void (*lxpr_read_function[LXPR_NFILES])() = { lxpr_read_isdir, /* /proc */ lxpr_read_isdir, /* /proc/ */ + lxpr_read_pid_cgroup, /* /proc//cgroup */ lxpr_read_pid_cmdline, /* /proc//cmdline */ lxpr_read_pid_comm, /* /proc//comm */ lxpr_read_empty, /* /proc//cpu */ @@ -524,6 +528,7 @@ static void (*lxpr_read_function[LXPR_NFILES])() = { lxpr_read_isdir, /* /proc//task/nn */ lxpr_read_isdir, /* /proc//fd */ lxpr_read_fd, /* /proc//fd/nn */ + lxpr_read_pid_cgroup, /* /proc//task//cgroup */ lxpr_read_pid_cmdline, /* /proc//task//cmdline */ lxpr_read_pid_comm, /* /proc//task//comm */ lxpr_read_empty, /* /proc//task//cpu */ @@ -605,6 +610,7 @@ static void (*lxpr_read_function[LXPR_NFILES])() = { static vnode_t *(*lxpr_lookup_function[LXPR_NFILES])() = { lxpr_lookup_procdir, /* /proc */ lxpr_lookup_piddir, /* /proc/ */ + lxpr_lookup_not_a_dir, /* /proc//cgroup */ lxpr_lookup_not_a_dir, /* /proc//cmdline */ lxpr_lookup_not_a_dir, /* /proc//comm */ lxpr_lookup_not_a_dir, /* /proc//cpu */ @@ -623,6 +629,7 @@ static vnode_t *(*lxpr_lookup_function[LXPR_NFILES])() = { lxpr_lookup_task_tid_dir, /* /proc//task/nn */ lxpr_lookup_fddir, /* /proc//fd */ lxpr_lookup_not_a_dir, /* /proc//fd/nn */ + lxpr_lookup_not_a_dir, /* /proc//task//cgroup */ lxpr_lookup_not_a_dir, /* /proc//task//cmdline */ lxpr_lookup_not_a_dir, /* /proc//task//comm */ lxpr_lookup_not_a_dir, /* /proc//task//cpu */ @@ -704,6 +711,7 @@ static vnode_t *(*lxpr_lookup_function[LXPR_NFILES])() = { static int (*lxpr_readdir_function[LXPR_NFILES])() = { lxpr_readdir_procdir, /* /proc */ lxpr_readdir_piddir, /* /proc/ */ + lxpr_readdir_not_a_dir, /* /proc//cgroup */ lxpr_readdir_not_a_dir, /* /proc//cmdline */ lxpr_readdir_not_a_dir, /* /proc//comm */ lxpr_readdir_not_a_dir, /* /proc//cpu */ @@ -722,6 +730,7 @@ static int (*lxpr_readdir_function[LXPR_NFILES])() = { lxpr_readdir_task_tid_dir, /* /proc//task/nn */ lxpr_readdir_fddir, /* /proc//fd */ lxpr_readdir_not_a_dir, /* /proc//fd/nn */ + lxpr_readdir_not_a_dir, /* /proc//task//cgroup */ lxpr_readdir_not_a_dir, /* /proc//task//cmdline */ lxpr_readdir_not_a_dir, /* /proc//task//comm */ lxpr_readdir_not_a_dir, /* /proc//task//cpu */ @@ -889,6 +898,29 @@ lxpr_read_empty(lxpr_node_t *lxpnp, lxpr_uiobuf_t *uiobuf) { } +/* + * lxpr_read_pid_cgroup(): read cgroups for process + */ +static void +lxpr_read_pid_cgroup(lxpr_node_t *lxpnp, lxpr_uiobuf_t *uiobuf) +{ + proc_t *p; + + ASSERT(lxpnp->lxpr_type == LXPR_PID_CGROUP || + lxpnp->lxpr_type == LXPR_PID_TID_CGROUP); + + p = lxpr_lock(lxpnp->lxpr_pid); + if (p == NULL) { + lxpr_uiobuf_seterr(uiobuf, EINVAL); + return; + } + + /* basic stub, 3rd field will need to be populated */ + lxpr_uiobuf_printf(uiobuf, "1:name=systemd:/\n"); + + lxpr_unlock(p); +} + /* * lxpr_read_pid_cmdline(): read argument vector from process */ -- cgit v1.2.3