Print this page
2989 Eliminate use of LOGNAME_MAX in ON
1166 useradd have warning with name more 8 chars

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/prstat/prutil.c
          +++ new/usr/src/cmd/prstat/prutil.c
↓ open down ↓ 11 lines elided ↑ open up ↑
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
       22 + * Copyright (c) 2013 Gary Mills
       23 + *
  22   24   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   25   * Use is subject to license terms.
  24   26   *
  25   27   * Portions Copyright 2009 Chad Mynhier
  26   28   */
  27   29  
  28   30  #include <sys/types.h>
  29   31  #include <sys/param.h>
  30   32  #include <sys/resource.h>
  31   33  #include <sys/priocntl.h>
↓ open down ↓ 239 lines elided ↑ open up ↑
 271  273          }
 272  274          pcparms.pc_cid = pcinfo.pc_cid;
 273  275          ((rtparms_t *)pcparms.pc_clparms)->rt_pri = 0;
 274  276          ((rtparms_t *)pcparms.pc_clparms)->rt_tqsecs = 0;
 275  277          ((rtparms_t *)pcparms.pc_clparms)->rt_tqnsecs = RT_NOCHANGE;
 276  278          if (priocntl(P_PID, getpid(), PC_SETPARMS, (caddr_t)&pcparms) == -1)
 277  279                  Warn(gettext("cannot enter the real time class"));
 278  280  }
 279  281  
 280  282  void
 281      -getprojname(projid_t projid, char *str, int len, int noresolve)
      283 +getprojname(projid_t projid, char *str, size_t len, int noresolve,
      284 +    int termcap, size_t width)
 282  285  {
 283  286          struct project proj;
      287 +        size_t n;
 284  288  
 285  289          if (noresolve || getprojbyid(projid, &proj, projbuf, PROJECT_BUFSZ) ==
 286      -            NULL)
      290 +            NULL) {
 287  291                  (void) snprintf(str, len, "%-6d", (int)projid);
 288      -        else
 289      -                (void) snprintf(str, len, "%-28s", proj.pj_name);
      292 +        } else {
      293 +                n = strlen(proj.pj_name);
      294 +                if (termcap && n > width)
      295 +                        (void) snprintf(str, len, "%.*s%c", width - 1,
      296 +                            proj.pj_name, '*');
      297 +                else
      298 +                        (void) snprintf(str, len, "%-28s", proj.pj_name);
      299 +        }
 290  300  }
 291  301  
 292  302  void
 293      -getzonename(zoneid_t zoneid, char *str, int len)
      303 +getzonename(zoneid_t zoneid, char *str, size_t len, int termcap, size_t width)
 294  304  {
 295  305          char zone_name[ZONENAME_MAX];
      306 +        size_t n;
 296  307  
 297      -        if (getzonenamebyid(zoneid, zone_name, sizeof (zone_name)) < 0)
      308 +        if (getzonenamebyid(zoneid, zone_name, sizeof (zone_name)) < 0) {
 298  309                  (void) snprintf(str, len, "%-6d", (int)zoneid);
 299      -        else
 300      -                (void) snprintf(str, len, "%-28s", zone_name);
      310 +        } else {
      311 +                n = strlen(zone_name);
      312 +                if (termcap && n > width)
      313 +                        (void) snprintf(str, len, "%.*s%c", width - 1,
      314 +                            zone_name, '*');
      315 +                else
      316 +                        (void) snprintf(str, len, "%-28s", zone_name);
      317 +        }
 301  318  }
 302  319  
 303  320  /*
 304  321   * Remove all unprintable characters from process name
 305  322   */
 306  323  void
 307  324  stripfname(char *buf)
 308  325  {
 309  326          int bytesleft = PRFNSZ;
 310  327          wchar_t wchar;
↓ open down ↓ 22 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX