]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs: add ceph_conf_parse_env()
authorSage Weil <sage@inktank.com>
Mon, 13 May 2013 17:02:05 +0000 (10:02 -0700)
committerSage Weil <sage@inktank.com>
Mon, 13 May 2013 17:16:32 +0000 (10:16 -0700)
This exists in the librados API.

Signed-off-by: Sage Weil <sage@inktank.com>
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index df4ae9f8bbb6167319489ecf89e3f8cf66d6cb2a..55e32743b9b9529956727af75b8013162019fbbb 100644 (file)
@@ -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
index d43b3dbbe64ab4a7a4c6254b88b8fb139edb9f85..9d68715e7816ff510eec0d2ba608a724ba5ccbb4 100644 (file)
@@ -172,6 +172,18 @@ public:
     return 0;
   }
 
+  int conf_parse_env(const char *name)
+  {
+    md_config_t *conf = cct->_conf;
+    vector<const char*> 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)
 {