diff options
author | azzolini <azzolini@fb.com> | 2013-10-11 11:38:07 -0700 |
---|---|---|
committer | Kevin Vigor <kvigor@fb.com> | 2016-12-06 12:50:26 -0800 |
commit | cc9c18dc066a9e8f1020acc421dbefc3550d3ea5 (patch) | |
tree | eed046928fbc77767fda457352d6241fc0aad945 | |
parent | d1ac991503b0153b12406d16ce99cd22dadfe0f7 (diff) |
[glusterfs] Allow to set dynamic library path from env variable
Summary:
This allows to ship all glusterfs dependencies to hadoop
machines in a tarball.
Test Plan:
- build tarball: https://phabricator.fb.com/P2848521
- scp to a machine with no gluster installed
echo "Hellow world" | LD_LIBRARY_PATH=glusterfs_libs GLUSTER_LIBDIR=glusterfs_libs ./glfscat $(shuf -n 1 <(smcc ls storage.gluster.gfsops.frc1) | cut -d: -f 1) groot /gfsetlprocstore/adslearner/users/azzolini/hello_world.txt
(code for glfscat follows in a separate diff)
Reviewers: rwareing
Reviewed By: rwareing
Differential Revision: https://phabricator.fb.com/D1009665
Change-Id: I8812929fc127ca291aa66e2430b5633892235915
Signed-off-by: Kevin Vigor <kvigor@fb.com>
Reviewed-on: http://review.gluster.org/16032
Reviewed-by: Shreyas Siravara <shreyas.siravara@gmail.com>
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
-rw-r--r-- | libglusterfs/src/xlator.c | 16 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpc-transport.c | 15 |
2 files changed, 27 insertions, 4 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 3c1cde50fa0..b2529d3c4f7 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -117,6 +117,14 @@ out: } +static const char *xlator_lib_path (void) +{ + const char *libdir_env = getenv ("GLUSTER_LIBDIR"); + + return libdir_env ? libdir_env : XLATORDIR; +} + + int xlator_volopt_dynload (char *xlator_type, void **dl_handle, volume_opt_list_t *opt_list) @@ -130,9 +138,11 @@ xlator_volopt_dynload (char *xlator_type, void **dl_handle, /* socket.so doesn't fall under the default xlator directory, hence we * need this check */ if (!strstr(xlator_type, "rpc-transport")) - ret = gf_asprintf (&name, "%s/%s.so", XLATORDIR, xlator_type); + ret = gf_asprintf (&name, "%s/%s.so", xlator_lib_path (), + xlator_type); else - ret = gf_asprintf (&name, "%s/%s.so", XLATORPARENTDIR, xlator_type); + ret = gf_asprintf (&name, "%s/../%s.so", xlator_lib_path (), + xlator_type); if (-1 == ret) { goto out; } @@ -183,7 +193,7 @@ xlator_dynload (xlator_t *xl) INIT_LIST_HEAD (&xl->volume_options); - ret = gf_asprintf (&name, "%s/%s.so", XLATORDIR, xl->type); + ret = gf_asprintf (&name, "%s/%s.so", xlator_lib_path (), xl->type); if (-1 == ret) { goto out; } diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c index e224dcc022e..22324fb9994 100644 --- a/rpc/rpc-lib/src/rpc-transport.c +++ b/rpc/rpc-lib/src/rpc-transport.c @@ -166,6 +166,19 @@ out: +int rpc_transport_lib_path (char **name, char *type) +{ + int ret = -1; + char *libdir_env = getenv ("GLUSTER_LIBDIR"); + + ret = libdir_env == NULL + ? gf_asprintf (name, "%s/%s.so", RPC_TRANSPORTDIR, type) + : gf_asprintf (name, "%s/rpc-transport/%s.so", libdir_env, type); + return ret; +} + + + rpc_transport_t * rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name) { @@ -274,7 +287,7 @@ rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name) goto fail; } - ret = gf_asprintf (&name, "%s/%s.so", RPC_TRANSPORTDIR, type); + ret = rpc_transport_lib_path (&name, type); if (-1 == ret) { goto fail; } |