diff options
author | Bryan Cantrill <bryan@joyent.com> | 2015-02-17 17:24:10 +0000 |
---|---|---|
committer | Bryan Cantrill <bryan@joyent.com> | 2015-02-17 17:24:10 +0000 |
commit | 3f8d3031925da0b8a20186fff1da8a615aaf4470 (patch) | |
tree | 4e4042744aefca7b0a4891c072dce28b809ed7be /usr/src/lib/libctf/common/ctf_lib.c | |
parent | 877cd781ea8bda7fd72756cca317ab9b0f43bb7d (diff) | |
download | illumos-joyent-3f8d3031925da0b8a20186fff1da8a615aaf4470.tar.gz |
OS-3860 lx brand: dtrace unable to use "curpsinfo" translator
Diffstat (limited to 'usr/src/lib/libctf/common/ctf_lib.c')
-rw-r--r-- | usr/src/lib/libctf/common/ctf_lib.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/usr/src/lib/libctf/common/ctf_lib.c b/usr/src/lib/libctf/common/ctf_lib.c index 5071f693a2..4658fc8ddc 100644 --- a/usr/src/lib/libctf/common/ctf_lib.c +++ b/usr/src/lib/libctf/common/ctf_lib.c @@ -37,6 +37,7 @@ #include <dlfcn.h> #include <gelf.h> #include <zlib.h> +#include <zone.h> #ifdef _LP64 static const char *_libctf_zlib = "/usr/lib/64/libz.so.1"; @@ -79,15 +80,36 @@ _libctf_init(void) void * ctf_zopen(int *errp) { - ctf_dprintf("decompressing CTF data using %s\n", _libctf_zlib); + char buf[MAXPATHLEN]; + const char *path = _libctf_zlib, *zroot; if (zlib.z_dlp != NULL) return (zlib.z_dlp); /* library is already loaded */ - if (access(_libctf_zlib, R_OK) == -1) + /* + * Get the zone native root. For the tools build, we don't need + * this (it seems fair to impose that we always build the system in + * a native zone), and we want to allow build machines that are older + * that the notion of the native root, so we only actually make this + * call if we're not the tools build. + */ +#ifndef CTF_TOOLS_BUILD + zroot = zone_get_nroot(); +#else + zroot = NULL; +#endif + + if (zroot != NULL) { + (void) snprintf(buf, MAXPATHLEN, "%s/%s", zroot, _libctf_zlib); + path = buf; + } + + ctf_dprintf("decompressing CTF data using %s\n", path); + + if (access(path, R_OK) == -1) return (ctf_set_open_errno(errp, ECTF_ZMISSING)); - if ((zlib.z_dlp = dlopen(_libctf_zlib, RTLD_LAZY | RTLD_LOCAL)) == NULL) + if ((zlib.z_dlp = dlopen(path, RTLD_LAZY | RTLD_LOCAL)) == NULL) return (ctf_set_open_errno(errp, ECTF_ZINIT)); zlib.z_uncompress = (int (*)()) dlsym(zlib.z_dlp, "uncompress"); |