From 42c640e76c437352ec8ac20965ff2dd8e4696b1d Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 30 Jun 2016 10:54:26 -0400 Subject: [PATCH] common/PluginRegistry: try $plugin_dir/$foo if $plugin_dir/$type/$foo fails This is helpful for running out of a build dir, where e.g. cmake puts stuff in lib/* and type separated into subdirs by type. Signed-off-by: Sage Weil --- src/common/PluginRegistry.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common/PluginRegistry.cc b/src/common/PluginRegistry.cc index fb02d4a45a5da..661df1c74e50f 100644 --- a/src/common/PluginRegistry.cc +++ b/src/common/PluginRegistry.cc @@ -142,9 +142,15 @@ int PluginRegistry::load(const std::string &type, + name + PLUGIN_SUFFIX; void *library = dlopen(fname.c_str(), RTLD_NOW); if (!library) { - lderr(cct) << __func__ << " failed dlopen(" << fname << "): " - << dlerror() << dendl; - return -EIO; + // fall back to plugin_dir + std::string fname2 = cct->_conf->plugin_dir + "/" + PLUGIN_PREFIX + + name + PLUGIN_SUFFIX; + library = dlopen(fname2.c_str(), RTLD_NOW); + if (!library) { + lderr(cct) << __func__ << " failed dlopen(" << fname << ") or dlopen(" + << fname2 << "): " << dlerror() << dendl; + return -EIO; + } } const char * (*code_version)() = -- 2.39.5