aboutsummaryrefslogtreecommitdiff
path: root/loader
diff options
context:
space:
mode:
authorCourtney Goeltzenleuchter <courtney@LunarG.com>2014-12-01 09:29:42 -0700
committerCourtney Goeltzenleuchter <courtney@LunarG.com>2014-12-02 15:45:53 -0700
commit92fb43936b05af9c11aa692cd9b5c325773dfe2d (patch)
tree491295e40bc092a9f3fac8ff76de8a0d1a6f11aa /loader
parentd1772484cf1af9ac724a966eed7d0ecb4db87ad3 (diff)
downloadusermoji-92fb43936b05af9c11aa692cd9b5c325773dfe2d.tar.xz
loader: Make LIBXGL_LAYERS_PATH behave like LIBXGL_DRIVERS_PATH
Diffstat (limited to 'loader')
-rw-r--r--loader/loader.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/loader/loader.c b/loader/loader.c
index aadb40e6..dcdc5fa1 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -83,7 +83,7 @@ static struct {
bool scanned;
struct loader_icd *icds;
bool layer_scanned;
- char layer_dirs[4096];
+ char *layer_dirs;
unsigned int scanned_layer_count;
char *scanned_layer_names[MAX_LAYER_LIBRARIES];
struct loader_msg_callback *msg_callbacks;
@@ -375,26 +375,46 @@ static void loader_icd_scan(void)
}
#ifndef DEFAULT_XGL_LAYERS_PATH
-// TODO: Is this a good default locations
+// TODO: Are these good default locations?
#define DEFAULT_XGL_LAYERS_PATH ".:/usr/lib/i386-linux-gnu/xgl:/usr/lib/x86_64-linux-gnu/xgl"
#endif
-static void layer_lib_scan(const char * libInPaths, const bool useDefaultDirs)
+static void layer_lib_scan(const char * libInPaths)
{
const char *p, *next;
- char *libPaths = &loader.layer_dirs[0];
+ char *libPaths;
DIR *curdir;
struct dirent *dent;
int len, i;
char temp_str[1024];
+ len = 0;
+ loader.layer_dirs = NULL;
if (libInPaths){
- strncpy(libPaths, libInPaths, sizeof(loader.layer_dirs));
+ len = strlen(libInPaths);
+ p = libInPaths;
}
else {
- *libPaths = '\0';
+ if (geteuid() == getuid()) {
+ p = getenv("LIBXGL_LAYERS_PATH");
+ if (p != NULL)
+ len = strlen(p);
+ }
+ }
+
+ if (len == 0) {
+ len = strlen(DEFAULT_XGL_LAYERS_PATH);
+ p = DEFAULT_XGL_LAYERS_PATH;
}
+ if (len == 0) {
+ // Have no paths to search
+ return;
+ }
+ loader.layer_dirs = malloc(len+1);
+ strncpy(loader.layer_dirs, p, len);
+ libPaths = loader.layer_dirs;
+
/* cleanup any previously scanned libraries */
for (i = 0; i < loader.scanned_layer_count; i++) {
if (loader.scanned_layer_names[i] != NULL)
@@ -403,9 +423,6 @@ static void layer_lib_scan(const char * libInPaths, const bool useDefaultDirs)
}
loader.scanned_layer_count = 0;
- if (useDefaultDirs)
- strncat(libPaths, DEFAULT_XGL_LAYERS_PATH, sizeof(loader.layer_dirs) - sizeof(DEFAULT_XGL_LAYERS_PATH));
-
for (p = libPaths; *p; p = next) {
next = strchr(p, ':');
if (next == NULL) {
@@ -1172,7 +1189,7 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglInitAndEnumerateGpus(const XGL_APPLICATION_IN
/* get layer libraries */
if (!loader.layer_scanned)
- layer_lib_scan(NULL, true);
+ layer_lib_scan(NULL);
*pGpuCount = count;