int rc = 0;
/* stash access data for "mount" */
- RGWLibFS* new_fs = new RGWLibFS(uid, acc_key, sec_key);
+ RGWLibFS* new_fs = new RGWLibFS(static_cast<CephContext*>(rgw), uid, acc_key,
+ sec_key);
assert(new_fs);
rc = new_fs->authorize(librgw.get_store());
RGWFileHandle* rgw_fh;
if (parent->is_root()) {
- /* XXX if lookup is in the root, then (for now) just get a handle */
- rgw_fh = fs->lookup_fh(parent, path);
- if (! rgw_fh)
- return ENOENT;
+ /* special: lookup on root itself */
+ if (strcmp(path, "/") == 0) {
+ rgw_fh = parent->ref();
+ } else {
+ /* name lookup in root--for now) just get a handle */
+ rgw_fh = fs->lookup_fh(parent, path);
+ if (! rgw_fh)
+ return ENOENT;
+ }
} else {
std::string object_name{path};
RGWStatObjRequest req(cct, fs->get_user(),
rgw_fh = fs->lookup_fh(parent, path);
if (! rgw_fh)
return ENOENT;
- }
+ } /* !root */
struct rgw_file_handle *rfh = rgw_fh->get_fh();
*fh = rfh;
}
}
+ RGWFileHandle* ref() {
+ intrusive_ptr_add_ref(this);
+ return this;
+ }
+
inline void rele() {
intrusive_ptr_release(this);
}
class RGWLibFS
{
+ CephContext* cct;
struct rgw_fs fs;
RGWFileHandle root_fh;
std::string fsid;
public:
- RGWLibFS(const char *_uid, const char *_user_id, const char* _key)
- : root_fh(this), uid(_uid), key(_user_id, _key) {
+ RGWLibFS(CephContext* _cct, const char *_uid, const char *_user_id,
+ const char* _key)
+ : cct(_cct), root_fh(this), uid(_uid), key(_user_id, _key) {
/* no bucket may be named rgw_fs_inst-(.*) */
fsid = RGWFileHandle::root_name + "rgw_fs_inst-" +
}
CephContext* get_context() {
- return static_cast<CephContext*>(get_fs()->fs_private);
+ return cct;
}
struct rgw_fs* get_fs() { return &fs; }