top: add support exploiting new library LXC containers

Reference(s):
https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1424253
https://bugs.launchpad.net/ubuntu/+source/procps/+bug/1424253

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2015-06-13 00:00:00 -05:00 committed by Craig Small
parent 0557504f9c
commit 2ba7aa8b7d
3 changed files with 13 additions and 3 deletions

View File

@ -269,6 +269,7 @@ SCB_NUM1(FV1, maj_delta)
SCB_NUM1(FV2, min_delta)
SCB_NUMx(GID, egid)
SCB_STRS(GRP, egroup)
SCB_STRS(LXC, lxcname)
SCB_NUMx(NCE, nice)
SCB_NUM1(NS1, ns[IPCNS])
SCB_NUM1(NS2, ns[MNTNS])
@ -1399,7 +1400,7 @@ static void osel_clear (WIN_t *q) {
/*
* Determine if there is a matching value or releationship among the
* Determine if there are matching values or relationships among the
* other criteria in this passed window -- it's called from only one
* place, and likely inlined even without the directive */
static inline int osel_matched (const WIN_t *q, FLG_t enu, const char *str) {
@ -1695,6 +1696,7 @@ end_justifies:
#define L_SUPGRP PROC_FILLSTATUS | PROC_FILLSUPGRP
#define L_USED PROC_FILLSTATUS | PROC_FILLMEM
#define L_NS PROC_FILLNS
#define L_LXC PROC_FILL_LXC
// make 'none' non-zero (used to be important to Frames_libflags)
#define L_NONE PROC_SPARE_1
// from either 'stat' or 'status' (preferred), via bits not otherwise used
@ -1794,7 +1796,8 @@ static FLD_t Fieldstab[] = {
{ 10, -1, A_right, SF(NS3), L_NS }, // NETNS
{ 10, -1, A_right, SF(NS4), L_NS }, // PIDNS
{ 10, -1, A_right, SF(NS5), L_NS }, // USERNS
{ 10, -1, A_right, SF(NS6), L_NS } // UTSNS
{ 10, -1, A_right, SF(NS6), L_NS }, // UTSNS
{ 8, -1, A_left, SF(LXC), L_LXC }
#undef SF
#undef A_left
#undef A_right
@ -2331,7 +2334,7 @@ static void zap_fieldstab (void) {
Fieldstab[EU_UEN].width = Fieldstab[EU_URN].width
= Fieldstab[EU_USN].width = Fieldstab[EU_GRP].width
= Rc.fixed_widest ? 8 + Rc.fixed_widest : 8;
Fieldstab[EU_TTY].width
Fieldstab[EU_TTY].width = Fieldstab[EU_LXC].width
= Rc.fixed_widest ? 8 + Rc.fixed_widest : 8;
Fieldstab[EU_WCH].width
= Rc.fixed_widest ? 10 + Rc.fixed_widest : 10;
@ -5396,6 +5399,9 @@ static const char *task_show (const WIN_t *q, const proc_t *p) {
case EU_GRP:
cp = make_str(p->egroup, W, Js, EU_GRP);
break;
case EU_LXC:
cp = make_str(p->lxcname, W, Js, EU_LXC);
break;
case EU_MEM:
cp = scale_pcnt((float)pages2K(p->resident) * 100 / kb_main_total, W, Jn);
break;

View File

@ -205,6 +205,7 @@ enum pflag {
EU_FV1, EU_FV2,
EU_USE,
EU_NS1, EU_NS2, EU_NS3, EU_NS4, EU_NS5, EU_NS6,
EU_LXC,
#ifdef USE_X_COLHDR
// not really pflags, used with tbl indexing
EU_MAXPFLGS

View File

@ -277,6 +277,9 @@ static void build_two_nlstabs (void) {
/* Translation Hint: maximum 'nsUTS' = 7 */
Head_nlstab[EU_NS6] = _("nsUTS");
Desc_nlstab[EU_NS6] = _("UTS namespace Inode");
/* Translation Hint: maximum 'LXC' = 7 */
Head_nlstab[EU_LXC] = _("LXC");
Desc_nlstab[EU_LXC] = _("LXC container name");
}