mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 11:18:08 +02:00
egl: Rework _eglGetSearchPath.
So that the directory part of EGL_DRIVER, if exists, is prepended to the search path. This commit also adds a sanity check to _eglLog.
This commit is contained in:
parent
583e41855b
commit
ad00a92ee7
3 changed files with 50 additions and 25 deletions
|
|
@ -136,11 +136,6 @@ binaries.</p>
|
||||||
specified EGL driver to be loaded. It comes in handy when one wants to test a
|
specified EGL driver to be loaded. It comes in handy when one wants to test a
|
||||||
specific driver. This variable is ignored for setuid/setgid binaries.</p>
|
specific driver. This variable is ignored for setuid/setgid binaries.</p>
|
||||||
|
|
||||||
<p><code>egl_gallium</code> dynamically loads hardware drivers and client API
|
|
||||||
modules found in <code>EGL_DRIVERS_PATH</code>. Thus, specifying this variable
|
|
||||||
alone is not sufficient for <code>egl_gallium</code> for an uninstalled
|
|
||||||
build.</p>
|
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li><code>EGL_PLATFORM</code>
|
<li><code>EGL_PLATFORM</code>
|
||||||
|
|
|
||||||
|
|
@ -395,35 +395,62 @@ _eglPreloadForEach(const char *search_path,
|
||||||
static const char *
|
static const char *
|
||||||
_eglGetSearchPath(void)
|
_eglGetSearchPath(void)
|
||||||
{
|
{
|
||||||
static const char *search_path;
|
static char search_path[1024];
|
||||||
|
|
||||||
#if defined(_EGL_OS_UNIX) || defined(_EGL_OS_WINDOWS)
|
#if defined(_EGL_OS_UNIX) || defined(_EGL_OS_WINDOWS)
|
||||||
if (!search_path) {
|
if (search_path[0] == '\0') {
|
||||||
static char buffer[1024];
|
char *buf = search_path;
|
||||||
const char *p;
|
size_t len = sizeof(search_path);
|
||||||
|
EGLBoolean use_env;
|
||||||
|
char dir_sep;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
p = getenv("EGL_DRIVERS_PATH");
|
|
||||||
#if defined(_EGL_OS_UNIX)
|
#if defined(_EGL_OS_UNIX)
|
||||||
if (p && (geteuid() != getuid() || getegid() != getgid())) {
|
use_env = (geteuid() == getuid() && getegid() == getgid());
|
||||||
|
dir_sep = '/';
|
||||||
|
#else
|
||||||
|
use_env = EGL_TRUE;
|
||||||
|
dir_sep = '\\';
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (use_env) {
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
/* extract the dirname from EGL_DRIVER */
|
||||||
|
p = getenv("EGL_DRIVER");
|
||||||
|
if (p && strchr(p, dir_sep)) {
|
||||||
|
ret = _eglsnprintf(buf, len, "%s", p);
|
||||||
|
if (ret > 0 && ret < len) {
|
||||||
|
p = strrchr(buf, dir_sep);
|
||||||
|
*p++ = ':';
|
||||||
|
|
||||||
|
len -= p - buf;
|
||||||
|
buf = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* append EGL_DRIVERS_PATH */
|
||||||
|
p = getenv("EGL_DRIVERS_PATH");
|
||||||
|
if (p) {
|
||||||
|
ret = _eglsnprintf(buf, len, "%s:", p);
|
||||||
|
if (ret > 0 && ret < len) {
|
||||||
|
buf += ret;
|
||||||
|
len -= ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
_eglLog(_EGL_DEBUG,
|
_eglLog(_EGL_DEBUG,
|
||||||
"ignore EGL_DRIVERS_PATH for setuid/setgid binaries");
|
"ignore EGL_DRIVERS_PATH for setuid/setgid binaries");
|
||||||
p = NULL;
|
|
||||||
}
|
}
|
||||||
#endif /* _EGL_OS_UNIX */
|
|
||||||
|
|
||||||
if (p) {
|
ret = _eglsnprintf(buf, len, "%s", _EGL_DRIVER_SEARCH_DIR);
|
||||||
ret = _eglsnprintf(buffer, sizeof(buffer),
|
if (ret < 0 || ret >= len)
|
||||||
"%s:%s", p, _EGL_DRIVER_SEARCH_DIR);
|
search_path[0] = '\0';
|
||||||
if (ret > 0 && ret < sizeof(buffer))
|
|
||||||
search_path = buffer;
|
_eglLog(_EGL_DEBUG, "EGL search path is %s", search_path);
|
||||||
}
|
}
|
||||||
}
|
#endif /* defined(_EGL_OS_UNIX) || defined(_EGL_OS_WINDOWS) */
|
||||||
if (!search_path)
|
|
||||||
search_path = _EGL_DRIVER_SEARCH_DIR;
|
|
||||||
#else
|
|
||||||
search_path = "";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return search_path;
|
return search_path;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@ _eglLog(EGLint level, const char *fmtStr, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char msg[MAXSTRING];
|
char msg[MAXSTRING];
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* one-time initialization; a little race here is fine */
|
/* one-time initialization; a little race here is fine */
|
||||||
if (!logging.initialized)
|
if (!logging.initialized)
|
||||||
|
|
@ -162,7 +163,9 @@ _eglLog(EGLint level, const char *fmtStr, ...)
|
||||||
|
|
||||||
if (logging.logger) {
|
if (logging.logger) {
|
||||||
va_start(args, fmtStr);
|
va_start(args, fmtStr);
|
||||||
vsnprintf(msg, MAXSTRING, fmtStr, args);
|
ret = vsnprintf(msg, MAXSTRING, fmtStr, args);
|
||||||
|
if (ret < 0 || ret >= MAXSTRING)
|
||||||
|
strcpy(msg, "<message truncated>");
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
logging.logger(level, msg);
|
logging.logger(level, msg);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue