Print this page
OS-3280 need a way to specify the root of a native system in the lx brand
OS-3279 lx brand should allow delegated datasets
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/ptools/ptime/ptime.c
          +++ new/usr/src/cmd/ptools/ptime/ptime.c
↓ open down ↓ 33 lines elided ↑ open up ↑
  34   34  #include <fcntl.h>
  35   35  #include <string.h>
  36   36  #include <errno.h>
  37   37  #include <math.h>
  38   38  #include <wait.h>
  39   39  #include <signal.h>
  40   40  #include <sys/types.h>
  41   41  #include <sys/time.h>
  42   42  #include <signal.h>
  43   43  #include <libproc.h>
       44 +#include <limits.h>
       45 +#include "ptools_common.h"
  44   46  
  45   47  static  int     look(pid_t);
  46   48  static  void    hr_min_sec(char *, long);
  47   49  static  void    prtime(char *, timestruc_t *);
  48   50  static  int     perr(const char *);
  49   51  
  50   52  static  void    tsadd(timestruc_t *result, timestruc_t *a, timestruc_t *b);
  51   53  static  void    tssub(timestruc_t *result, timestruc_t *a, timestruc_t *b);
  52   54  static  void    hrt2ts(hrtime_t hrt, timestruc_t *tsp);
  53   55  
↓ open down ↓ 128 lines elided ↑ open up ↑
 182  184                      "abnormally by %s\n", command,
 183  185                      proc_signame(sig, name, sizeof (name)));
 184  186          }
 185  187  
 186  188          return (status | WCOREFLG); /* see time(1) */
 187  189  }
 188  190  
 189  191  static int
 190  192  look(pid_t pid)
 191  193  {
 192      -        char pathname[100];
      194 +        char pathname[PATH_MAX];
 193  195          int rval = 0;
 194  196          int fd;
 195  197          psinfo_t psinfo;
 196  198          prusage_t prusage;
 197  199          timestruc_t real, user, sys;
 198  200          hrtime_t hrtime;
 199  201          prusage_t *pup = &prusage;
 200  202  
 201  203          pfirst++;
 202  204  
 203  205          if (proc_get_psinfo(pid, &psinfo) < 0)
 204  206                  return (perr("read psinfo"));
 205  207  
 206      -        (void) sprintf(pathname, "/proc/%d/usage", (int)pid);
      208 +        (void) proc_snprintf(pathname, sizeof (pathname), "/proc/%d/usage",
      209 +            (int)pid);
 207  210          if ((fd = open(pathname, O_RDONLY)) < 0)
 208  211                  return (perr("open usage"));
 209  212  
 210  213          if (read(fd, &prusage, sizeof (prusage)) != sizeof (prusage))
 211  214                  rval = perr("read usage");
 212  215          else {
 213  216                  if (pidarg) {
 214  217                          hrtime = gethrtime();
 215  218                          hrt2ts(hrtime, &real);
 216  219                  } else {
↓ open down ↓ 94 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX