*/
int64_t ceph_get_fs_cid(struct ceph_mount_info *cmount);
+typedef void (*libcephfs_c_completion_t)(int rc, const void* out, size_t outlen, const void* outs, size_t outslen, void* ud);
+
+int ceph_mds_command2(struct ceph_mount_info *cmount,
+ const char *mds_spec,
+ const char **cmd,
+ size_t cmdlen,
+ const char *inbuf, size_t inbuflen,
+ int one_shot,
+ libcephfs_c_completion_t c,
+ void* ud);
+
/**
* Execute a management command remotely on an MDS.
*
return ceph_conf_set(cmount, "client_mount_timeout", timeout_str.c_str());
}
+class CommandCContext : public Context {
+public:
+ CommandCContext(libcephfs_c_completion_t c, void* ud) : c(c), ud(ud) {}
+
+ void finish(int rc) {
+ c(rc, outbl.c_str(), outbl.length(), outs.c_str(), outs.size(), ud);
+ }
+
+ libcephfs_c_completion_t c;
+ void* ud;
+ bufferlist outbl;
+ std::string outs;
+};
+
+extern "C" int ceph_mds_command2(struct ceph_mount_info *cmount,
+ const char *mds_spec,
+ const char **cmd,
+ size_t cmdlen,
+ const char *inbuf, size_t inbuflen,
+ int one_shot,
+ libcephfs_c_completion_t c,
+ void* ud)
+{
+ bufferlist inbl;
+ std::vector<string> cmdv;
+
+ if (!cmount->is_initialized()) {
+ return -ENOTCONN;
+ }
+
+ // Construct inputs
+ for (size_t i = 0; i < cmdlen; ++i) {
+ cmdv.push_back(cmd[i]);
+ }
+ inbl.append(inbuf, inbuflen);
+
+ // Issue remote command
+ auto* ctx = new CommandCContext(c, ud);
+ int r = cmount->get_client()->mds_command(mds_spec, cmdv, inbl, &ctx->outbl, &ctx->outs, ctx, one_shot);
+
+ if (r != 0) {
+ delete ctx;
+ return r;
+ }
+
+ return 0;
+}
+
+
extern "C" int ceph_mds_command(struct ceph_mount_info *cmount,
const char *mds_spec,
const char **cmd,