From 2ba7aa8b7d4e1731044844589f736c5625a0b15e Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sat, 13 Jun 2015 00:00:00 -0500 Subject: [PATCH] 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 --- top/top.c | 12 +++++++++--- top/top.h | 1 + top/top_nls.c | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/top/top.c b/top/top.c index b0e23bac..a51835bb 100644 --- a/top/top.c +++ b/top/top.c @@ -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; diff --git a/top/top.h b/top/top.h index 6b13e54b..28a1a240 100644 --- a/top/top.h +++ b/top/top.h @@ -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 diff --git a/top/top_nls.c b/top/top_nls.c index 5c73e4c2..1928b172 100644 --- a/top/top_nls.c +++ b/top/top_nls.c @@ -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"); }