]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
libceph: implement ceph_conf_set and ceph_conf_get
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 15 Apr 2011 17:37:05 +0000 (10:37 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 15 Apr 2011 17:38:26 +0000 (10:38 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/client/libceph.h
src/libceph.cc

index 4ee05f630b155c25d954273dc0f23fbf4d283f23..9350593a473769e81b228b27557e535878fc04bc 100644 (file)
@@ -43,6 +43,17 @@ const char *ceph_version(int *major, int *minor, int *patch);
 int ceph_initialize(int argc, const char **argv);
 void ceph_deinitialize();
 
+/* Sets a configuration value from a string.
+ * Returns 0 on success, error code otherwise. */
+int ceph_conf_set(const char *option, const char *value);
+
+/* Returns a configuration value as a string.
+ * If len is positive, that is the maximum number of bytes we'll write into the
+ * buffer. If len == -1, we'll call malloc() and set *buf.
+ * Returns 0 on success, error code otherwise. Returns ENAMETOOLONG if the
+ * buffer is too short. */
+int ceph_conf_get(const char *option, char *buf, size_t len);
+
 int ceph_mount();
 int ceph_umount();
 
index 17513e1edabd1fe4c4d4f25064652acd9d508559..a5f7bf56803cd03bb6e2582cfe275093bf327945 100644 (file)
@@ -93,6 +93,17 @@ extern "C" void ceph_deinitialize()
   ceph_client_mutex.Unlock();
 }
 
+extern "C" int ceph_conf_set(const char *option, const char *value)
+{
+  return g_conf.set_val(option, value);
+}
+
+extern "C" int ceph_conf_get(const char *option, char *buf, size_t len)
+{
+  char *tmp = buf;
+  return g_conf.get_val(option, &tmp, len);
+}
+
 extern "C" int ceph_mount()
 {
   int ret;