MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / getRealPath

Method getRealPath

src/common/os/posix/mod_loader.cpp:224–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224bool DlfcnModule::getRealPath(const Firebird::string& anySymbol, Firebird::PathName& path)
225{
226 if (realPath.hasData())
227 {
228 path = realPath;
229 return true;
230 }
231
232 char buffer[PATH_MAX];
233
234#ifdef HAVE_DLINFO
235#ifdef HAVE_RTLD_DI_ORIGIN
236 if (dlinfo(module, RTLD_DI_ORIGIN, buffer) == 0)
237 {
238 path = buffer;
239 path += '/';
240 path += fileName;
241
242 if (realpath(path.c_str(), buffer))
243 {
244 path = buffer;
245 return true;
246 }
247 }
248#endif
249
250#ifdef HAVE_RTLD_DI_LINKMAP
251 struct link_map* lm;
252 if (dlinfo(module, RTLD_DI_LINKMAP, &lm) == 0)
253 {
254 if (realpath(lm->l_name, buffer))
255 {
256 path = buffer;
257 return true;
258 }
259 }
260#endif
261
262#endif
263
264#ifdef HAVE_DLADDR
265 if (anySymbol.hasData())
266 {
267 void* symbolPtr = dlsym(module, anySymbol.c_str());
268
269 if (!symbolPtr)
270 symbolPtr = dlsym(module, ('_' + anySymbol).c_str());
271
272 if (symbolPtr)
273 {
274 Dl_info info;
275 if (dladdr(symbolPtr, &info))
276 {
277 if (realpath(info.dli_fname, buffer))
278 {
279 path = buffer;
280 return true;
281 }

Callers 1

initializeMethod · 0.45

Calls 3

hasDataMethod · 0.45
c_strMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected