*/
CEPH_RADOS_API void rados_ioctx_set_namespace(rados_ioctx_t io,
const char *nspace);
+
+/**
+ * Get the namespace for objects within the io context
+ *
+ * @param io the io context to query
+ * @param buf pointer to buffer where name will be stored
+ * @param maxlen size of buffer where name will be stored
+ * @returns length of string stored, or -ERANGE if buffer too small
+ */
+CEPH_RADOS_API int rados_ioctx_get_namespace(rados_ioctx_t io, char *buf,
+ unsigned maxlen);
+
/** @} obj_loc */
/**
void locator_set_key(const std::string& key);
void set_namespace(const std::string& nspace);
+ std::string get_namespace() const;
int64_t get_id();
io_ctx_impl->oloc.nspace = nspace;
}
+std::string librados::IoCtx::get_namespace() const
+{
+ return io_ctx_impl->oloc.nspace;
+}
+
int64_t librados::IoCtx::get_id()
{
return io_ctx_impl->get_id();
tracepoint(librados, rados_ioctx_set_namespace_exit);
}
+extern "C" int rados_ioctx_get_namespace(rados_ioctx_t io, char *s,
+ unsigned maxlen)
+{
+ tracepoint(librados, rados_ioctx_get_namespace_enter, io, maxlen);
+ librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
+ auto length = ctx->oloc.nspace.length();
+ if (length >= maxlen) {
+ tracepoint(librados, rados_ioctx_get_namespace_exit, -ERANGE, "");
+ return -ERANGE;
+ }
+ strcpy(s, ctx->oloc.nspace.c_str());
+ int retval = (int)length;
+ tracepoint(librados, rados_ioctx_get_namespace_exit, retval, s);
+ return retval;
+}
+
extern "C" rados_t rados_ioctx_get_cluster(rados_ioctx_t io)
{
tracepoint(librados, rados_ioctx_get_cluster_enter, io);
ASSERT_EQ(0, rados_write(ioctx, "foo6", buf, sizeof(buf), 0));
ASSERT_EQ(0, rados_write(ioctx, "foo7", buf, sizeof(buf), 0));
+ char nspace[4];
+ ASSERT_EQ(-ERANGE, rados_ioctx_get_namespace(ioctx, nspace, 3));
+ ASSERT_EQ(0, rados_ioctx_get_namespace(ioctx, nspace, sizeof(nspace)));
+ ASSERT_EQ(0, strcmp("ns2", nspace));
+
std::set<std::string> def, ns1, ns2, all;
def.insert(std::string("foo1"));
def.insert(std::string("foo2"));
ioctx.set_namespace("ns2");
ASSERT_EQ(0, ioctx.write("foo6", bl1, sizeof(buf), 0));
ASSERT_EQ(0, ioctx.write("foo7", bl1, sizeof(buf), 0));
+ ASSERT_EQ(std::string("ns2"), ioctx.get_namespace());
std::set<std::string> def, ns1, ns2, all;
def.insert(std::string("foo1"));
TP_FIELDS()
)
+TRACEPOINT_EVENT(librados, rados_ioctx_get_namespace_enter,
+ TP_ARGS(
+ rados_ioctx_t, ioctx,
+ unsigned, maxlen),
+ TP_FIELDS(
+ ctf_integer_hex(rados_ioctx_t, ioctx, ioctx)
+ ctf_integer(unsigned, maxlen, maxlen)
+ )
+)
+
+TRACEPOINT_EVENT(librados, rados_ioctx_get_namespace_exit,
+ TP_ARGS(
+ int, retval,
+ const char*, name),
+ TP_FIELDS(
+ ctf_integer(int, retval, retval)
+ ctf_string(name, name)
+ )
+)
+
TRACEPOINT_EVENT(librados, rados_ioctx_get_cluster_enter,
TP_ARGS(
rados_ioctx_t, ioctx),