0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-23 04:18:22 +02:00

ircd::mods::ldso: Add loaded check using the dlfcn method.

This commit is contained in:
Jason Volk 2020-03-08 18:55:33 -07:00
parent dc1778bce7
commit a4f18fcd00
2 changed files with 38 additions and 1 deletions

View file

@ -54,4 +54,7 @@ namespace ircd::mods::ldso
// Query link
string_view string(const struct link_map &, const size_t &idx);
bool for_each_needed(const struct link_map &, const string_closure &);
// dlfcn suite
bool loaded(const string_view &name);
}

View file

@ -18,7 +18,41 @@
///////////////////////////////////////////////////////////////////////////////
//
// mods/ldso.h
// dlfcn suite
//
#if defined(HAVE_DLFCN_H)
bool
ircd::mods::ldso::loaded(const string_view &name_)
try
{
static const int flags
{
RTLD_NOLOAD | RTLD_LAZY
};
const char *const name
{
data(strlcpy(fs::name_scratch, name_))
};
const custom_ptr<void> ptr
{
::dlopen(name, flags), ::dlclose
};
return ptr.get() != nullptr;
}
catch(...)
{
return false;
}
#endif // HAVE_DLFCN_H
///////////////////////////////////////////////////////////////////////////////
//
// link_map suite
//
#if defined(HAVE_LINK_H)