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/lib/libc/port/gen/getauxv.c
          +++ new/usr/src/lib/libc/port/gen/getauxv.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  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   25   */
  26   26  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  29   27  #include "lint.h"
       28 +#include "thr_uberdata.h"
  30   29  #include <libc.h>
  31   30  #include <fcntl.h>
  32   31  #include <stdlib.h>
  33   32  #include <unistd.h>
  34   33  #include <sys/types.h>
  35   34  #include <sys/stat.h>
  36   35  #include <sys/auxv.h>
  37   36  #include <mtlib.h>
  38   37  #include <thread.h>
  39   38  #include <synch.h>
  40   39  #include <atomic.h>
       40 +#include <limits.h>
  41   41  
  42   42  static mutex_t auxlock = DEFAULTMUTEX;
  43   43  
  44   44  /*
  45   45   * Get auxiliary entry.
  46   46   * Returns pointer to entry, or 0 if entry does not exist.
  47   47   */
  48   48  static auxv_t *
  49   49  _getaux(int type)
  50   50  {
↓ open down ↓ 1 lines elided ↑ open up ↑
  52   52          static size_t nauxv = 0;
  53   53          ssize_t i;
  54   54  
  55   55          /*
  56   56           * The first time through, read the initial aux vector that was
  57   57           * passed to the process at exec(2).  Only do this once.
  58   58           */
  59   59          if (auxb == NULL) {
  60   60                  lmutex_lock(&auxlock);
  61   61                  if (auxb == NULL) {
       62 +                        uberdata_t *udp = curthread->ul_uberdata;
  62   63                          struct stat statb;
  63   64                          auxv_t *buf = NULL;
       65 +                        char *path = "/proc/self/auxv";
       66 +                        char pbuf[PATH_MAX];
  64   67                          int fd;
  65   68  
  66      -                        if ((fd = open("/proc/self/auxv", O_RDONLY)) != -1 &&
       69 +                        if (udp->ub_broot != NULL) {
       70 +                                (void) snprintf(pbuf, sizeof (pbuf),
       71 +                                    "%s/proc/self/auxv", udp->ub_broot);
       72 +                                path = pbuf;
       73 +                        }
       74 +
       75 +                        if ((fd = open(path, O_RDONLY)) != -1 &&
  67   76                              fstat(fd, &statb) != -1)
  68   77                                  buf = libc_malloc(
  69   78                                      statb.st_size + sizeof (auxv_t));
  70   79  
  71   80                          if (buf != NULL) {
  72   81                                  i = read(fd, buf, statb.st_size);
  73   82                                  if (i != -1) {
  74   83                                          nauxv = i / sizeof (auxv_t);
  75   84                                          buf[nauxv].a_type = AT_NULL;
  76   85                                  } else {
↓ open down ↓ 51 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX