(req.get_ret() == 0) &&
(req.matched())) {
fhr = lookup_fh(parent, path,
- RGWFileHandle::FLAG_CREATE|RGWFileHandle::FLAG_BUCKET);
+ RGWFileHandle::FLAG_CREATE|
+ RGWFileHandle::FLAG_BUCKET);
}
return fhr;
}
break;
case 1:
{
- RGWStatLeafRequest req(cct, get_user(), parent->bucket_name(),
- object_name);
+ RGWStatLeafRequest req(cct, get_user(), parent, object_name);
int rc = librgw.get_fe()->execute_req(&req);
if ((rc == 0) &&
(req.get_ret() == 0)) {
if (req.matched) {
fhr = lookup_fh(parent, path,
- (req.path.back() == '/') ?
- RGWFileHandle::FLAG_DIRECTORY :
- RGWFileHandle::FLAG_NONE);
+ RGWFileHandle::FLAG_CREATE|
+ ((req.path.back() == '/') ?
+ RGWFileHandle::FLAG_DIRECTORY :
+ RGWFileHandle::FLAG_NONE));
}
}
}
RGWFileHandle* parent = get_rgwfh(parent_fh);
if ((! parent) ||
(parent->is_root()) ||
- (parent->is_object())) {
+ (parent->is_file())) {
/* bad parent */
return -EINVAL;
}
RGWFileHandle* parent = get_rgwfh(parent_fh);
if ((! parent) ||
- (parent->is_object())) {
+ (! parent->is_dir())) {
/* bad parent */
return -EINVAL;
}
RGWLibFS *fs = static_cast<RGWLibFS*>(rgw_fs->fs_private);
RGWFileHandle* rgw_fh = get_rgwfh(fh);
- if (! rgw_fh->is_object())
+ if (! rgw_fh->is_file())
return -EINVAL;
size_t nread = 0;
RGWLibFS *fs = static_cast<RGWLibFS*>(rgw_fs->fs_private);
RGWFileHandle* rgw_fh = get_rgwfh(fh);
- if (! rgw_fh->is_object())
+ if (! rgw_fh->is_file())
return -EINVAL;
/* XXXX testing only */
RGWLibFS *fs = static_cast<RGWLibFS*>(rgw_fs->fs_private);
RGWFileHandle* rgw_fh = get_rgwfh(fh);
- if (! rgw_fh->is_object())
+ if (! rgw_fh->is_file())
return -EINVAL;
buffer::list bl;
RGWLibFS *fs = static_cast<RGWLibFS*>(rgw_fs->fs_private);
RGWFileHandle* rgw_fh = get_rgwfh(fh);
- if (! rgw_fh->is_object())
+ if (! rgw_fh->is_file())
return -EINVAL;
buffer::list bl;
s->op = OP_GET;
/* XXX derp derp derp */
- string uri = "/" + rgw_fh->bucket_name() + "/";
+ std::string uri = "/" + rgw_fh->bucket_name() + "/";
s->relative_uri = uri;
s->info.request_uri = uri; // XXX
s->info.effective_uri = uri;
public RGWListBucket /* RGWOp */
{
public:
- const std::string& bucket;
+ RGWFileHandle* rgw_fh;
std::string path;
bool matched;
RGWStatLeafRequest(CephContext* _cct, RGWUserInfo *_user,
- const std::string& _bucket, const std::string& _path)
- : RGWLibRequest(_cct, _user), bucket(_bucket), path(_path),
+ RGWFileHandle* _rgw_fh, const std::string& _path)
+ : RGWLibRequest(_cct, _user), rgw_fh(_rgw_fh), path(_path),
matched(false) {
- default_max = 2; // logical max {"foo", "foo/"}
+ default_max = 1000; // logical max {"foo", "foo/"}
magic = 80;
op = this;
}
s->op = OP_GET;
/* XXX derp derp derp */
- std::string uri = "/" + bucket;
+ std::string uri = "/" + rgw_fh->bucket_name() + "/";
s->relative_uri = uri;
s->info.request_uri = uri; // XXX
s->info.effective_uri = uri;
// woo
s->user = user;
+ prefix = rgw_fh->full_object_name();
+ delimiter = '/';
+
return 0;
}
virtual int get_params() {
- // XXX S3
- struct req_state* s = get_state();
- list_versions = s->info.args.exists("versions");
- if (!list_versions) {
- marker = s->info.args.get("marker");
- } else {
- marker.name = s->info.args.get("key-marker");
- marker.instance = s->info.args.get("version-id-marker");
- }
- max_keys = default_max; // 2
- prefix = path;
- delimiter = "/";
-#if 0 /* XXX? */
- encoding_type = s->info.args.get("encoding-type");
-#endif
+ max = default_max;
return 0;
}
virtual void send_response() {
+ // try objects
for (const auto& iter : objs) {
path = iter.key.name;
matched = true;
+ return;
+ }
+ // try prefixes
+ for (auto& iter : common_prefixes) {
+ path = iter.first;
+ matched = true;
break;
}
}
extern "C" {
static bool r1_cb(const char* name, void *arg, uint64_t offset) {
+ struct rgw_file_handle* parent_fh
+ = static_cast<struct rgw_file_handle*>(arg);
obj_stack.push(
- obj_rec{name, nullptr, nullptr, nullptr});
+ obj_rec{name, nullptr, parent_fh, nullptr});
return true; /* XXX */
}
}
// descending
uint64_t offset;
bool eof; // XXX
- rc = rgw_readdir(fs, elt.parent_fh, &offset, r1_cb,
- &obj_stack, &eof);
+ rc = rgw_readdir(fs, elt.fh, &offset, r1_cb, elt.fh, &eof);
elt.state.readdir = true;
ASSERT_EQ(rc, 0);
ASSERT_TRUE(eof);