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>

@@ -19,18 +19,17 @@
  * CDDL HEADER END
  */
 /*
  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ * Copyright (c) 2014, Joyent, Inc.  All rights reserved.
  */
 
 /*
  * ptree -- print family tree of processes
  */
 
-#pragma ident   "%Z%%M% %I%     %E% SMI"
-
 #include <assert.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
 #include <fcntl.h>

@@ -46,10 +45,11 @@
 #include <libcontract.h>
 #include <sys/contract.h>
 #include <sys/ctfs.h>
 #include <libcontract_priv.h>
 #include <sys/stat.h>
+#include "ptools_common.h"
 
 #define FAKEDPID0(p)    (p->pid == 0 && p->psargs[0] == '\0')
 
 typedef struct ps {
         int     done;

@@ -101,14 +101,15 @@
         int errflg = 0;
         struct winsize winsize;
         char *s;
         int n;
         int retc = 0;
+        char ppath[PATH_MAX];
 
         DIR *dirp;
         struct dirent *dentp;
-        char    pname[100];
+        char    pname[PATH_MAX];
         int     pdlen;
 
         ps_t *p;
 
         if ((command = strrchr(argv[0], '/')) == NULL)

@@ -167,20 +168,22 @@
 
         nps = 0;
         psize = 0;
         ps = NULL;
 
+        (void) proc_snprintf(ppath, sizeof (ppath), "/proc");
+
         /*
          * Search the /proc directory for all processes.
          */
-        if ((dirp = opendir("/proc")) == NULL) {
-                (void) fprintf(stderr, "%s: cannot open /proc directory\n",
-                    command);
+        if ((dirp = opendir(ppath)) == NULL) {
+                (void) fprintf(stderr, "%s: cannot open %s directory\n",
+                    command, ppath);
                 return (1);
         }
 
-        (void) strcpy(pname, "/proc");
+        (void) strcpy(pname, ppath);
         pdlen = strlen(pname);
         pname[pdlen++] = '/';
 
         /* for each active process --- */
         while (dentp = readdir(dirp)) {