if (! rgw_fh->is_file())
return -EINVAL;
- size_t nread = 0;
-
- /* XXX testing only */
- buffer::list bl;
RGWGetObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(),
- rgw_fh->object_name(), offset, length, bl);
+ rgw_fh->object_name(), offset, length,
+ buffer);
int rc = librgw.get_fe()->execute_req(&req);
-
+#if 0
if (! rc) {
uint64_t off = 0;
for (auto& bp : bl.buffers()) {
break;
}
}
-
- *bytes_read = nread;
+#endif
+ if ((rc == 0) &&
+ (req.get_ret() == 0)) {
+ *bytes_read = req.nread;
+ }
return rc;
}
if (! rgw_fh->is_file())
return -EINVAL;
+ int rc = 0;
+#if 0 /* XXX */
buffer::list bl;
RGWGetObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(),
rgw_fh->object_name(), uio->uio_offset, uio->uio_resid,
bl);
req.do_hexdump = false;
- int rc = librgw.get_fe()->execute_req(&req);
+ rc = librgw.get_fe()->execute_req(&req);
if (! rc) {
RGWReadV* rdv = static_cast<RGWReadV*>(
++ix;
}
}
-
+#endif
return rc;
}
public:
const std::string& bucket_name;
const std::string& obj_name;
- buffer::list& bl;
+ void *ulp_buffer;
+ size_t nread;
+ size_t read_len;
bool do_hexdump = false;
RGWGetObjRequest(CephContext* _cct, RGWUserInfo *_user,
const std::string& _bname, const std::string& _oname,
- uint64_t off, uint64_t len, buffer::list& _bl)
+ uint64_t off, uint64_t len, void *_ulp_buffer)
: RGWLibRequest(_cct, _user), bucket_name(_bname), obj_name(_oname),
- bl(_bl) {
+ ulp_buffer(_ulp_buffer), nread(0), read_len(len) {
magic = 76;
op = this;
RGWGetObj::end = off + len;
}
- buffer::list& get_bl() { return bl; }
-
virtual bool only_bucket() { return false; }
virtual int op_init() {
return 0;
}
- virtual int send_response_data(ceph::buffer::list& _bl, off_t s_off,
+ virtual int send_response_data(ceph::buffer::list& bl, off_t s_off,
off_t e_off) {
- /* XXX deal with offsets */
if (do_hexdump) {
dout(15) << __func__ << " s_off " << s_off
- << " e_off " << e_off << " len " << _bl.length()
+ << " e_off " << e_off << " len " << bl.length()
<< " ";
- _bl.hexdump(*_dout);
+ bl.hexdump(*_dout);
*_dout << dendl;
}
- bl.claim_append(_bl);
+ uint64_t off = 0;
+ for (auto& bp : bl.buffers()) {
+ if (nread >= read_len)
+ break;
+ size_t bytes = std::min(std::min(read_len, size_t(bp.length())),
+ size_t(e_off));
+ memcpy(static_cast<char*>(ulp_buffer)+off, bp.c_str()+s_off, bytes);
+ nread += bytes;
+ off += bytes;
+ s_off -= bytes;
+ }
return 0;
}
string secret_key("");
struct rgw_fs *fs = nullptr;
+ bool do_create = false;
bool do_delete = false;
bool do_verify = false;
bool do_hexdump = false;
}
TEST(LibRGW, CREATE_BUCKET) {
- struct stat st;
- struct rgw_file_handle *fh;
- int ret = rgw_mkdir(fs, fs->root_fh, bucket_name.c_str(), 755, &st, &fh);
- ASSERT_EQ(ret, 0);
+ if (do_create) {
+ struct stat st;
+ struct rgw_file_handle *fh;
+ int ret = rgw_mkdir(fs, fs->root_fh, bucket_name.c_str(), 755, &st, &fh);
+ ASSERT_EQ(ret, 0);
+ }
}
TEST(LibRGW, LOOKUP_BUCKET) {
} else if (ceph_argparse_flag(args, arg_iter, "--verify",
(char*) nullptr)) {
do_verify = true;
+ } else if (ceph_argparse_flag(args, arg_iter, "--create",
+ (char*) nullptr)) {
+ do_create = true;
} else if (ceph_argparse_flag(args, arg_iter, "--delete",
(char*) nullptr)) {
do_delete = true;