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/pmap/pmap.c
          +++ new/usr/src/cmd/ptools/pmap/pmap.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
       25 + * Copyright (c) 2014, Joyent, Inc.  All rights reserved.
  25   26   */
  26   27  
  27   28  #include <stdio.h>
  28   29  #include <stdio_ext.h>
  29   30  #include <stdlib.h>
  30   31  #include <unistd.h>
  31   32  #include <ctype.h>
  32   33  #include <fcntl.h>
  33   34  #include <string.h>
  34   35  #include <dirent.h>
  35   36  #include <limits.h>
  36   37  #include <link.h>
  37   38  #include <libelf.h>
  38   39  #include <sys/types.h>
  39   40  #include <signal.h>
  40   41  #include <sys/stat.h>
  41   42  #include <sys/mkdev.h>
  42   43  #include <sys/mman.h>
  43   44  #include <sys/lgrp_user.h>
  44   45  #include <libproc.h>
       46 +#include "ptools_common.h"
  45   47  
  46   48  #include "pmap_common.h"
  47   49  
  48   50  #define KILOBYTE        1024
  49   51  #define MEGABYTE        (KILOBYTE * KILOBYTE)
  50   52  #define GIGABYTE        (KILOBYTE * KILOBYTE * KILOBYTE)
  51   53  
  52   54  /*
  53   55   * Round up the value to the nearest kilobyte
  54   56   */
↓ open down ↓ 137 lines elided ↑ open up ↑
 192  194  {
 193  195          int rflag = 0, sflag = 0, xflag = 0, Fflag = 0;
 194  196          int errflg = 0, Sflag = 0;
 195  197          int rc = 0;
 196  198          int opt;
 197  199          const char *bar8 = "-------";
 198  200          const char *bar16 = "----------";
 199  201          const char *bar;
 200  202          struct rlimit rlim;
 201  203          struct stat64 statbuf;
 202      -        char buf[128];
      204 +        char buf[PATH_MAX];
 203  205          int mapfd;
 204  206          int prg_gflags = PGRAB_RDONLY;
 205  207          int prr_flags = 0;
 206  208          boolean_t use_agent_lwp = B_FALSE;
 207  209  
 208  210          if ((command = strrchr(argv[0], '/')) != NULL)
 209  211                  command++;
 210  212          else
 211  213                  command = argv[0];
 212  214  
↓ open down ↓ 138 lines elided ↑ open up ↑
 351  353  
 352  354                  procname = arg;         /* for perr() */
 353  355  
 354  356                  addr_width = (Pstatus(Pr)->pr_dmodel == PR_MODEL_LP64) ? 16 : 8;
 355  357                  size_width = (Pstatus(Pr)->pr_dmodel == PR_MODEL_LP64) ? 11 : 8;
 356  358                  bar = addr_width == 8 ? bar8 : bar16;
 357  359                  (void) memcpy(&psinfo, Ppsinfo(Pr), sizeof (psinfo_t));
 358  360                  proc_unctrl_psinfo(&psinfo);
 359  361  
 360  362                  if (Pstate(Pr) != PS_DEAD) {
 361      -                        (void) snprintf(buf, sizeof (buf),
      363 +                        (void) proc_snprintf(buf, sizeof (buf),
 362  364                              "/proc/%d/map", (int)psinfo.pr_pid);
 363  365                          if ((mapfd = open(buf, O_RDONLY)) < 0) {
 364  366                                  (void) fprintf(stderr, "%s: cannot "
 365  367                                      "examine %s: lost control of "
 366  368                                      "process\n", command, arg);
 367  369                                  rc++;
 368  370                                  Prelease(Pr, prr_flags);
 369  371                                  continue;
 370  372                          }
 371  373                  } else {
↓ open down ↓ 211 lines elided ↑ open up ↑
 583  585  
 584  586  static int
 585  587  rmapping_iter(struct ps_prochandle *Pr, proc_map_f *func, void *cd)
 586  588  {
 587  589          char mapname[PATH_MAX];
 588  590          int mapfd, nmap, i, rc;
 589  591          struct stat st;
 590  592          prmap_t *prmapp, *pmp;
 591  593          ssize_t n;
 592  594  
 593      -        (void) snprintf(mapname, sizeof (mapname),
      595 +        (void) proc_snprintf(mapname, sizeof (mapname),
 594  596              "/proc/%d/rmap", (int)Pstatus(Pr)->pr_pid);
 595  597  
 596  598          if ((mapfd = open(mapname, O_RDONLY)) < 0 || fstat(mapfd, &st) != 0) {
 597  599                  if (mapfd >= 0)
 598  600                          (void) close(mapfd);
 599  601                  return (perr(mapname));
 600  602          }
 601  603  
 602  604          nmap = st.st_size / sizeof (prmap_t);
 603  605          prmapp = malloc((nmap + 1) * sizeof (prmap_t));
↓ open down ↓ 20 lines elided ↑ open up ↑
 624  626  
 625  627  static int
 626  628  xmapping_iter(struct ps_prochandle *Pr, proc_xmap_f *func, void *cd, int doswap)
 627  629  {
 628  630          char mapname[PATH_MAX];
 629  631          int mapfd, nmap, i, rc;
 630  632          struct stat st;
 631  633          prxmap_t *prmapp, *pmp;
 632  634          ssize_t n;
 633  635  
 634      -        (void) snprintf(mapname, sizeof (mapname),
      636 +        (void) proc_snprintf(mapname, sizeof (mapname),
 635  637              "/proc/%d/xmap", (int)Pstatus(Pr)->pr_pid);
 636  638  
 637  639          if ((mapfd = open(mapname, O_RDONLY)) < 0 || fstat(mapfd, &st) != 0) {
 638  640                  if (mapfd >= 0)
 639  641                          (void) close(mapfd);
 640  642                  return (perr(mapname));
 641  643          }
 642  644  
 643  645          nmap = st.st_size / sizeof (prxmap_t);
 644  646          nmap *= 2;
↓ open down ↓ 1023 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX