#include <errno.h>
#include <sstream>
+#include <string>
#include <string.h>
#define dout_subsys ceph_subsys_rgw
+using std::string;
+
int librgw_create(librgw_t* rgw, const char* const id)
{
CephInitParameters iparams(CEPH_ENTITY_TYPE_CLIENT);
return -1;
}
-uint64_t RGWLib::get_new_handle(const string& uri)
+uint64_t RGWLib::get_handle(const string& uri)
{
ceph::unordered_map<string, uint64_t>::iterator i =
allocated_objects_handles.find(uri);
return last_allocated_handle.read();
}
+int RGWLib::check_handle(uint64_t handle)
+{
+ ceph::unordered_map<uint64_t, string>::const_iterator i =
+ handles_map.find(handle);
+ return (i != handles_map.end());
+}
+
int RGWLibIO::set_uid(RGWRados *store, const rgw_user& uid)
{
int ret = rgw_get_user_info_by_uid(store, uid, user_info, NULL);
env.set("SERVER_PORT", port_buf);
}
-int RGWLibIO::send_status(int status, const char *status_name)
-{
- return 0;
-}
-
-int RGWLibIO::send_100_continue()
-{
- return 0;
-}
-
-int RGWLibIO::complete_header()
-{
- return 0;
-}
-
-int RGWLibIO::send_content_length(uint64_t len)
-{
- return 0;
-}
-
-int RGWLib::get_userinfo_by_uid(const string& uid, RGWUserInfo& info)
-{
- atomic_t failed;
- fe->gen_request("GET", uid, 4096, true, &failed);
- return failed.read();
-}
-
-int RGWLib::get_user_acl()
-{
- return 0;
-}
-
-int RGWLib::set_user_permissions()
-{
- return 0;
-}
-
-int RGWLib::set_user_quota()
-{
- return 0;
-}
-
-int RGWLib::get_user_quota()
-{
- return 0;
-}
-
-int RGWLib::get_user_buckets_list()
-{
- /* need to authanitcate first */
- atomic_t failed;
- fe->gen_request("GET", "", 4096, false, &failed);
- return failed.read();
-
-}
-
-int RGWLib::get_bucket_objects_list()
-{
- return 0;
-}
-
-int RGWLib::create_bucket()
-{
- return 0;
-}
-
-int RGWLib::delete_bucket()
-{
- return 0;
-}
-
-int RGWLib::get_bucket_attributes()
-{
- return 0;
-}
-
-int RGWLib::set_bucket_attributes()
-{
- return 0;
-}
-
-int RGWLib::create_object()
-{
- return 0;
-}
-
-int RGWLib::delete_object()
-{
- return 0;
-}
-
-int RGWLib::write()
-{
- return 0;
-}
-
-int RGWLib::read()
-{
- return 0;
-}
-
-int RGWLib::get_object_attributes()
-{
- return 0;
-}
-
-int RGWLib::set_object_attributes()
-{
- return 0;
-}
-
/* global RGW library object */
static RGWLib rgwlib;
#include "rgw_common.h"
-void rgw_create_s3_canonical_header(const char *method, const char *content_md5, const char *content_type, const char *date,
- map<string, string>& meta_map, const char *request_uri, map<string, string>& sub_resources,
- string& dest_str);
-bool rgw_create_s3_canonical_header(req_info& info, utime_t *header_time, string& dest, bool qsr);
-int rgw_get_s3_header_digest(const string& auth_hdr, const string& key, string& dest);
-
-
+void rgw_create_s3_canonical_header(const char *method,
+ const char *content_md5,
+ const char *content_type, const char *date,
+ map<string, string>& meta_map,
+ const char *request_uri,
+ map<string, string>& sub_resources,
+ string& dest_str);
+bool rgw_create_s3_canonical_header(req_info& info, utime_t *header_time,
+ string& dest, bool qsr);
+int rgw_get_s3_header_digest(const string& auth_hdr, const string& key,
+ string& dest);
#endif
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
-#include "rgw_file.h"
-extern RGWLib librgw;
+#include "include/rados/rgw_file.h"
+#include "include/rados/librgw.h"
+
+#include "rgw_lib.h"
+#include "rgw_rados.h"
+#include "rgw_resolve.h"
+#include "rgw_op.h"
+#include "rgw_rest.h"
+#include "rgw_frontend.h"
+#include "rgw_request.h"
+#include "rgw_process.h"
+#include "rgw_rest_user.h"
+#include "rgw_rest_s3.h"
+#include "rgw_rest_lib.h"
+#include "rgw_auth_s3.h"
+#include "rgw_lib.h"
+extern RGWLib librgw;
+
bool is_root(const string& uri)
{
- return uri.equals("");
+ return (uri == "");
}
bool is_bucket(const string& uri)
{
- int pos = req.find('/');
+ /* XXX */
+ int pos = uri.find('/');
return (pos < 0);
}
/*
- get generate nfs_handle
+ get generate rgw_file_handle
*/
-int rgw_get_handle(const char* uri, struct nfs_handle* handle)
+int rgw_get_handle(const char* uri, struct rgw_file_handle* handle)
{
handle->handle = librgw.get_handle(uri);
return 0;
}
/*
- check nfs_handle
+ check rgw_file_handle
*/
-int rgw_check_handle(const struct nfs_handle* handle)
+int rgw_check_handle(const struct rgw_file_handle* handle)
{
- return librgw.check_handle(handle);
+ return librgw.check_handle(handle->handle);
}
-int rgw_mount(const char* uid, const char* key, const char* secret,
- const struct nfs_handle* handle)
+int rgw_mount(const char* uid, const char* key, const char* _secret,
+ struct rgw_file_handle* handle)
{
int rc;
- string uri = uid + "\";
+ string uri(uid);
+ uri += "\\";
+ string secret(_secret);
string auth_hdr;
map<string, string> meta_map;
map<string, string> sub_resources;
- rgw_create_s3_canonical_header('GET',
- NULL, /* const char *content_md5 */
- 'text/html',
- "",
- meta_map,
- urti.c_str(),
- sub_resources,
- auth_hdr);
+ rgw_create_s3_canonical_header("GET",
+ NULL, /* const char *content_md5 */
+ "text/html",
+ "",
+ meta_map,
+ uri.c_str(),
+ sub_resources,
+ auth_hdr);
/* check key */
rc = rgw_get_s3_header_digest(auth_hdr, key, secret);
return rc;
}
- return rgw_get_handle(uri);
+ return rgw_get_handle(uri.c_str(), handle);
}
/*
create a new dirctory
*/
-int rgw_create_directory(const struct nfs_handle* parent_handle,
-const char* name)
+int rgw_create_directory(const struct rgw_file_handle* parent_handle,
+ const char* name)
{
return 0;
}
/*
create a new file
*/
-int rgw_create_file(const struct nfs_handle* parent_handle, const char* name)
+int rgw_create_file(const struct rgw_file_handle* parent_handle,
+ const char* name)
{
return 0;
}
-int rgw_rename(const struct nfs_handle* parent_handle, const char* old_name,
-const char* new_name)
+int rgw_rename(const struct rgw_file_handle* parent_handle,
+ const char* old_name,
+ const char* new_name)
{
return 0;
}
/*
remove file or directory
*/
-int rgw_unlink(const struct nfs_handle* parent_handle, const char* path)
+int rgw_unlink(const struct rgw_file_handle* parent_handle, const char* path)
{
return 0;
}
/*
lookup a directory or file
*/
-int rgw_lookup(const struct nfs_handle* parent_handle, const struct nfs_handle*
- parent_handle, const char* path, uint64_t* handle)
+int rgw_lookup(const struct rgw_file_handle *parent_handle, const char* path,
+ struct rgw_file_handle *handle)
{
string uri;
int rc;
- rc = get_uri(parent_handle, uri);
+ rc = librgw.get_uri(parent_handle->handle, uri);
if (rc < 0 ) { /* invalid parent */
return rc;
}
+ #warning get_bucket and ?get_object? unimplemented
+ /* TODO: implement */
if (is_root(uri)) {
- librgw.get_bucket(uri);
- } else if (is_bucket(uri)) {
+ //librgw.get_bucket(uri);
+ } else if (0 /* is_bucket(uri) */) {
/* get the object */
} else { /* parent cannot be an object */
return -1;
}
- uri += "/" + path;
+ uri += "/";
+ uri += path;
+
/* find or create an handle for the object or bucket */
- *handle = librgw.get_new_handle(uri);
+ handle->handle = librgw.get_handle(uri);
return 0;
}
/*
read directory content
*/
-int rgw_readdir(const struct nfs_handle* parent_handle, const char* path)
+int rgw_readdir(const struct rgw_file_handle* parent_handle, const char* path)
{
string uri;
int rc;
- rc = get_uri(parent_handle, uri);
+ rc = librgw.get_uri(parent_handle->handle, uri);
if (rc < 0 ) { /* invalid parent */
return rc;
}
- if (librgw.is_root(uri)) {
+ if (is_root(uri)) {
/* get the bucket list */
return librgw.get_user_buckets_list();
- } else if (librgw.is_bucket(uri)) {
+ } else if (is_bucket(uri)) {
/* get the object list */
- return librgw.get_buckets_object_list();
+ return librgw.get_bucket_objects_list();
} else { /* parent cannot be an object */
return -1;
}