diff options
author | pjd <pjd@FreeBSD.org> | 2005-08-14 21:55:18 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2005-08-14 21:55:18 +0000 |
commit | 3c2828d3f48dcca202bda61f4e4777515d06d641 (patch) | |
tree | a00428a2d2d72fa4a5092da0803da66c2de4bdfb /sbin/geom/core | |
parent | 481f28c27d950908b0be332ed2c72df1c0a6ec3b (diff) | |
download | FreeBSD-src-3c2828d3f48dcca202bda61f4e4777515d06d641.zip FreeBSD-src-3c2828d3f48dcca202bda61f4e4777515d06d641.tar.gz |
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.
MFC after: 3 days
Diffstat (limited to 'sbin/geom/core')
-rw-r--r-- | sbin/geom/core/geom.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/sbin/geom/core/geom.c b/sbin/geom/core/geom.c index 17a4ad8..3db7cf4 100644 --- a/sbin/geom/core/geom.c +++ b/sbin/geom/core/geom.c @@ -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", |