int read(int pool, object_t& oid, off_t off, bufferlist& bl, size_t len);
int remove(int pool, object_t& oid);
- int exec(int pool, object_t& oid, const char *cls, const char *method, bufferlist& inbl, size_t in_len, bufferlist& outbl, size_t out_len);
+ int exec(int pool, object_t& oid, const char *cls, const char *method, bufferlist& inbl, bufferlist& outbl);
};
bool RadosClient::init()
return r;
}
-int RadosClient::exec(int pool, object_t& oid, const char *cls, const char *method, bufferlist& inbl, size_t in_len, bufferlist& outbl, size_t out_len)
+int RadosClient::exec(int pool, object_t& oid, const char *cls, const char *method,
+ bufferlist& inbl, bufferlist& outbl)
{
SnapContext snapc;
utime_t ut = g_clock.now();
lock.Lock();
ObjectRead rd;
-
rd.rdcall(cls, method, inbl);
objecter->read(oid, layout, rd, CEPH_NOSNAP, &outbl, 0, onack);
lock.Unlock();
- if (outbl.length() < out_len)
- out_len = outbl.length();
-
- return out_len;
+ return r;
}
int RadosClient::read(int pool, object_t& oid, off_t off, bufferlist& bl, size_t len)
}
int Rados::exec(rados_pool_t pool, object_t& oid, const char *cls, const char *method,
- bufferlist& inbl, size_t in_len, bufferlist& outbl, size_t out_len)
+ bufferlist& inbl, bufferlist& outbl)
{
if (!client)
return -EINVAL;
- return client->exec(pool, oid, cls, method, inbl, in_len, outbl, out_len);
+ return client->exec(pool, oid, cls, method, inbl, outbl);
}
int Rados::open_pool(const char *name, rados_pool_t *pool)
object_t oid(*o);
bufferlist bl;
ret = radosp->read(pool, oid, off, bl, len);
- if (ret > 0)
- memcpy(buf, bl.c_str(), ret);
+ if (ret >= 0) {
+ if (bl.length() > len)
+ return -ERANGE;
+ bl.copy(0, bl.length(), buf);
+ ret = bl.length(); // hrm :/
+ }
return ret;
}
bufferlist inbl, outbl;
int ret;
inbl.append(inbuf, in_len);
- ret = radosp->exec(pool, oid, cls, method, inbl, in_len, outbl, out_len);
- if (ret > 0)
- memcpy(buf, outbl.c_str(), ret);
-
+ ret = radosp->exec(pool, oid, cls, method, inbl, outbl);
+ if (ret >= 0) {
+ if (outbl.length()) {
+ if (outbl.length() > out_len)
+ return -ERANGE;
+ outbl.copy(0, outbl.length(), buf);
+ ret = outbl.length(); // hrm :/
+ }
+ }
return ret;
}
cout << "open pool result = " << r << " pool = " << pool << std::endl;
rados.write(pool, oid, 0, bl, bl.length());
- rados.exec(pool, oid, "test", "foo", bl, bl.length(), bl2, 1024);
+ rados.exec(pool, oid, "test", "foo", bl, bl2);
cout << "exec result=" << bl2.c_str() << std::endl;
int size = rados.read(pool, oid, 0, bl2, 128);