MFC: sbin/geom/core/geom.c 1.23
Unfortunately dlerror(3) returns string, so there is no clean way to ignore "no such file" errors only, which I wanted to do. Because of this I ignored all other errors on dlopen(3) failure as well, which isn't good. Fix this situation by calling access(2) on library file first and ignore only ENOENT error. This allows to report all the rest of dlopen(3) errors. Approved by: re (kensmith)
This commit is contained in:
parent
0bd357e9d3
commit
c385fd9b5d
@ -471,18 +471,19 @@ load_library(void)
|
||||
|
||||
snprintf(path, sizeof(path), "%s/geom_%s.so", library_path(),
|
||||
class_name);
|
||||
dlh = dlopen(path, RTLD_NOW);
|
||||
if (dlh == NULL) {
|
||||
#if 0
|
||||
fprintf(stderr, "Cannot open library %s, but continuing "
|
||||
"anyway.\n", path);
|
||||
#endif
|
||||
/*
|
||||
* Even if library cannot be loaded, standard commands are
|
||||
* available, so don't panic!
|
||||
*/
|
||||
return;
|
||||
if (access(path, F_OK) == -1) {
|
||||
if (errno == ENOENT) {
|
||||
/*
|
||||
* If we cannot find library, that's ok, standard
|
||||
* commands can still be used.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
err(EXIT_FAILURE, "Cannot access library");
|
||||
}
|
||||
dlh = dlopen(path, RTLD_NOW);
|
||||
if (dlh == NULL)
|
||||
errx(EXIT_FAILURE, "Cannot open library: %s.", dlerror());
|
||||
lib_version = dlsym(dlh, "lib_version");
|
||||
if (lib_version == NULL) {
|
||||
fprintf(stderr, "Cannot find symbol %s: %s.\n", "lib_version",
|
||||
|
Loading…
Reference in New Issue
Block a user