[lxc-devel] [lxcfs/master] add common fallback dlopen for liblxcfs.so
elianka on Github
lxc-bot at linuxcontainers.org
Sat Jul 1 16:33:14 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 587 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170701/6dd7031d/attachment.bin>
-------------- next part --------------
From 9dd49ba5551b6932866320ed3d9e5fadf8a69c30 Mon Sep 17 00:00:00 2001
From: Daniel Kang <kangliang424 at gmail.com>
Date: Sun, 2 Jul 2017 00:23:44 +0800
Subject: [PATCH] add common fallback dlopen for liblxcfs.so
Signed-off-by: Daniel Kang <kangliang424 at gmail.com>
---
lxcfs.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lxcfs.c b/lxcfs.c
index fb0c05c..62cfd35 100644
--- a/lxcfs.c
+++ b/lxcfs.c
@@ -28,6 +28,7 @@
#include <sys/epoll.h>
#include <sys/mount.h>
#include <sys/socket.h>
+#include <linux/limits.h>
#include "bindings.h"
#include "config.h" // for VERSION
@@ -74,6 +75,7 @@ static volatile sig_atomic_t need_reload;
* lock and when we know the user_count was 0 */
static void do_reload(void)
{
+ char lxcfs_lib_path[PATH_MAX];
if (dlopen_handle) {
lxcfs_debug("%s\n", "Closing liblxcfs.so handle.");
dlclose(dlopen_handle);
@@ -86,7 +88,13 @@ static void do_reload(void)
goto good;
}
- dlopen_handle = dlopen("/usr/lib/lxcfs/liblxcfs.so", RTLD_LAZY);
+#ifdef LIBDIR
+ /* LIBDIR: autoconf will setup this MACRO. Default value is $PREFIX/lib */
+ snprintf(lxcfs_lib_path, PATH_MAX, "%s/lxcfs/liblxcfs.so", LIBDIR);
+#else
+ snprintf(lxcfs_lib_path, PATH_MAX, "/usr/local/lib/lxcfs/liblxcfs.so");
+#endif
+ dlopen_handle = dlopen(lxcfs_lib_path, RTLD_LAZY);
if (!dlopen_handle) {
lxcfs_error("Failed to open liblxcfs.so: %s.\n", dlerror());
_exit(1);
More information about the lxc-devel
mailing list