diff options
author | pjd <pjd@FreeBSD.org> | 2005-02-27 21:14:58 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2005-02-27 21:14:58 +0000 |
commit | 45fc09dc07feb26d9e48db8b8f0a2167c6ec55a6 (patch) | |
tree | 9760831c775fd1c8bdbc851707ccbb934d6a6edf /sbin/geom | |
parent | 6c7be54e9bb56a4fb982d0ccf5ff7fc227a543c6 (diff) | |
download | FreeBSD-src-45fc09dc07feb26d9e48db8b8f0a2167c6ec55a6.zip FreeBSD-src-45fc09dc07feb26d9e48db8b8f0a2167c6ec55a6.tar.gz |
- Add GEOM_LIBRARY_PATH environment variable which allows to specify an
alternative to /lib/geom/ path where shared libraries are stored.
- Improve debugging.
MFC after: 3 days
Diffstat (limited to 'sbin/geom')
-rw-r--r-- | sbin/geom/core/geom.8 | 8 | ||||
-rw-r--r-- | sbin/geom/core/geom.c | 22 |
2 files changed, 27 insertions, 3 deletions
diff --git a/sbin/geom/core/geom.8 b/sbin/geom/core/geom.8 index 4d3f925..ba1b7c6 100644 --- a/sbin/geom/core/geom.8 +++ b/sbin/geom/core/geom.8 @@ -96,6 +96,14 @@ SHSEC .It STRIPE .El +.Sh ENVIRONMENT +The following environment variables affect the execution of +.Nm : +.Bl -tag -width ".Ev GEOM_LIBRARY_PATH" +.It Ev GEOM_LIBRARY_PATH +Specifies the path where shared libraries are stored instead of +.Pa /lib/geom/ . +.El .Sh EXIT STATUS Exit status is 0 on success, and 1 if the command fails. .Sh EXAMPLES diff --git a/sbin/geom/core/geom.c b/sbin/geom/core/geom.c index c093c94..126c2eb 100644 --- a/sbin/geom/core/geom.c +++ b/sbin/geom/core/geom.c @@ -446,6 +446,17 @@ run_command(int argc, char *argv[]) exit(EXIT_SUCCESS); } +static const char * +library_path(void) +{ + const char *path; + + path = getenv("GEOM_LIBRARY_PATH"); + if (path == NULL) + path = CLASS_DIR; + return (path); +} + static void load_library(void) { @@ -453,7 +464,8 @@ load_library(void) uint32_t *lib_version; void *dlh; - snprintf(path, sizeof(path), "%s/geom_%s.so", CLASS_DIR, class_name); + snprintf(path, sizeof(path), "%s/geom_%s.so", library_path(), + class_name); dlh = dlopen(path, RTLD_NOW); if (dlh == NULL) { #if 0 @@ -670,8 +682,10 @@ std_list_available(void) int error; error = geom_gettree(&mesh); - if (error != 0) + if (error != 0) { + fprintf(stderr, "Cannot get GEOM tree: %s.\n", strerror(error)); exit(EXIT_FAILURE); + } classp = find_class(&mesh, gclass_name); geom_deletetree(&mesh); if (classp != NULL) @@ -688,8 +702,10 @@ std_list(struct gctl_req *req, unsigned flags __unused) int error, *nargs; error = geom_gettree(&mesh); - if (error != 0) + if (error != 0) { + fprintf(stderr, "Cannot get GEOM tree: %s.\n", strerror(error)); exit(EXIT_FAILURE); + } classp = find_class(&mesh, gclass_name); if (classp == NULL) { geom_deletetree(&mesh); |