The current API relies on rgw_lookup and rgw_lookup_filehandle to
return file handle instances, and like POSIX, needs to deal in some
way with the NFS/POSIX open-for-create concept.
For now, allow rgw_lookup to return the canonical instance for an
object being created, i.e., if the option RGW_LOOKUP_FLAG_CREATE
is passed. (I added an RGW_OPEN_FLAG_CREATE also, but it doesn't
do anything.)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
/*
lookup object by name (POSIX style)
*/
+#define RGW_LOOKUP_FLAG_NONE 0x0000
+#define RGW_LOOKUP_FLAG_CREATE 0x0001
+
int rgw_lookup(struct rgw_fs *rgw_fs,
struct rgw_file_handle *parent_fh, const char *path,
struct rgw_file_handle **fh, uint32_t flags);
/*
open file
*/
+#define RGW_OPEN_FLAG_NONE 0x0000
+#define RGW_OPEN_FLAG_CREATE 0x0001
+
int rgw_open(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh,
uint32_t flags);
RGWStatObjRequest::FLAG_NONE);
int rc = librgw.get_fe()->execute_req(&req);
- if ((rc != 0) ||
- (req.get_ret() != 0))
+ if (((rc != 0) ||
+ (req.get_ret() != 0)) &&
+ (! (flags & RGW_LOOKUP_FLAG_CREATE)))
return ENOENT;
rgw_fh = fs->lookup_fh(parent, path);
TEST(LibRGW, LOOKUP_OBJECT) {
if (do_get || do_put || do_bulk || do_readv || do_writev) {
int ret = rgw_lookup(fs, bucket_fh, object_name.c_str(), &object_fh,
- 0 /* flags */);
+ RGW_LOOKUP_FLAG_CREATE);
ASSERT_EQ(ret, 0);
}
}