diff options
author | Frederic Barrat <fbarrat@linux.ibm.com> | 2021-06-07 12:24:52 +0200 |
---|---|---|
committer | Frederic Barrat <fbarrat@linux.ibm.com> | 2021-06-09 14:17:13 +0200 |
commit | e9e32473cf85717482e9d0f63a3c7a26e266fbb9 (patch) | |
tree | f7be54e5bb68e4dbd4bee8b626ce7b328a95a1d5 | |
parent | acca9d9e59572ebc9477ac5338c1656e307dd2b7 (diff) |
Allow to redefine SYSPATH through environment variable
The LIBOCXL_SYSPATH env variable can override the sys path. Can be
useful for containers
Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | src/internal.c | 5 |
2 files changed, 10 insertions, 0 deletions
@@ -98,6 +98,11 @@ The following environment variables may be set (to 1 or "YES") to assist with de **LIBOCXL_VERBOSE_ERRORS_ALL** Force verbose errors to be emitted for any failed LibOCXL calls, unless explicitly disabled. + +For testing and/or assist in various environments, the following environment variable can also be set: + +**LIBOCXL_SYSPATH** Override the default path (/sys/class/ocxl) used by the library to read driver information. + Patches may be submitted via Github pull requests. Please prepare your patches by running `make precommit` before committing your work, and addressing any warnings & errors reported. Patches must compile cleanly with the latest stable version of GCC to be accepted. diff --git a/src/internal.c b/src/internal.c index 0dd8e91..07eaa9d 100644 --- a/src/internal.c +++ b/src/internal.c @@ -53,6 +53,7 @@ pthread_mutex_t stderr_mutex = PTHREAD_MUTEX_INITIALIZER; * - Check the LIBOCXL_INFO environment variable and output the info string * - Check the LIBOCXL_TRACE_ALL environment variable and enable tracing_all * - Check the LIBOCXL_VERBOSE_ERRORS_ALL environment variable and enable verbose_errors_all + * - Check the LIBOCXL_SYSPATH environment variable and override sys_path */ void libocxl_init() { @@ -81,6 +82,10 @@ void libocxl_init() verbose_errors = true; } + val = getenv("LIBOCXL_SYSPATH"); + if (val) + sys_path = val; + libocxl_inited = true; pthread_mutex_unlock(&libocxl_inited_mutex); |