22 #include <linux/limits.h>
26 #include <boost/filesystem/operations.hpp>
27 #include <boost/filesystem/path.hpp>
30 #ifdef ENABLE_EMBEDDED_DATABASE
41 #ifdef ENABLE_EMBEDDED_DATABASE
42 void*
const handle = dlopen(DBEngine_LIBNAME, RTLD_LAZY | RTLD_NOLOAD);
48 const struct link_map* link_map = 0;
49 const int ret = dlinfo(handle, RTLD_DI_LINKMAP, &link_map);
55 boost::filesystem::path abs_exe_dir(boost::filesystem::absolute(
56 boost::filesystem::canonical(std::string(link_map->l_name))));
57 abs_exe_dir.remove_filename();
59 const auto mapd_root = abs_exe_dir.parent_path().parent_path();
61 const auto mapd_root = abs_exe_dir.parent_path();
63 return mapd_root.string();
67 char abs_exe_path[PROC_PIDPATHINFO_MAXSIZE] = {0};
68 auto path_len = proc_pidpath(getpid(), abs_exe_path,
sizeof(abs_exe_path));
70 char abs_exe_path[PATH_MAX] = {0};
71 auto path_len = readlink(
"/proc/self/exe", abs_exe_path,
sizeof(abs_exe_path));
74 CHECK_LT(static_cast<size_t>(path_len),
sizeof(abs_exe_path));
75 boost::filesystem::path abs_exe_dir(std::string(abs_exe_path, path_len));
76 abs_exe_dir.remove_filename();
78 const auto mapd_root = abs_exe_dir.parent_path().parent_path();
80 const auto mapd_root = abs_exe_dir.parent_path();
82 return mapd_root.string();
std::string get_root_abs_path()