From: Sage Weil Date: Mon, 13 May 2013 17:02:05 +0000 (-0700) Subject: libcephfs: add ceph_conf_parse_env() X-Git-Tag: v0.64~124^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6db072d4a9d17e236e66b6cefe515d59e6becccd;p=ceph.git libcephfs: add ceph_conf_parse_env() This exists in the librados API. Signed-off-by: Sage Weil --- diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index df4ae9f8bbb6..55e32743b9b9 100644 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -179,6 +179,23 @@ int ceph_conf_read_file(struct ceph_mount_info *cmount, const char *path_list); */ int ceph_conf_parse_argv(struct ceph_mount_info *cmount, int argc, const char **argv); +/** + * Configure the cluster handle based on an environment variable + * + * The contents of the environment variable are parsed as if they were + * Ceph command line options. If var is NULL, the CEPH_ARGS + * environment variable is used. + * + * @pre ceph_mount() has not been called on the handle + * + * @note BUG: this is not threadsafe - it uses a static buffer + * + * @param cmount handle to configure + * @param var name of the environment variable to read + * @returns 0 on success, negative error code on failure + */ +int ceph_conf_parse_env(struct ceph_mount_info *cmount, const char *var); + /** Sets a configuration value from a string. * * @param cmount the mount handle to set the configuration value on diff --git a/src/libcephfs.cc b/src/libcephfs.cc index d43b3dbbe64a..9d68715e7816 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -172,6 +172,18 @@ public: return 0; } + int conf_parse_env(const char *name) + { + md_config_t *conf = cct->_conf; + vector args; + env_to_vec(args, name); + int ret = conf->parse_argv(args); + if (ret) + return ret; + conf->apply_changes(NULL); + return 0; + } + int conf_set(const char *option, const char *value) { int ret = cct->_conf->set_val(option, value); @@ -284,6 +296,11 @@ extern "C" int ceph_conf_parse_argv(struct ceph_mount_info *cmount, int argc, return cmount->conf_parse_argv(argc, argv); } +extern "C" int ceph_conf_parse_env(struct ceph_mount_info *cmount, const char *name) +{ + return cmount->conf_parse_env(name); +} + extern "C" int ceph_conf_set(struct ceph_mount_info *cmount, const char *option, const char *value) {