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,36 ****
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* 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>
--- 19,35 ----
* 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
*/
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
*** 46,55 ****
--- 45,55 ----
#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,114 ****
int errflg = 0;
struct winsize winsize;
char *s;
int n;
int retc = 0;
DIR *dirp;
struct dirent *dentp;
! char pname[100];
int pdlen;
ps_t *p;
if ((command = strrchr(argv[0], '/')) == NULL)
--- 101,115 ----
int errflg = 0;
struct winsize winsize;
char *s;
int n;
int retc = 0;
+ char ppath[PATH_MAX];
DIR *dirp;
struct dirent *dentp;
! char pname[PATH_MAX];
int pdlen;
ps_t *p;
if ((command = strrchr(argv[0], '/')) == NULL)
*** 167,186 ****
nps = 0;
psize = 0;
ps = NULL;
/*
* Search the /proc directory for all processes.
*/
! if ((dirp = opendir("/proc")) == NULL) {
! (void) fprintf(stderr, "%s: cannot open /proc directory\n",
! command);
return (1);
}
! (void) strcpy(pname, "/proc");
pdlen = strlen(pname);
pname[pdlen++] = '/';
/* for each active process --- */
while (dentp = readdir(dirp)) {
--- 168,189 ----
nps = 0;
psize = 0;
ps = NULL;
+ (void) proc_snprintf(ppath, sizeof (ppath), "/proc");
+
/*
* Search the /proc directory for all processes.
*/
! if ((dirp = opendir(ppath)) == NULL) {
! (void) fprintf(stderr, "%s: cannot open %s directory\n",
! command, ppath);
return (1);
}
! (void) strcpy(pname, ppath);
pdlen = strlen(pname);
pname[pdlen++] = '/';
/* for each active process --- */
while (dentp = readdir(dirp)) {