Normalize the given image path in load_container(). Just constructing

some absolute path was not enough to always recognize a library as
already loaded. This fixes problems with Perl where loading an add-on
would cause another instance of libperl.so to be loaded, which would
lead to crashes due to uninitialized static vars in the new instance.
Perl builds now and the tests run, but quite a few do fail.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23930 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2008-02-08 03:18:26 +00:00
parent 2c986936df
commit 6918dbf421

View File

@ -997,29 +997,10 @@ load_container(char const *name, image_type type, const char *rpath, image_t **_
return fd;
}
// If the path is not absolute, we prepend the CWD to make it one.
if (path[0] != '/') {
char relativePath[PATH_MAX];
if (!strncmp(path, "./", 2))
strcpy(relativePath, path + 2);
else
strcpy(relativePath, path);
// get the CWD
status = _kern_getcwd(path, sizeof(path));
if (status < B_OK) {
FATAL("_kern_getcwd() failed\n");
// normalize the image path
status = _kern_normalize_path(path, true, path);
if (status != B_OK)
goto err1;
}
if (strlcat(path, "/", sizeof(path)) >= sizeof(path)
|| strlcat(path, relativePath, sizeof(path)) >= sizeof(path)) {
status = B_NAME_TOO_LONG;
FATAL("Absolute path of image %s is too "
"long!\n", relativePath);
goto err1;
}
}
// Test again if this image has been registered already - this time,
// we can check the full path, not just its name as noted.