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/preap/preap.c
          +++ new/usr/src/cmd/ptools/preap/preap.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  29   27  #include <stdio.h>
  30   28  #include <stdlib.h>
  31   29  #include <unistd.h>
  32   30  #include <fcntl.h>
  33   31  #include <ctype.h>
  34   32  #include <string.h>
  35   33  #include <signal.h>
  36   34  #include <errno.h>
  37   35  #include <sys/types.h>
  38   36  #include <sys/wait.h>
  39   37  #include <libproc.h>
       38 +#include <limits.h>
       39 +#include "ptools_common.h"
  40   40  
  41   41  #define NOREAP_TIME 60          /* wait 60 seconds before allow a reap */
  42   42  
  43   43  static volatile int interrupt;
  44   44  static int Fflag;
  45   45  static char *command;
  46   46  
  47   47  static void
  48   48  intr(int sig)
  49   49  {
  50   50          interrupt = sig;
  51   51  }
  52   52  
  53   53  static int
  54   54  open_usage(pid_t pid, int *perr)
  55   55  {
  56      -        char path[64];
       56 +        char path[PATH_MAX];
  57   57          struct stat64 st;
  58   58          int fd;
  59   59  
  60      -        (void) snprintf(path, sizeof (path), "/proc/%d/usage", (int)pid);
       60 +        (void) proc_snprintf(path, sizeof (path), "/proc/%d/usage", (int)pid);
  61   61  
  62   62          /*
  63   63           * Attempt to open the usage file, and return the fd if we can
  64   64           * confirm this is a regular file provided by /proc.
  65   65           */
  66   66          if ((fd = open64(path, O_RDONLY)) >= 0) {
  67   67                  if (fstat64(fd, &st) != 0 || !S_ISREG(st.st_mode) ||
  68   68                      strcmp(st.st_fstype, "proc") != 0) {
  69   69                          (void) close(fd);
  70   70                          fd = -1;
↓ open down ↓ 201 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX