return -EINVAL;
}
- /* XXX: atomicity */
- LookupFHResult fhr = fs->lookup_fh(parent, name);
- RGWFileHandle* rgw_fh = get<0>(fhr);
+ LookupFHResult fhr;
+ RGWFileHandle* rgw_fh;
if (parent->is_root()) {
- /* mkdir in root creates a new bucket */
+ /* bucket */
+ fhr = fs->lookup_fh(parent, name);
uri += "/"; /* XXX */
uri += name;
RGWCreateBucketRequest req(cct, fs->get_user(), uri);
rc = librgw.get_fe()->execute_req(&req);
- } else
- rgw_fh->set_pseudo();
+ } else {
+ /* pseudofs */
+ LookupFHResult fhr =
+ fs->lookup_fh(parent, name, RGWFileHandle::FLAG_PSEUDO);
+ }
+ rgw_fh = get<0>(fhr);
struct rgw_file_handle *rfh = rgw_fh->get_fh();
*fh = rfh;
/* XXX */
RGWPutObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(),
- rgw_fh->object_name(), bl);
+ rgw_fh->full_object_name(), bl);
int rc = librgw.get_fe()->execute_req(&req);
}
RGWPutObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(),
- rgw_fh->object_name(), bl);
+ rgw_fh->full_object_name(), bl);
int rc = librgw.get_fe()->execute_req(&req);
: parent(_parent), name(std::move(_name)), fhk(_fhk), flags(FLAG_NONE) {
fh.fh_type = parent->is_root()
- ? RGW_FS_TYPE_DIRECTORY : RGW_FS_TYPE_FILE;
+ ? RGW_FS_TYPE_DIRECTORY : RGW_FS_TYPE_FILE;
depth = parent->depth + 1;
/* save constant fhk */
- fh_key fhk(parent->bucket_name(), make_path());
fh.fh_hk = fhk.fh_hk; /* XXX redundant in fh_hk */
/* pointer to self */
const std::string& object_name() const { return name; }
- std::string make_path() {
+ std::string full_object_name() {
if (depth <= 1) {
return object_name();
}
}
/* find or create an RGWFileHandle */
- LookupFHResult lookup_fh(RGWFileHandle* parent, const char *name) {
+ LookupFHResult lookup_fh(RGWFileHandle* parent, const char *name,
+ const uint32_t cflags = RGWFileHandle::FLAG_NONE) {
std::string sname(name);
RGWFileHandle::FHCache::Latch lat;
intrusive_ptr_add_ref(fh); /* sentinel ref */
fh_cache.insert_latched(fh, lat,
RGWFileHandle::FHCache::FLAG_NONE);
+ if (cflags & RGWFileHandle::FLAG_PSEUDO)
+ fh->set_pseudo();
get<1>(fhr) = RGWFileHandle::FLAG_CREATE;
}
intrusive_ptr_add_ref(fh); /* call path/handle ref */