Print this page
2989 Eliminate use of LOGNAME_MAX in ON
1166 useradd have warning with name more 8 chars
*** 18,27 ****
--- 18,29 ----
*
* CDDL HEADER END
*/
/*
+ * Copyright (c) 2013 Gary Mills
+ *
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Portions Copyright 2009 Chad Mynhier
*/
*** 73,82 ****
--- 75,88 ----
#endif
#include <curses.h>
#include <term.h>
+ #define LOGIN_WIDTH 8
+ #define ZONE_WIDTH 28
+ #define PROJECT_WIDTH 28
+
#define PSINFO_HEADER_PROC \
" PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP "
#define PSINFO_HEADER_PROC_LGRP \
" PID USERNAME SIZE RSS STATE PRI NICE TIME CPU LGRP PROCESS/NLWP "
#define PSINFO_HEADER_LWP \
*** 106,117 ****
#define PSINFO_LINE \
"%6d %-8s %5s %5s %-6s %3s %3s %9s %3.3s%% %-.16s/%d"
#define PSINFO_LINE_LGRP \
"%6d %-8s %5s %5s %-6s %3s %3s %9s %3.3s%% %4d %-.16s/%d"
#define USAGE_LINE \
! "%6d %-8s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s "\
! "%3.3s %-.12s/%d"
#define USER_LINE \
"%6d %-8s %5.5s %5.5s %3.3s%% %9s %3.3s%%"
#define TASK_LINE \
"%6d %8d %5s %5s %3.3s%% %9s %3.3s%% %28s"
#define PROJECT_LINE \
--- 112,123 ----
#define PSINFO_LINE \
"%6d %-8s %5s %5s %-6s %3s %3s %9s %3.3s%% %-.16s/%d"
#define PSINFO_LINE_LGRP \
"%6d %-8s %5s %5s %-6s %3s %3s %9s %3.3s%% %4d %-.16s/%d"
#define USAGE_LINE \
! "%6d %-8s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s "\
! "%3.3s %3.3s %-.12s/%d"
#define USER_LINE \
"%6d %-8s %5.5s %5.5s %3.3s%% %9s %3.3s%%"
#define TASK_LINE \
"%6d %8d %5s %5s %3.3s%% %9s %3.3s%% %28s"
#define PROJECT_LINE \
*** 352,362 ****
char usr[4], sys[4], trp[4], tfl[4];
char dfl[4], lck[4], slp[4], lat[4];
char vcx[4], icx[4], scl[4], sig[4];
char psize[6], prssize[6], pmem[6], pcpu[6], ptime[12];
char pstate[7], pnice[4], ppri[4];
! char pname[LOGNAME_MAX+1];
char projname[PROJNAME_MAX+1];
char zonename[ZONENAME_MAX+1];
float cpu, mem;
double loadavg[3] = {0, 0, 0};
int i, lwpid;
--- 358,368 ----
char usr[4], sys[4], trp[4], tfl[4];
char dfl[4], lck[4], slp[4], lat[4];
char vcx[4], icx[4], scl[4], sig[4];
char psize[6], prssize[6], pmem[6], pcpu[6], ptime[12];
char pstate[7], pnice[4], ppri[4];
! char pname[LOGNAME_MAX_ILLUMOS+1];
char projname[PROJNAME_MAX+1];
char zonename[ZONENAME_MAX+1];
float cpu, mem;
double loadavg[3] = {0, 0, 0};
int i, lwpid;
*** 444,463 ****
cpu = id->id_pctcpu;
if (id->id_sizematch == B_FALSE && total_mem >= 100)
mem = (100 * id->id_pctmem) / total_mem;
else
mem = id->id_pctmem;
! if (list->l_type == LT_USERS)
! pwd_getname(id->id_uid, pname, LOGNAME_MAX + 1,
! opts.o_outpmode & OPT_NORESOLVE);
! else if (list->l_type == LT_ZONES)
getzonename(id->id_zoneid, zonename,
! ZONENAME_MAX);
! else
getprojname(id->id_projid, projname,
! PROJNAME_MAX,
! opts.o_outpmode & OPT_NORESOLVE);
Format_size(psize, id->id_size, 6);
Format_size(prssize, id->id_rssize, 6);
Format_pct(pmem, mem, 4);
Format_pct(pcpu, cpu, 4);
Format_time(ptime, id->id_time, 10);
--- 450,476 ----
cpu = id->id_pctcpu;
if (id->id_sizematch == B_FALSE && total_mem >= 100)
mem = (100 * id->id_pctmem) / total_mem;
else
mem = id->id_pctmem;
! if (list->l_type == LT_USERS) {
! pwd_getname(id->id_uid, pname, sizeof (pname),
! opts.o_outpmode & OPT_NORESOLVE,
! opts.o_outpmode & OPT_TERMCAP,
! LOGIN_WIDTH);
! } else if (list->l_type == LT_ZONES) {
getzonename(id->id_zoneid, zonename,
! sizeof (zonename) - 1,
! opts.o_outpmode & OPT_TERMCAP,
! ZONE_WIDTH);
! } else {
getprojname(id->id_projid, projname,
! sizeof (projname) - 1,
! opts.o_outpmode & OPT_NORESOLVE,
! opts.o_outpmode & OPT_TERMCAP,
! PROJECT_WIDTH);
! }
Format_size(psize, id->id_size, 6);
Format_size(prssize, id->id_rssize, 6);
Format_pct(pmem, mem, 4);
Format_pct(pcpu, cpu, 4);
Format_time(ptime, id->id_time, 10);
*** 486,497 ****
if (opts.o_outpmode & OPT_LWPS)
lwpid = lwp->li_info.pr_lwp.pr_lwpid;
else
lwpid = lwp->li_info.pr_nlwp +
lwp->li_info.pr_nzomb;
! pwd_getname(lwp->li_info.pr_uid, pname, LOGNAME_MAX + 1,
! opts.o_outpmode & OPT_NORESOLVE);
if (opts.o_outpmode & OPT_PSINFO) {
Format_size(psize, lwp->li_info.pr_size, 6);
Format_size(prssize, lwp->li_info.pr_rssize, 6);
Format_state(pstate,
lwp->li_info.pr_lwp.pr_sname,
--- 499,512 ----
if (opts.o_outpmode & OPT_LWPS)
lwpid = lwp->li_info.pr_lwp.pr_lwpid;
else
lwpid = lwp->li_info.pr_nlwp +
lwp->li_info.pr_nzomb;
! pwd_getname(lwp->li_info.pr_uid, pname, sizeof (pname),
! opts.o_outpmode & OPT_NORESOLVE,
! opts.o_outpmode & OPT_TERMCAP,
! LOGIN_WIDTH);
if (opts.o_outpmode & OPT_PSINFO) {
Format_size(psize, lwp->li_info.pr_size, 6);
Format_size(prssize, lwp->li_info.pr_rssize, 6);
Format_state(pstate,
lwp->li_info.pr_lwp.pr_sname,
*** 520,537 ****
(void) putchar('\r');
stripfname(lwp->li_info.pr_fname);
if (opts.o_outpmode & OPT_LGRP) {
(void) printf(PSINFO_LINE_LGRP,
(int)lwp->li_info.pr_pid, pname,
! psize, prssize, pstate, ppri, pnice,
! ptime, pcpu,
(int)lwp->li_info.pr_lwp.pr_lgrp,
lwp->li_info.pr_fname, lwpid);
} else {
(void) printf(PSINFO_LINE,
(int)lwp->li_info.pr_pid, pname,
! psize, prssize, pstate, ppri, pnice,
ptime, pcpu,
lwp->li_info.pr_fname, lwpid);
}
(void) putp(t_eol);
(void) putchar('\n');
--- 535,553 ----
(void) putchar('\r');
stripfname(lwp->li_info.pr_fname);
if (opts.o_outpmode & OPT_LGRP) {
(void) printf(PSINFO_LINE_LGRP,
(int)lwp->li_info.pr_pid, pname,
! psize, prssize, pstate,
! ppri, pnice, ptime, pcpu,
(int)lwp->li_info.pr_lwp.pr_lgrp,
lwp->li_info.pr_fname, lwpid);
} else {
(void) printf(PSINFO_LINE,
(int)lwp->li_info.pr_pid, pname,
! psize, prssize,
! pstate, ppri, pnice,
ptime, pcpu,
lwp->li_info.pr_fname, lwpid);
}
(void) putp(t_eol);
(void) putchar('\n');