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>

@@ -20,10 +20,11 @@
  */
 
 /*
  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ * Copyright (c) 2014, Joyent, Inc.  All rights reserved.
  */
 
 #include <stdio.h>
 #include <stdio_ext.h>
 #include <stdlib.h>

@@ -40,10 +41,11 @@
 #include <sys/stat.h>
 #include <sys/mkdev.h>
 #include <sys/mman.h>
 #include <sys/lgrp_user.h>
 #include <libproc.h>
+#include "ptools_common.h"
 
 #include "pmap_common.h"
 
 #define KILOBYTE        1024
 #define MEGABYTE        (KILOBYTE * KILOBYTE)

@@ -197,11 +199,11 @@
         const char *bar8 = "-------";
         const char *bar16 = "----------";
         const char *bar;
         struct rlimit rlim;
         struct stat64 statbuf;
-        char buf[128];
+        char buf[PATH_MAX];
         int mapfd;
         int prg_gflags = PGRAB_RDONLY;
         int prr_flags = 0;
         boolean_t use_agent_lwp = B_FALSE;
 

@@ -356,11 +358,11 @@
                 bar = addr_width == 8 ? bar8 : bar16;
                 (void) memcpy(&psinfo, Ppsinfo(Pr), sizeof (psinfo_t));
                 proc_unctrl_psinfo(&psinfo);
 
                 if (Pstate(Pr) != PS_DEAD) {
-                        (void) snprintf(buf, sizeof (buf),
+                        (void) proc_snprintf(buf, sizeof (buf),
                             "/proc/%d/map", (int)psinfo.pr_pid);
                         if ((mapfd = open(buf, O_RDONLY)) < 0) {
                                 (void) fprintf(stderr, "%s: cannot "
                                     "examine %s: lost control of "
                                     "process\n", command, arg);

@@ -588,11 +590,11 @@
         int mapfd, nmap, i, rc;
         struct stat st;
         prmap_t *prmapp, *pmp;
         ssize_t n;
 
-        (void) snprintf(mapname, sizeof (mapname),
+        (void) proc_snprintf(mapname, sizeof (mapname),
             "/proc/%d/rmap", (int)Pstatus(Pr)->pr_pid);
 
         if ((mapfd = open(mapname, O_RDONLY)) < 0 || fstat(mapfd, &st) != 0) {
                 if (mapfd >= 0)
                         (void) close(mapfd);

@@ -629,11 +631,11 @@
         int mapfd, nmap, i, rc;
         struct stat st;
         prxmap_t *prmapp, *pmp;
         ssize_t n;
 
-        (void) snprintf(mapname, sizeof (mapname),
+        (void) proc_snprintf(mapname, sizeof (mapname),
             "/proc/%d/xmap", (int)Pstatus(Pr)->pr_pid);
 
         if ((mapfd = open(mapname, O_RDONLY)) < 0 || fstat(mapfd, &st) != 0) {
                 if (mapfd >= 0)
                         (void) close(mapfd);