#include "common/ceph_context.h"
#include "common/errno.h"
#include "common/debug.h"
-
-#include <dlfcn.h>
+#include "include/dlfcn_compat.h"
#define PLUGIN_PREFIX "libceph_"
-#ifdef __APPLE__
-#define PLUGIN_SUFFIX ".dylib"
-#else
-#define PLUGIN_SUFFIX ".so"
-#endif
+#define PLUGIN_SUFFIX SHARED_LIB_SUFFIX
#define PLUGIN_INIT_FUNCTION "__ceph_plugin_init"
#define PLUGIN_VERSION_FUNCTION "__ceph_plugin_version"
#define dout_subsys ceph_subsys_context
+using std::map;
+using std::string;
+
+namespace ceph {
+
PluginRegistry::PluginRegistry(CephContext *cct) :
cct(cct),
loading(false),
ceph_assert(ceph_mutex_is_locked(lock));
ldout(cct, 1) << __func__ << " " << type << " " << name << dendl;
- // std::string fname = cct->_conf->plugin_dir + "/" + type + "/" PLUGIN_PREFIX
- // + name + PLUGIN_SUFFIX;
std::string fname = cct->_conf.get_val<std::string>("plugin_dir") + "/" + type + "/" + PLUGIN_PREFIX
+ name + PLUGIN_SUFFIX;
void *library = dlopen(fname.c_str(), RTLD_NOW);
if (!library) {
string err1(dlerror());
// fall back to plugin_dir
- std::string fname2 = cct->_conf.get_val<std::string>("plugin_dir") + "/" + PLUGIN_PREFIX +
+ fname = cct->_conf.get_val<std::string>("plugin_dir") + "/" + PLUGIN_PREFIX +
name + PLUGIN_SUFFIX;
- library = dlopen(fname2.c_str(), RTLD_NOW);
+ library = dlopen(fname.c_str(), RTLD_NOW);
if (!library) {
lderr(cct) << __func__
<< " failed dlopen(): \"" << err1.c_str()
<< " loaded and registered" << dendl;
return 0;
}
+}
/*
int ErasureCodePluginRegistry::preload(const std::string &plugins,