if (! rgw_fh->is_file())
return -EINVAL;
- RGWReadRequest req(cct, fs->get_user(), rgw_fh->bucket_name(),
- rgw_fh->object_name(), offset, length,
- buffer);
+ RGWReadRequest req(cct, fs->get_user(), rgw_fh, offset, length, buffer);
int rc = rgwlib.get_fe()->execute_req(&req);
if ((rc == 0) &&
public RGWGetObj /* RGWOp */
{
public:
- const std::string& bucket_name;
- const std::string& obj_name;
+ RGWFileHandle* rgw_fh;
void *ulp_buffer;
size_t nread;
size_t read_len;
bool do_hexdump = false;
RGWReadRequest(CephContext* _cct, RGWUserInfo *_user,
- const std::string& _bname, const std::string& _oname,
- uint64_t off, uint64_t len, void *_ulp_buffer)
- : RGWLibRequest(_cct, _user), bucket_name(_bname), obj_name(_oname),
- ulp_buffer(_ulp_buffer), nread(0), read_len(len) {
+ RGWFileHandle* _rgw_fh, uint64_t off, uint64_t len,
+ void *_ulp_buffer)
+ : RGWLibRequest(_cct, _user), rgw_fh(_rgw_fh), ulp_buffer(_ulp_buffer),
+ nread(0), read_len(len) {
magic = 76;
op = this;
s->op = OP_GET;
/* XXX derp derp derp */
- std::string uri = make_uri(bucket_name, obj_name);
- s->relative_uri = uri;
- s->info.request_uri = uri; // XXX
- s->info.effective_uri = uri;
+ s->relative_uri = make_uri(rgw_fh->bucket_name(),
+ rgw_fh->relative_object_name());
+ s->info.request_uri = s->relative_uri; // XXX
+ s->info.effective_uri = s->relative_uri;
s->info.request_params = "";
s->info.domain = ""; /* XXX ? */
}
}
+TEST(LibRGW, READ_DIRS1)
+{
+ if (do_dirs1) {
+ int rc;
+ char buf[256];
+ uint64_t nread;
+ for (auto& dirs_rec : dirs_vec) {
+ obj_rec& dir = get<0>(dirs_rec);
+ if (verbose) {
+ std::cout << "read back objects in "
+ << dir.rgw_fh->full_object_name()
+ << std::endl;
+ }
+ for (auto& sobj : get<1>(dirs_rec)) {
+ /* only the first 2 file objects have data */
+ if ((sobj.rgw_fh->object_name().find("sfile_0")
+ != std::string::npos) ||
+ (sobj.rgw_fh->object_name().find("sfile_1")
+ != std::string::npos)) {
+ ASSERT_TRUE(sobj.rgw_fh->is_file());
+ // do it
+ memset(buf, 0, 256);
+ rc = rgw_read(fs, sobj.fh, 0, 256, &nread, buf, RGW_READ_FLAG_NONE);
+ ASSERT_EQ(rc, 0);
+ if (verbose) {
+ std::cout << "\tread back from " << sobj.name
+ << " : \"" << buf << "\""
+ << std::endl;
+ }
+ }
+ }
+ }
+ }
+}
+
TEST(LibRGW, RELEASE_DIRS1) {
if (do_dirs1) {
/* force release of handles for children of dirs1--force subsequent