14b88c807SRodney W. Grimes /*- 24b88c807SRodney W. Grimes * Copyright (c) 1990, 1993, 1994 34b88c807SRodney W. Grimes * The Regents of the University of California. All rights reserved. 44b88c807SRodney W. Grimes * 54b88c807SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 64b88c807SRodney W. Grimes * modification, are permitted provided that the following conditions 74b88c807SRodney W. Grimes * are met: 84b88c807SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 94b88c807SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 104b88c807SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 114b88c807SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 124b88c807SRodney W. Grimes * documentation and/or other materials provided with the distribution. 134b88c807SRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 144b88c807SRodney W. Grimes * must display the following acknowledgement: 154b88c807SRodney W. Grimes * This product includes software developed by the University of 164b88c807SRodney W. Grimes * California, Berkeley and its contributors. 174b88c807SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 184b88c807SRodney W. Grimes * may be used to endorse or promote products derived from this software 194b88c807SRodney W. Grimes * without specific prior written permission. 204b88c807SRodney W. Grimes * 214b88c807SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 224b88c807SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 234b88c807SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 244b88c807SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 254b88c807SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 264b88c807SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 274b88c807SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 284b88c807SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 294b88c807SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 304b88c807SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 314b88c807SRodney W. Grimes * SUCH DAMAGE. 324b88c807SRodney W. Grimes */ 334b88c807SRodney W. Grimes 34c9a8d1f4SPhilippe Charnier #if 0 35871e8d8cSMark Murray #ifndef lint 36c9a8d1f4SPhilippe Charnier static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; 374b88c807SRodney W. Grimes #endif /* not lint */ 38871e8d8cSMark Murray #endif 392749b141SDavid E. O'Brien #include <sys/cdefs.h> 402749b141SDavid E. O'Brien __FBSDID("$FreeBSD$"); 414b88c807SRodney W. Grimes 424b88c807SRodney W. Grimes #include <sys/param.h> 434b88c807SRodney W. Grimes #include <sys/time.h> 444b88c807SRodney W. Grimes #include <sys/resource.h> 454b88c807SRodney W. Grimes #include <sys/proc.h> 464b88c807SRodney W. Grimes #include <sys/stat.h> 474b88c807SRodney W. Grimes 482af538ebSRobert Watson #include <sys/mac.h> 498b9b0e39SPoul-Henning Kamp #include <sys/user.h> 504b88c807SRodney W. Grimes #include <sys/sysctl.h> 514b88c807SRodney W. Grimes 524b88c807SRodney W. Grimes #include <err.h> 53576541a9SWarner Losh #include <grp.h> 54f59105eeSAndrey A. Chernov #include <langinfo.h> 558073a93cSAndrey A. Chernov #include <locale.h> 564b88c807SRodney W. Grimes #include <math.h> 574b88c807SRodney W. Grimes #include <nlist.h> 58576541a9SWarner Losh #include <pwd.h> 594b88c807SRodney W. Grimes #include <stddef.h> 604b88c807SRodney W. Grimes #include <stdio.h> 614b88c807SRodney W. Grimes #include <stdlib.h> 624b88c807SRodney W. Grimes #include <string.h> 63871e8d8cSMark Murray #include <unistd.h> 644b88c807SRodney W. Grimes #include <vis.h> 654b88c807SRodney W. Grimes 664b88c807SRodney W. Grimes #include "ps.h" 674b88c807SRodney W. Grimes 686327ab9cSPeter Wemm #define ps_pgtok(a) (((a) * getpagesize()) / 1024) 69871e8d8cSMark Murray 704b88c807SRodney W. Grimes void 7146251ddeSWarner Losh printheader(void) 724b88c807SRodney W. Grimes { 734b88c807SRodney W. Grimes VAR *v; 744b88c807SRodney W. Grimes struct varent *vent; 7501e5f166STim J. Robbins int allempty; 764b88c807SRodney W. Grimes 7701e5f166STim J. Robbins allempty = 1; 7801e5f166STim J. Robbins for (vent = vhead; vent; vent = vent->next) 7901e5f166STim J. Robbins if (*vent->var->header != '\0') { 8001e5f166STim J. Robbins allempty = 0; 8101e5f166STim J. Robbins break; 8201e5f166STim J. Robbins } 8301e5f166STim J. Robbins if (allempty) 8401e5f166STim J. Robbins return; 854b88c807SRodney W. Grimes for (vent = vhead; vent; vent = vent->next) { 864b88c807SRodney W. Grimes v = vent->var; 874b88c807SRodney W. Grimes if (v->flag & LJUST) { 884b88c807SRodney W. Grimes if (vent->next == NULL) /* last one */ 894b88c807SRodney W. Grimes (void)printf("%s", v->header); 904b88c807SRodney W. Grimes else 914b88c807SRodney W. Grimes (void)printf("%-*s", v->width, v->header); 924b88c807SRodney W. Grimes } else 934b88c807SRodney W. Grimes (void)printf("%*s", v->width, v->header); 944b88c807SRodney W. Grimes if (vent->next != NULL) 954b88c807SRodney W. Grimes (void)putchar(' '); 964b88c807SRodney W. Grimes } 974b88c807SRodney W. Grimes (void)putchar('\n'); 984b88c807SRodney W. Grimes } 994b88c807SRodney W. Grimes 1004b88c807SRodney W. Grimes void 10103334017SJuli Mallett arguments(KINFO *k, VARENT *ve) 10203334017SJuli Mallett { 10303334017SJuli Mallett VAR *v; 10403334017SJuli Mallett int left; 10503334017SJuli Mallett char *cp, *vis_args; 10603334017SJuli Mallett 10703334017SJuli Mallett v = ve->var; 10803334017SJuli Mallett 10903334017SJuli Mallett if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL) 11003334017SJuli Mallett errx(1, "malloc failed"); 11103334017SJuli Mallett strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH); 11203334017SJuli Mallett 11303334017SJuli Mallett if (ve->next == NULL) { 11403334017SJuli Mallett /* last field */ 11503334017SJuli Mallett if (termwidth == UNLIMITED) { 11603334017SJuli Mallett (void)printf("%s", vis_args); 11703334017SJuli Mallett } else { 11803334017SJuli Mallett left = termwidth - (totwidth - v->width); 11903334017SJuli Mallett if (left < 1) /* already wrapped, just use std width */ 12003334017SJuli Mallett left = v->width; 12103334017SJuli Mallett for (cp = vis_args; --left >= 0 && *cp != '\0';) 12203334017SJuli Mallett (void)putchar(*cp++); 12303334017SJuli Mallett } 12403334017SJuli Mallett } else { 12503334017SJuli Mallett (void)printf("%-*.*s", v->width, v->width, vis_args); 12603334017SJuli Mallett } 12703334017SJuli Mallett free(vis_args); 12803334017SJuli Mallett } 12903334017SJuli Mallett 13003334017SJuli Mallett void 13146251ddeSWarner Losh command(KINFO *k, VARENT *ve) 1324b88c807SRodney W. Grimes { 1334b88c807SRodney W. Grimes VAR *v; 1344b88c807SRodney W. Grimes int left; 1354b88c807SRodney W. Grimes char *cp, *vis_env, *vis_args; 1364b88c807SRodney W. Grimes 137db91faacSPeter Wemm v = ve->var; 138db91faacSPeter Wemm 139db91faacSPeter Wemm if (cflag) { 1403cc273e0SJohn Polstra if (ve->next == NULL) /* last field, don't pad */ 1411f7d2501SKirk McKusick (void)printf("%s", k->ki_p->ki_comm); 1423cc273e0SJohn Polstra else 1431f7d2501SKirk McKusick (void)printf("%-*s", v->width, k->ki_p->ki_comm); 144db91faacSPeter Wemm return; 145db91faacSPeter Wemm } 146db91faacSPeter Wemm 1474b88c807SRodney W. Grimes if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL) 1484fa7d788SJuli Mallett errx(1, "malloc failed"); 1494b88c807SRodney W. Grimes strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH); 1504b88c807SRodney W. Grimes if (k->ki_env) { 1514b88c807SRodney W. Grimes if ((vis_env = malloc(strlen(k->ki_env) * 4 + 1)) == NULL) 1524fa7d788SJuli Mallett errx(1, "malloc failed"); 1534b88c807SRodney W. Grimes strvis(vis_env, k->ki_env, VIS_TAB | VIS_NL | VIS_NOSLASH); 1544b88c807SRodney W. Grimes } else 1554b88c807SRodney W. Grimes vis_env = NULL; 1564b88c807SRodney W. Grimes 1574b88c807SRodney W. Grimes if (ve->next == NULL) { 1584b88c807SRodney W. Grimes /* last field */ 1594b88c807SRodney W. Grimes if (termwidth == UNLIMITED) { 1604b88c807SRodney W. Grimes if (vis_env) 1614b88c807SRodney W. Grimes (void)printf("%s ", vis_env); 1624b88c807SRodney W. Grimes (void)printf("%s", vis_args); 1634b88c807SRodney W. Grimes } else { 1644b88c807SRodney W. Grimes left = termwidth - (totwidth - v->width); 1654b88c807SRodney W. Grimes if (left < 1) /* already wrapped, just use std width */ 1664b88c807SRodney W. Grimes left = v->width; 1674b88c807SRodney W. Grimes if ((cp = vis_env) != NULL) { 1684b88c807SRodney W. Grimes while (--left >= 0 && *cp) 1694b88c807SRodney W. Grimes (void)putchar(*cp++); 1704b88c807SRodney W. Grimes if (--left >= 0) 1714b88c807SRodney W. Grimes putchar(' '); 1724b88c807SRodney W. Grimes } 1734b88c807SRodney W. Grimes for (cp = vis_args; --left >= 0 && *cp != '\0';) 1744b88c807SRodney W. Grimes (void)putchar(*cp++); 1754b88c807SRodney W. Grimes } 1764b88c807SRodney W. Grimes } else 1774b88c807SRodney W. Grimes /* XXX env? */ 1784b88c807SRodney W. Grimes (void)printf("%-*.*s", v->width, v->width, vis_args); 1794b88c807SRodney W. Grimes free(vis_args); 1804b88c807SRodney W. Grimes if (vis_env != NULL) 1814b88c807SRodney W. Grimes free(vis_env); 1824b88c807SRodney W. Grimes } 1834b88c807SRodney W. Grimes 1844b88c807SRodney W. Grimes void 18546251ddeSWarner Losh ucomm(KINFO *k, VARENT *ve) 1864b88c807SRodney W. Grimes { 1874b88c807SRodney W. Grimes VAR *v; 1884b88c807SRodney W. Grimes 1894b88c807SRodney W. Grimes v = ve->var; 1901f7d2501SKirk McKusick (void)printf("%-*s", v->width, k->ki_p->ki_comm); 1914b88c807SRodney W. Grimes } 1924b88c807SRodney W. Grimes 1934b88c807SRodney W. Grimes void 19446251ddeSWarner Losh logname(KINFO *k, VARENT *ve) 1954b88c807SRodney W. Grimes { 1964b88c807SRodney W. Grimes VAR *v; 197ad863cacSSteve Price char *s; 1984b88c807SRodney W. Grimes 1994b88c807SRodney W. Grimes v = ve->var; 2001f7d2501SKirk McKusick (void)printf("%-*s", v->width, (s = k->ki_p->ki_login, *s) ? s : "-"); 2014b88c807SRodney W. Grimes } 2024b88c807SRodney W. Grimes 2034b88c807SRodney W. Grimes void 20446251ddeSWarner Losh state(KINFO *k, VARENT *ve) 2054b88c807SRodney W. Grimes { 206b40ce416SJulian Elischer int flag, sflag, tdflags; 2074b88c807SRodney W. Grimes char *cp; 2084b88c807SRodney W. Grimes VAR *v; 2094b88c807SRodney W. Grimes char buf[16]; 2104b88c807SRodney W. Grimes 2114b88c807SRodney W. Grimes v = ve->var; 2121f7d2501SKirk McKusick flag = k->ki_p->ki_flag; 213564efb8fSTor Egge sflag = k->ki_p->ki_sflag; 214b40ce416SJulian Elischer tdflags = k->ki_p->ki_tdflags; /* XXXKSE */ 2154b88c807SRodney W. Grimes cp = buf; 2164b88c807SRodney W. Grimes 2171f7d2501SKirk McKusick switch (k->ki_p->ki_stat) { 2184b88c807SRodney W. Grimes 2194b88c807SRodney W. Grimes case SSTOP: 2204b88c807SRodney W. Grimes *cp = 'T'; 2214b88c807SRodney W. Grimes break; 2224b88c807SRodney W. Grimes 2234b88c807SRodney W. Grimes case SSLEEP: 224b40ce416SJulian Elischer if (tdflags & TDF_SINTR) /* interruptable (long) */ 2251f7d2501SKirk McKusick *cp = k->ki_p->ki_slptime >= MAXSLP ? 'I' : 'S'; 2264b88c807SRodney W. Grimes else 2274b88c807SRodney W. Grimes *cp = 'D'; 2284b88c807SRodney W. Grimes break; 2294b88c807SRodney W. Grimes 2304b88c807SRodney W. Grimes case SRUN: 2314b88c807SRodney W. Grimes case SIDL: 2324b88c807SRodney W. Grimes *cp = 'R'; 2334b88c807SRodney W. Grimes break; 2344b88c807SRodney W. Grimes 2350384fff8SJason Evans case SWAIT: 2360384fff8SJason Evans *cp = 'W'; 2370384fff8SJason Evans break; 2380384fff8SJason Evans 2390d632649SJohn Baldwin case SLOCK: 2400d632649SJohn Baldwin *cp = 'L'; 2410384fff8SJason Evans break; 2420384fff8SJason Evans 2434b88c807SRodney W. Grimes case SZOMB: 2444b88c807SRodney W. Grimes *cp = 'Z'; 2454b88c807SRodney W. Grimes break; 2464b88c807SRodney W. Grimes 2474b88c807SRodney W. Grimes default: 2484b88c807SRodney W. Grimes *cp = '?'; 2494b88c807SRodney W. Grimes } 2504b88c807SRodney W. Grimes cp++; 251e0aa5ab7SJohn Baldwin if (!(sflag & PS_INMEM)) 2524b88c807SRodney W. Grimes *cp++ = 'W'; 2531f7d2501SKirk McKusick if (k->ki_p->ki_nice < NZERO) 2544b88c807SRodney W. Grimes *cp++ = '<'; 2551f7d2501SKirk McKusick else if (k->ki_p->ki_nice > NZERO) 2564b88c807SRodney W. Grimes *cp++ = 'N'; 2574b88c807SRodney W. Grimes if (flag & P_TRACED) 2584b88c807SRodney W. Grimes *cp++ = 'X'; 2591f7d2501SKirk McKusick if (flag & P_WEXIT && k->ki_p->ki_stat != SZOMB) 2604b88c807SRodney W. Grimes *cp++ = 'E'; 2614b88c807SRodney W. Grimes if (flag & P_PPWAIT) 2624b88c807SRodney W. Grimes *cp++ = 'V'; 2631f7d2501SKirk McKusick if ((flag & P_SYSTEM) || k->ki_p->ki_lock > 0) 2644b88c807SRodney W. Grimes *cp++ = 'L'; 2651f7d2501SKirk McKusick if (k->ki_p->ki_kiflag & KI_SLEADER) 2664b88c807SRodney W. Grimes *cp++ = 's'; 2671f7d2501SKirk McKusick if ((flag & P_CONTROLT) && k->ki_p->ki_pgid == k->ki_p->ki_tpgid) 2684b88c807SRodney W. Grimes *cp++ = '+'; 26975c13541SPoul-Henning Kamp if (flag & P_JAILED) 27075c13541SPoul-Henning Kamp *cp++ = 'J'; 2714b88c807SRodney W. Grimes *cp = '\0'; 2724b88c807SRodney W. Grimes (void)printf("%-*s", v->width, buf); 2734b88c807SRodney W. Grimes } 2744b88c807SRodney W. Grimes 2754b88c807SRodney W. Grimes void 27646251ddeSWarner Losh pri(KINFO *k, VARENT *ve) 2774b88c807SRodney W. Grimes { 2784b88c807SRodney W. Grimes VAR *v; 2794b88c807SRodney W. Grimes 2804b88c807SRodney W. Grimes v = ve->var; 2814c85452bSJake Burkholder (void)printf("%*d", v->width, k->ki_p->ki_pri.pri_level - PZERO); 2824b88c807SRodney W. Grimes } 2834b88c807SRodney W. Grimes 2844b88c807SRodney W. Grimes void 28546251ddeSWarner Losh uname(KINFO *k, VARENT *ve) 2864b88c807SRodney W. Grimes { 2874b88c807SRodney W. Grimes VAR *v; 2884b88c807SRodney W. Grimes 2894b88c807SRodney W. Grimes v = ve->var; 290e8eef4bbSJuli Mallett (void)printf("%-*s", v->width, user_from_uid(k->ki_p->ki_uid, 0)); 2914b88c807SRodney W. Grimes } 2924b88c807SRodney W. Grimes 2936a2d726bSJordan K. Hubbard int 29446251ddeSWarner Losh s_uname(KINFO *k) 2956a2d726bSJordan K. Hubbard { 2961f7d2501SKirk McKusick return (strlen(user_from_uid(k->ki_p->ki_uid, 0))); 2976a2d726bSJordan K. Hubbard } 2986a2d726bSJordan K. Hubbard 2994b88c807SRodney W. Grimes void 300e8eef4bbSJuli Mallett rgroupname(KINFO *k, VARENT *ve) 301e8eef4bbSJuli Mallett { 302e8eef4bbSJuli Mallett VAR *v; 303e8eef4bbSJuli Mallett 304e8eef4bbSJuli Mallett v = ve->var; 305e8eef4bbSJuli Mallett (void)printf("%-*s", v->width, group_from_gid(k->ki_p->ki_rgid, 0)); 306e8eef4bbSJuli Mallett } 307e8eef4bbSJuli Mallett 308e8eef4bbSJuli Mallett int 309e8eef4bbSJuli Mallett s_rgroupname(KINFO *k) 310e8eef4bbSJuli Mallett { 311e8eef4bbSJuli Mallett return (strlen(group_from_gid(k->ki_p->ki_rgid, 0))); 312e8eef4bbSJuli Mallett } 313e8eef4bbSJuli Mallett 314e8eef4bbSJuli Mallett void 31546251ddeSWarner Losh runame(KINFO *k, VARENT *ve) 3164b88c807SRodney W. Grimes { 3174b88c807SRodney W. Grimes VAR *v; 3184b88c807SRodney W. Grimes 3194b88c807SRodney W. Grimes v = ve->var; 320e8eef4bbSJuli Mallett (void)printf("%-*s", v->width, user_from_uid(k->ki_p->ki_ruid, 0)); 3214b88c807SRodney W. Grimes } 3224b88c807SRodney W. Grimes 3236a2d726bSJordan K. Hubbard int 32446251ddeSWarner Losh s_runame(KINFO *k) 3256a2d726bSJordan K. Hubbard { 3261f7d2501SKirk McKusick return (strlen(user_from_uid(k->ki_p->ki_ruid, 0))); 3276a2d726bSJordan K. Hubbard } 3286a2d726bSJordan K. Hubbard 329f3073b05SJuli Mallett 330f3073b05SJuli Mallett void 33146251ddeSWarner Losh tdev(KINFO *k, VARENT *ve) 3324b88c807SRodney W. Grimes { 3334b88c807SRodney W. Grimes VAR *v; 3344b88c807SRodney W. Grimes dev_t dev; 3354b88c807SRodney W. Grimes char buff[16]; 3364b88c807SRodney W. Grimes 3374b88c807SRodney W. Grimes v = ve->var; 3381f7d2501SKirk McKusick dev = k->ki_p->ki_tdev; 3394b88c807SRodney W. Grimes if (dev == NODEV) 3404b88c807SRodney W. Grimes (void)printf("%*s", v->width, "??"); 3414b88c807SRodney W. Grimes else { 3424b88c807SRodney W. Grimes (void)snprintf(buff, sizeof(buff), 3434b88c807SRodney W. Grimes "%d/%d", major(dev), minor(dev)); 3444b88c807SRodney W. Grimes (void)printf("%*s", v->width, buff); 3454b88c807SRodney W. Grimes } 3464b88c807SRodney W. Grimes } 3474b88c807SRodney W. Grimes 3484b88c807SRodney W. Grimes void 34946251ddeSWarner Losh tname(KINFO *k, VARENT *ve) 3504b88c807SRodney W. Grimes { 3514b88c807SRodney W. Grimes VAR *v; 3524b88c807SRodney W. Grimes dev_t dev; 3534b88c807SRodney W. Grimes char *ttname; 3544b88c807SRodney W. Grimes 3554b88c807SRodney W. Grimes v = ve->var; 3561f7d2501SKirk McKusick dev = k->ki_p->ki_tdev; 3574b88c807SRodney W. Grimes if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL) 358c55931c7SPeter Wemm (void)printf("%*s ", v->width-1, "??"); 3594b88c807SRodney W. Grimes else { 360efc18e2cSAndrey A. Chernov if (strncmp(ttname, "tty", 3) == 0 || 361efc18e2cSAndrey A. Chernov strncmp(ttname, "cua", 3) == 0) 3624b88c807SRodney W. Grimes ttname += 3; 363c55931c7SPeter Wemm (void)printf("%*.*s%c", v->width-1, v->width-1, ttname, 3641f7d2501SKirk McKusick k->ki_p->ki_kiflag & KI_CTTY ? ' ' : '-'); 3654b88c807SRodney W. Grimes } 3664b88c807SRodney W. Grimes } 3674b88c807SRodney W. Grimes 3684b88c807SRodney W. Grimes void 36946251ddeSWarner Losh longtname(KINFO *k, VARENT *ve) 3704b88c807SRodney W. Grimes { 3714b88c807SRodney W. Grimes VAR *v; 3724b88c807SRodney W. Grimes dev_t dev; 3734b88c807SRodney W. Grimes char *ttname; 3744b88c807SRodney W. Grimes 3754b88c807SRodney W. Grimes v = ve->var; 3761f7d2501SKirk McKusick dev = k->ki_p->ki_tdev; 3774b88c807SRodney W. Grimes if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL) 3784b88c807SRodney W. Grimes (void)printf("%-*s", v->width, "??"); 3794b88c807SRodney W. Grimes else 3804b88c807SRodney W. Grimes (void)printf("%-*s", v->width, ttname); 3814b88c807SRodney W. Grimes } 3824b88c807SRodney W. Grimes 3834b88c807SRodney W. Grimes void 38446251ddeSWarner Losh started(KINFO *k, VARENT *ve) 3854b88c807SRodney W. Grimes { 3864b88c807SRodney W. Grimes VAR *v; 387f8ec5fe2SBruce Evans time_t then; 3884b88c807SRodney W. Grimes struct tm *tp; 3894b88c807SRodney W. Grimes char buf[100]; 390f59105eeSAndrey A. Chernov static int use_ampm = -1; 3914b88c807SRodney W. Grimes 3924b88c807SRodney W. Grimes v = ve->var; 3931f7d2501SKirk McKusick if (!k->ki_valid) { 3944b88c807SRodney W. Grimes (void)printf("%-*s", v->width, "-"); 3954b88c807SRodney W. Grimes return; 3964b88c807SRodney W. Grimes } 3974b88c807SRodney W. Grimes 398f59105eeSAndrey A. Chernov if (use_ampm < 0) 399f59105eeSAndrey A. Chernov use_ampm = (*nl_langinfo(T_FMT_AMPM) != '\0'); 400f59105eeSAndrey A. Chernov 4011f7d2501SKirk McKusick then = k->ki_p->ki_start.tv_sec; 402f8ec5fe2SBruce Evans tp = localtime(&then); 4031f7d2501SKirk McKusick if (now - k->ki_p->ki_start.tv_sec < 24 * 3600) { 40408017519SAndrey A. Chernov (void)strftime(buf, sizeof(buf) - 1, 40508017519SAndrey A. Chernov use_ampm ? "%l:%M%p" : "%k:%M ", tp); 4061f7d2501SKirk McKusick } else if (now - k->ki_p->ki_start.tv_sec < 7 * 86400) { 40708017519SAndrey A. Chernov (void)strftime(buf, sizeof(buf) - 1, 40808017519SAndrey A. Chernov use_ampm ? "%a%I%p" : "%a%H ", tp); 4094b88c807SRodney W. Grimes } else 4104b88c807SRodney W. Grimes (void)strftime(buf, sizeof(buf) - 1, "%e%b%y", tp); 4114b88c807SRodney W. Grimes (void)printf("%-*s", v->width, buf); 4124b88c807SRodney W. Grimes } 4134b88c807SRodney W. Grimes 4144b88c807SRodney W. Grimes void 41546251ddeSWarner Losh lstarted(KINFO *k, VARENT *ve) 4164b88c807SRodney W. Grimes { 4174b88c807SRodney W. Grimes VAR *v; 418f8ec5fe2SBruce Evans time_t then; 4194b88c807SRodney W. Grimes char buf[100]; 4204b88c807SRodney W. Grimes 4214b88c807SRodney W. Grimes v = ve->var; 4221f7d2501SKirk McKusick if (!k->ki_valid) { 4234b88c807SRodney W. Grimes (void)printf("%-*s", v->width, "-"); 4244b88c807SRodney W. Grimes return; 4254b88c807SRodney W. Grimes } 4261f7d2501SKirk McKusick then = k->ki_p->ki_start.tv_sec; 427f8ec5fe2SBruce Evans (void)strftime(buf, sizeof(buf) -1, "%c", localtime(&then)); 4284b88c807SRodney W. Grimes (void)printf("%-*s", v->width, buf); 4294b88c807SRodney W. Grimes } 4304b88c807SRodney W. Grimes 4314b88c807SRodney W. Grimes void 4320d632649SJohn Baldwin lockname(KINFO *k, VARENT *ve) 433fd5f30bfSJohn Baldwin { 434fd5f30bfSJohn Baldwin VAR *v; 435fd5f30bfSJohn Baldwin 436fd5f30bfSJohn Baldwin v = ve->var; 4370d632649SJohn Baldwin if (k->ki_p->ki_kiflag & KI_LOCKBLOCK) { 4380d632649SJohn Baldwin if (k->ki_p->ki_lockname[0] != 0) 439fd5f30bfSJohn Baldwin (void)printf("%-*.*s", v->width, v->width, 4400d632649SJohn Baldwin k->ki_p->ki_lockname); 441fd5f30bfSJohn Baldwin else 442fd5f30bfSJohn Baldwin (void)printf("%-*s", v->width, "???"); 443fd5f30bfSJohn Baldwin } else 444fd5f30bfSJohn Baldwin (void)printf("%-*s", v->width, "-"); 445fd5f30bfSJohn Baldwin } 446fd5f30bfSJohn Baldwin 447fd5f30bfSJohn Baldwin void 44846251ddeSWarner Losh wchan(KINFO *k, VARENT *ve) 4494b88c807SRodney W. Grimes { 4504b88c807SRodney W. Grimes VAR *v; 4514b88c807SRodney W. Grimes 4524b88c807SRodney W. Grimes v = ve->var; 4531f7d2501SKirk McKusick if (k->ki_p->ki_wchan) { 4541f7d2501SKirk McKusick if (k->ki_p->ki_wmesg[0] != 0) 4554b88c807SRodney W. Grimes (void)printf("%-*.*s", v->width, v->width, 4561f7d2501SKirk McKusick k->ki_p->ki_wmesg); 4574b88c807SRodney W. Grimes else 4583929d518SDoug Rabson (void)printf("%-*lx", v->width, 4597d1192a7SPeter Wemm (long)k->ki_p->ki_wchan); 460d9a5f890SMatthew Dillon } else { 461d9a5f890SMatthew Dillon (void)printf("%-*s", v->width, "-"); 462d9a5f890SMatthew Dillon } 463d9a5f890SMatthew Dillon } 464d9a5f890SMatthew Dillon 465d9a5f890SMatthew Dillon void 466d9a5f890SMatthew Dillon mwchan(KINFO *k, VARENT *ve) 467d9a5f890SMatthew Dillon { 468d9a5f890SMatthew Dillon VAR *v; 469d9a5f890SMatthew Dillon 470d9a5f890SMatthew Dillon v = ve->var; 471d9a5f890SMatthew Dillon if (k->ki_p->ki_wchan) { 472d9a5f890SMatthew Dillon if (k->ki_p->ki_wmesg[0] != 0) 473d9a5f890SMatthew Dillon (void)printf("%-*.*s", v->width, v->width, 474d9a5f890SMatthew Dillon k->ki_p->ki_wmesg); 475d9a5f890SMatthew Dillon else 476d9a5f890SMatthew Dillon (void)printf("%-*lx", v->width, 477d9a5f890SMatthew Dillon (long)k->ki_p->ki_wchan); 4780d632649SJohn Baldwin } else if (k->ki_p->ki_kiflag & KI_LOCKBLOCK) { 4790d632649SJohn Baldwin if (k->ki_p->ki_lockname[0]) { 480d9a5f890SMatthew Dillon (void)printf("%-*.*s", v->width, v->width, 4810d632649SJohn Baldwin k->ki_p->ki_lockname); 482d9a5f890SMatthew Dillon } else { 483d9a5f890SMatthew Dillon (void)printf("%-*s", v->width, "???"); 484d9a5f890SMatthew Dillon } 485ebc1fff9SMatthew Dillon } else { 4864b88c807SRodney W. Grimes (void)printf("%-*s", v->width, "-"); 4874b88c807SRodney W. Grimes } 488ebc1fff9SMatthew Dillon } 4894b88c807SRodney W. Grimes 4904b88c807SRodney W. Grimes void 49146251ddeSWarner Losh vsize(KINFO *k, VARENT *ve) 4924b88c807SRodney W. Grimes { 4934b88c807SRodney W. Grimes VAR *v; 4944b88c807SRodney W. Grimes 4954b88c807SRodney W. Grimes v = ve->var; 496c1f903a0SBruce Evans (void)printf("%*lu", v->width, (u_long)(k->ki_p->ki_size / 1024)); 4974b88c807SRodney W. Grimes } 4984b88c807SRodney W. Grimes 4994b88c807SRodney W. Grimes void 50046251ddeSWarner Losh cputime(KINFO *k, VARENT *ve) 5014b88c807SRodney W. Grimes { 5024b88c807SRodney W. Grimes VAR *v; 5034b88c807SRodney W. Grimes long secs; 5044b88c807SRodney W. Grimes long psecs; /* "parts" of a second. first micro, then centi */ 5054b88c807SRodney W. Grimes char obuff[128]; 5068073a93cSAndrey A. Chernov static char decimal_point = 0; 5074b88c807SRodney W. Grimes 5088073a93cSAndrey A. Chernov if (!decimal_point) 5098073a93cSAndrey A. Chernov decimal_point = localeconv()->decimal_point[0]; 5104b88c807SRodney W. Grimes v = ve->var; 5111f7d2501SKirk McKusick if (k->ki_p->ki_stat == SZOMB || !k->ki_valid) { 5125832a752SBruce Evans secs = 0; 5135832a752SBruce Evans psecs = 0; 5144b88c807SRodney W. Grimes } else { 5154b88c807SRodney W. Grimes /* 5164b88c807SRodney W. Grimes * This counts time spent handling interrupts. We could 5174b88c807SRodney W. Grimes * fix this, but it is not 100% trivial (and interrupt 5184b88c807SRodney W. Grimes * time fractions only work on the sparc anyway). XXX 5194b88c807SRodney W. Grimes */ 5201f7d2501SKirk McKusick secs = k->ki_p->ki_runtime / 1000000; 5211f7d2501SKirk McKusick psecs = k->ki_p->ki_runtime % 1000000; 5224b88c807SRodney W. Grimes if (sumrusage) { 5231f7d2501SKirk McKusick secs += k->ki_p->ki_childtime.tv_sec; 5241f7d2501SKirk McKusick psecs += k->ki_p->ki_childtime.tv_usec; 5254b88c807SRodney W. Grimes } 5264b88c807SRodney W. Grimes /* 5274b88c807SRodney W. Grimes * round and scale to 100's 5284b88c807SRodney W. Grimes */ 5295832a752SBruce Evans psecs = (psecs + 5000) / 10000; 5305832a752SBruce Evans secs += psecs / 100; 5315832a752SBruce Evans psecs = psecs % 100; 5325832a752SBruce Evans } 5334b88c807SRodney W. Grimes (void)snprintf(obuff, sizeof(obuff), 5348073a93cSAndrey A. Chernov "%3ld:%02ld%c%02ld", secs/60, secs%60, decimal_point, psecs); 5354b88c807SRodney W. Grimes (void)printf("%*s", v->width, obuff); 5364b88c807SRodney W. Grimes } 5374b88c807SRodney W. Grimes 53876e1a9feSJuli Mallett void 53976e1a9feSJuli Mallett elapsed(KINFO *k, VARENT *ve) 54076e1a9feSJuli Mallett { 54176e1a9feSJuli Mallett VAR *v; 54276e1a9feSJuli Mallett time_t secs; 54376e1a9feSJuli Mallett char obuff[128]; 54476e1a9feSJuli Mallett 54576e1a9feSJuli Mallett v = ve->var; 54676e1a9feSJuli Mallett 54776e1a9feSJuli Mallett secs = now - k->ki_p->ki_start.tv_sec; 548c3f1b5a9SJuli Mallett (void)snprintf(obuff, sizeof(obuff), "%3ld:%02ld", (long)secs/60, 549c3f1b5a9SJuli Mallett (long)secs%60); 55076e1a9feSJuli Mallett (void)printf("%*s", v->width, obuff); 55176e1a9feSJuli Mallett } 55276e1a9feSJuli Mallett 5534b88c807SRodney W. Grimes double 554871e8d8cSMark Murray getpcpu(const KINFO *k) 5554b88c807SRodney W. Grimes { 5564b88c807SRodney W. Grimes static int failure; 5574b88c807SRodney W. Grimes 5584b88c807SRodney W. Grimes if (!nlistread) 5594b88c807SRodney W. Grimes failure = donlist(); 5604b88c807SRodney W. Grimes if (failure) 5614b88c807SRodney W. Grimes return (0.0); 5624b88c807SRodney W. Grimes 5634b88c807SRodney W. Grimes #define fxtofl(fixpt) ((double)(fixpt) / fscale) 5644b88c807SRodney W. Grimes 5654b88c807SRodney W. Grimes /* XXX - I don't like this */ 566e0aa5ab7SJohn Baldwin if (k->ki_p->ki_swtime == 0 || (k->ki_p->ki_sflag & PS_INMEM) == 0) 5674b88c807SRodney W. Grimes return (0.0); 5684b88c807SRodney W. Grimes if (rawcpu) 5691f7d2501SKirk McKusick return (100.0 * fxtofl(k->ki_p->ki_pctcpu)); 5701f7d2501SKirk McKusick return (100.0 * fxtofl(k->ki_p->ki_pctcpu) / 5711f7d2501SKirk McKusick (1.0 - exp(k->ki_p->ki_swtime * log(fxtofl(ccpu))))); 5724b88c807SRodney W. Grimes } 5734b88c807SRodney W. Grimes 5744b88c807SRodney W. Grimes void 57546251ddeSWarner Losh pcpu(KINFO *k, VARENT *ve) 5764b88c807SRodney W. Grimes { 5774b88c807SRodney W. Grimes VAR *v; 5784b88c807SRodney W. Grimes 5794b88c807SRodney W. Grimes v = ve->var; 5804b88c807SRodney W. Grimes (void)printf("%*.1f", v->width, getpcpu(k)); 5814b88c807SRodney W. Grimes } 5824b88c807SRodney W. Grimes 583871e8d8cSMark Murray static double 58446251ddeSWarner Losh getpmem(KINFO *k) 5854b88c807SRodney W. Grimes { 5864b88c807SRodney W. Grimes static int failure; 5874b88c807SRodney W. Grimes double fracmem; 5884b88c807SRodney W. Grimes 5894b88c807SRodney W. Grimes if (!nlistread) 5904b88c807SRodney W. Grimes failure = donlist(); 5914b88c807SRodney W. Grimes if (failure) 5924b88c807SRodney W. Grimes return (0.0); 5934b88c807SRodney W. Grimes 594e0aa5ab7SJohn Baldwin if ((k->ki_p->ki_sflag & PS_INMEM) == 0) 5954b88c807SRodney W. Grimes return (0.0); 5964b88c807SRodney W. Grimes /* XXX want pmap ptpages, segtab, etc. (per architecture) */ 5974b88c807SRodney W. Grimes /* XXX don't have info about shared */ 59885012e7cSPeter Wemm fracmem = ((float)k->ki_p->ki_rssize)/mempages; 5994b88c807SRodney W. Grimes return (100.0 * fracmem); 6004b88c807SRodney W. Grimes } 6014b88c807SRodney W. Grimes 6024b88c807SRodney W. Grimes void 60346251ddeSWarner Losh pmem(KINFO *k, VARENT *ve) 6044b88c807SRodney W. Grimes { 6054b88c807SRodney W. Grimes VAR *v; 6064b88c807SRodney W. Grimes 6074b88c807SRodney W. Grimes v = ve->var; 6084b88c807SRodney W. Grimes (void)printf("%*.1f", v->width, getpmem(k)); 6094b88c807SRodney W. Grimes } 6104b88c807SRodney W. Grimes 6114b88c807SRodney W. Grimes void 61246251ddeSWarner Losh pagein(KINFO *k, VARENT *ve) 6134b88c807SRodney W. Grimes { 6144b88c807SRodney W. Grimes VAR *v; 6154b88c807SRodney W. Grimes 6164b88c807SRodney W. Grimes v = ve->var; 6170fd510b7SJoerg Wunsch (void)printf("%*ld", v->width, 6181f7d2501SKirk McKusick k->ki_valid ? k->ki_p->ki_rusage.ru_majflt : 0); 6194b88c807SRodney W. Grimes } 6204b88c807SRodney W. Grimes 621871e8d8cSMark Murray /* ARGSUSED */ 6224b88c807SRodney W. Grimes void 623871e8d8cSMark Murray maxrss(KINFO *k __unused, VARENT *ve) 6244b88c807SRodney W. Grimes { 6254b88c807SRodney W. Grimes VAR *v; 6264b88c807SRodney W. Grimes 6274b88c807SRodney W. Grimes v = ve->var; 628940cca66SPeter Wemm /* XXX not yet */ 6294b88c807SRodney W. Grimes (void)printf("%*s", v->width, "-"); 6304b88c807SRodney W. Grimes } 6314b88c807SRodney W. Grimes 6324b88c807SRodney W. Grimes void 63346251ddeSWarner Losh priorityr(KINFO *k, VARENT *ve) 634ad863cacSSteve Price { 635ad863cacSSteve Price VAR *v; 636871e8d8cSMark Murray struct priority *lpri; 637ad863cacSSteve Price char str[8]; 6384c85452bSJake Burkholder unsigned class, level; 639ad863cacSSteve Price 640ad863cacSSteve Price v = ve->var; 641871e8d8cSMark Murray lpri = (struct priority *) ((char *)k + v->off); 642871e8d8cSMark Murray class = lpri->pri_class; 643871e8d8cSMark Murray level = lpri->pri_level; 6444c85452bSJake Burkholder switch (class) { 6454c85452bSJake Burkholder case PRI_REALTIME: 6464c85452bSJake Burkholder snprintf(str, sizeof(str), "real:%u", level); 647ad863cacSSteve Price break; 6484c85452bSJake Burkholder case PRI_TIMESHARE: 649ad863cacSSteve Price strncpy(str, "normal", sizeof(str)); 650ad863cacSSteve Price break; 6514c85452bSJake Burkholder case PRI_IDLE: 6524c85452bSJake Burkholder snprintf(str, sizeof(str), "idle:%u", level); 653ad863cacSSteve Price break; 654ad863cacSSteve Price default: 6554c85452bSJake Burkholder snprintf(str, sizeof(str), "%u:%u", class, level); 656ad863cacSSteve Price break; 657ad863cacSSteve Price } 658ad863cacSSteve Price str[sizeof(str) - 1] = '\0'; 659ad863cacSSteve Price (void)printf("%*s", v->width, str); 660ad863cacSSteve Price } 661ad863cacSSteve Price 6624b88c807SRodney W. Grimes /* 6634b88c807SRodney W. Grimes * Generic output routines. Print fields from various prototype 6644b88c807SRodney W. Grimes * structures. 6654b88c807SRodney W. Grimes */ 6664b88c807SRodney W. Grimes static void 667ffe25988SJuli Mallett printval(void *bp, VAR *v) 6684b88c807SRodney W. Grimes { 6694b88c807SRodney W. Grimes static char ofmt[32] = "%"; 670fdbec398SJuli Mallett const char *fcp; 671fdbec398SJuli Mallett char *cp; 6724b88c807SRodney W. Grimes 6734b88c807SRodney W. Grimes cp = ofmt + 1; 6744b88c807SRodney W. Grimes fcp = v->fmt; 6754b88c807SRodney W. Grimes if (v->flag & LJUST) 6764b88c807SRodney W. Grimes *cp++ = '-'; 6774b88c807SRodney W. Grimes *cp++ = '*'; 6780fd510b7SJoerg Wunsch while ((*cp++ = *fcp++)); 6794b88c807SRodney W. Grimes 6804b88c807SRodney W. Grimes switch (v->type) { 6814b88c807SRodney W. Grimes case CHAR: 6824b88c807SRodney W. Grimes (void)printf(ofmt, v->width, *(char *)bp); 6834b88c807SRodney W. Grimes break; 6844b88c807SRodney W. Grimes case UCHAR: 6854b88c807SRodney W. Grimes (void)printf(ofmt, v->width, *(u_char *)bp); 6864b88c807SRodney W. Grimes break; 6874b88c807SRodney W. Grimes case SHORT: 6884b88c807SRodney W. Grimes (void)printf(ofmt, v->width, *(short *)bp); 6894b88c807SRodney W. Grimes break; 6904b88c807SRodney W. Grimes case USHORT: 6914b88c807SRodney W. Grimes (void)printf(ofmt, v->width, *(u_short *)bp); 6924b88c807SRodney W. Grimes break; 6933929d518SDoug Rabson case INT: 6943929d518SDoug Rabson (void)printf(ofmt, v->width, *(int *)bp); 6953929d518SDoug Rabson break; 6963929d518SDoug Rabson case UINT: 6973929d518SDoug Rabson (void)printf(ofmt, v->width, *(u_int *)bp); 6983929d518SDoug Rabson break; 6994b88c807SRodney W. Grimes case LONG: 7004b88c807SRodney W. Grimes (void)printf(ofmt, v->width, *(long *)bp); 7014b88c807SRodney W. Grimes break; 7024b88c807SRodney W. Grimes case ULONG: 7034b88c807SRodney W. Grimes (void)printf(ofmt, v->width, *(u_long *)bp); 7044b88c807SRodney W. Grimes break; 7054b88c807SRodney W. Grimes case KPTR: 7067d1192a7SPeter Wemm (void)printf(ofmt, v->width, *(u_long *)bp); 7074b88c807SRodney W. Grimes break; 708362d62baSJuli Mallett case PGTOK: 709760bbf7dSJuli Mallett (void)printf(ofmt, v->width, ps_pgtok(*(u_long *)bp)); 710760bbf7dSJuli Mallett break; 7114b88c807SRodney W. Grimes default: 7124b88c807SRodney W. Grimes errx(1, "unknown type %d", v->type); 7134b88c807SRodney W. Grimes } 7144b88c807SRodney W. Grimes } 7154b88c807SRodney W. Grimes 7164b88c807SRodney W. Grimes void 71746251ddeSWarner Losh kvar(KINFO *k, VARENT *ve) 7184b88c807SRodney W. Grimes { 7194b88c807SRodney W. Grimes VAR *v; 7204b88c807SRodney W. Grimes 7214b88c807SRodney W. Grimes v = ve->var; 7221f7d2501SKirk McKusick printval((char *)((char *)k->ki_p + v->off), v); 7234b88c807SRodney W. Grimes } 7244b88c807SRodney W. Grimes 7254b88c807SRodney W. Grimes void 72646251ddeSWarner Losh rvar(KINFO *k, VARENT *ve) 7274b88c807SRodney W. Grimes { 7284b88c807SRodney W. Grimes VAR *v; 7294b88c807SRodney W. Grimes 7304b88c807SRodney W. Grimes v = ve->var; 7311f7d2501SKirk McKusick if (k->ki_valid) 7321f7d2501SKirk McKusick printval((char *)((char *)(&k->ki_p->ki_rusage) + v->off), v); 7334b88c807SRodney W. Grimes else 7344b88c807SRodney W. Grimes (void)printf("%*s", v->width, "-"); 7354b88c807SRodney W. Grimes } 7367304f61fSBrian Feldman 7377304f61fSBrian Feldman void 7382af538ebSRobert Watson label(KINFO *k, VARENT *ve) 7397304f61fSBrian Feldman { 7402af538ebSRobert Watson char *string; 741775bba9fSJuli Mallett mac_t proclabel; 7422af538ebSRobert Watson int error; 7437304f61fSBrian Feldman VAR *v; 7447304f61fSBrian Feldman 7457304f61fSBrian Feldman v = ve->var; 7462af538ebSRobert Watson string = NULL; 7472af538ebSRobert Watson 748775bba9fSJuli Mallett if (mac_prepare_process_label(&proclabel) == -1) { 7492af538ebSRobert Watson perror("mac_prepare_process_label"); 7502af538ebSRobert Watson goto out; 7512af538ebSRobert Watson } 7522af538ebSRobert Watson 753775bba9fSJuli Mallett error = mac_get_pid(k->ki_p->ki_pid, proclabel); 7542af538ebSRobert Watson if (error == 0) { 755775bba9fSJuli Mallett if (mac_to_text(proclabel, &string) == -1) 7562af538ebSRobert Watson string = NULL; 7572af538ebSRobert Watson } 758775bba9fSJuli Mallett mac_free(proclabel); 7592af538ebSRobert Watson 7602af538ebSRobert Watson out: 7612af538ebSRobert Watson if (string != NULL) { 7622af538ebSRobert Watson (void)printf("%-*s", v->width, string); 7632af538ebSRobert Watson free(string); 7642af538ebSRobert Watson } else 7652af538ebSRobert Watson (void)printf("%-*s", v->width, ""); 7662af538ebSRobert Watson return; 7672af538ebSRobert Watson } 7682af538ebSRobert Watson 7692af538ebSRobert Watson int 7702af538ebSRobert Watson s_label(KINFO *k) 7712af538ebSRobert Watson { 7722af538ebSRobert Watson char *string = NULL; 773775bba9fSJuli Mallett mac_t proclabel; 7742af538ebSRobert Watson int error, size = 0; 7752af538ebSRobert Watson 776775bba9fSJuli Mallett if (mac_prepare_process_label(&proclabel) == -1) { 7772af538ebSRobert Watson perror("mac_prepare_process_label"); 7782af538ebSRobert Watson return (0); 7792af538ebSRobert Watson } 780775bba9fSJuli Mallett error = mac_get_pid(k->ki_p->ki_pid, proclabel); 781775bba9fSJuli Mallett if (error == 0 && mac_to_text(proclabel, &string) == 0) { 7822af538ebSRobert Watson size = strlen(string); 7832af538ebSRobert Watson free(string); 7842af538ebSRobert Watson } 785775bba9fSJuli Mallett mac_free(proclabel); 7862af538ebSRobert Watson return (size); 7877304f61fSBrian Feldman } 788