Commit eca91686 authored by jim warner's avatar jim warner Committed by Craig Small

misc: adapted others to that new proc_t 'cgname' field

This patch adapts the ps program to a newly add proc_t
field and provides for new support in that top program
along with his man document (ps was already ok there).
Signed-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
parent 5d54dc0d
......@@ -104,26 +104,6 @@ static int sr_cgroup(const proc_t* a, const proc_t* b)
return strcmp(*a->cgroup, *b->cgroup);
}
static int sr_cgname(const proc_t* a, const proc_t* b)
{
char *aname, *bname;
/* This is a "vector" of one */
if (*a->cgroup == NULL || *b->cgroup == NULL)
return 0;
aname = strstr(*a->cgroup, ":name=");
bname = strstr(*b->cgroup, ":name=");
/* check for missing names, they win */
if (aname == NULL || aname[6] == '\0') {
if (bname == NULL || bname[6] == '\0')
return 0;
return -1;
} else if (bname == NULL || bname[6] == '\0')
return 1;
return strcmp(aname+6,bname+6);
}
#define CMP_STR(NAME) \
static int sr_ ## NAME(const proc_t* P, const proc_t* Q) { \
return strcmp(P->NAME, Q->NAME); \
......@@ -255,6 +235,7 @@ CMP_NS(userns, USERNS);
CMP_NS(utsns, UTSNS);
CMP_STR(lxcname)
CMP_STR(cgname)
/* approximation to: kB of address space that could end up in swap */
static int sr_swapable(const proc_t* P, const proc_t* Q) {
......@@ -464,27 +445,18 @@ static int pr_comm(char *restrict const outbuf, const proc_t *restrict const pp)
return max_rightward-rightward;
}
static int pr_cgroup(char *restrict const outbuf,const proc_t *restrict const pp) {
static int pr_cgname(char *restrict const outbuf, const proc_t *restrict const pp){
int rightward = max_rightward;
escaped_copy(outbuf, *pp->cgroup, OUTBUF_SIZE, &rightward);
escaped_copy(outbuf, pp->cgname, OUTBUF_SIZE, &rightward);
return max_rightward-rightward;
}
static int pr_cgname(char *restrict const outbuf,const proc_t *restrict const pp) {
static int pr_cgroup(char *restrict const outbuf,const proc_t *restrict const pp) {
int rightward = max_rightward;
int i;
char *name;
if ((name = strstr(*pp->cgroup, ":name=")) != NULL) {
name += 6;
if (name != '\0') {
escape_str(outbuf, name, OUTBUF_SIZE, &rightward);
return max_rightward - rightward;
}
}
/* fallback: use full cgroup for name */
return pr_cgroup(outbuf, pp);
escaped_copy(outbuf, *pp->cgroup, OUTBUF_SIZE, &rightward);
return max_rightward-rightward;
}
/* Non-standard, from SunOS 5 */
......
This diff is collapsed.
......@@ -252,6 +252,7 @@ static const char Graph_bars[] = "||||||||||||||||||||||||||||||||||||||||||||||
* routine may serve more than one column.
*/
SCB_STRS(CGN, cgname)
SCB_STRS(CGR, cgroup[0])
SCB_STRV(CMD, Frame_cmdlin, cmdline, cmd)
SCB_NUM1(COD, trs)
......@@ -1789,13 +1790,14 @@ static FLD_t Fieldstab[] = {
{ 6, SK_Kb, A_right, SF(RZA), L_status },
{ 6, SK_Kb, A_right, SF(RZF), L_status },
{ 6, SK_Kb, A_right, SF(RZL), L_status },
{ 6, SK_Kb, A_right, SF(RZS), L_status }
{ 6, SK_Kb, A_right, SF(RZS), L_status },
#else
{ 4, SK_Kb, A_right, SF(RZA), L_status },
{ 4, SK_Kb, A_right, SF(RZF), L_status },
{ 4, SK_Kb, A_right, SF(RZL), L_status },
{ 4, SK_Kb, A_right, SF(RZS), L_status }
{ 4, SK_Kb, A_right, SF(RZS), L_status },
#endif
{ -1, -1, A_left, SF(CGN), L_CGROUP }
#undef SF
#undef A_left
#undef A_right
......@@ -5337,6 +5339,9 @@ static const char *task_show (const WIN_t *q, const proc_t *p) {
}
break;
#endif
case EU_CGN:
makeVAR(p->cgname);
break;
case EU_CGR:
makeVAR(p->cgroup[0]);
break;
......
......@@ -204,6 +204,7 @@ enum pflag {
EU_NS1, EU_NS2, EU_NS3, EU_NS4, EU_NS5, EU_NS6,
EU_LXC,
EU_RZA, EU_RZF, EU_RZL, EU_RZS,
EU_CGN,
#ifdef USE_X_COLHDR
// not really pflags, used with tbl indexing
EU_MAXPFLGS
......
......@@ -290,6 +290,9 @@ static void build_two_nlstabs (void) {
/* Translation Hint: maximum 'RSsh' = 4 */
Head_nlstab[EU_RZS] = _("RSsh");
Desc_nlstab[EU_RZS] = _("RES Shared (KiB)");
/* Translation Hint: maximum 'CGNAME' = 7 */
Head_nlstab[EU_CGN] = _("CGNAME");
Desc_nlstab[EU_CGN] = _("Control Group name");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment