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>

@@ -22,13 +22,12 @@
 /*
  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident   "%Z%%M% %I%     %E% SMI"
-
 #include "lint.h"
+#include "thr_uberdata.h"
 #include <libc.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/types.h>

@@ -36,10 +35,11 @@
 #include <sys/auxv.h>
 #include <mtlib.h>
 #include <thread.h>
 #include <synch.h>
 #include <atomic.h>
+#include <limits.h>
 
 static mutex_t auxlock = DEFAULTMUTEX;
 
 /*
  * Get auxiliary entry.

@@ -57,15 +57,24 @@
          * passed to the process at exec(2).  Only do this once.
          */
         if (auxb == NULL) {
                 lmutex_lock(&auxlock);
                 if (auxb == NULL) {
+                        uberdata_t *udp = curthread->ul_uberdata;
                         struct stat statb;
                         auxv_t *buf = NULL;
+                        char *path = "/proc/self/auxv";
+                        char pbuf[PATH_MAX];
                         int fd;
 
-                        if ((fd = open("/proc/self/auxv", O_RDONLY)) != -1 &&
+                        if (udp->ub_broot != NULL) {
+                                (void) snprintf(pbuf, sizeof (pbuf),
+                                    "%s/proc/self/auxv", udp->ub_broot);
+                                path = pbuf;
+                        }
+
+                        if ((fd = open(path, O_RDONLY)) != -1 &&
                             fstat(fd, &statb) != -1)
                                 buf = libc_malloc(
                                     statb.st_size + sizeof (auxv_t));
 
                         if (buf != NULL) {