]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: compile and implement more of rgw_file
authorMatt Benjamin <mbenjamin@redhat.com>
Sun, 30 Aug 2015 20:28:48 +0000 (16:28 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 16:56:01 +0000 (11:56 -0500)
The rgw_file body wasn't being built, so had some impossible
constructs.  More had been added by the commit which renamed
struct nfs_handle to struct rgw_file_handle.

Several key RGWLib methods hadn't been implemented (in progress).

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/CMakeLists.txt
src/include/rados/librgw.h
src/include/rados/rgw_file.h
src/rgw/librgw.cc
src/rgw/rgw_auth_s3.h
src/rgw/rgw_file.cc
src/rgw/rgw_lib.h

index 89868d54341cec4a84e029f2b64e7571218b6dbc..ca93a960285aea7c48b8606aa5709fdaee017802 100644 (file)
@@ -1171,6 +1171,7 @@ if(${WITH_RADOSGW})
     rgw/rgw_process.cc
     rgw/rgw_frontend.cc
     rgw/rgw_rest_lib.cc
+    rgw/rgw_file.cc
     rgw/rgw_object_expirer_core.cc
     rgw/rgw_website.cc
     rgw/rgw_xml_enc.cc
index c8c03f86be81f2d9e5883719f02f6c397624e4ba..bdf197374e49d853260abd841a3d023b88fca3f4 100644 (file)
@@ -27,33 +27,9 @@ int librgw_acl_xml2bin(librgw_t rgw, const char *xml, char** bin,
 void librgw_free_bin(librgw_t rgw, char* bin);
 void librgw_shutdown(librgw_t rgw);
 
-/* librgw external interface */
 int librgw_init();
 int librgw_stop();
 
-/* User interface */
-int get_userinfo_by_uid(const string& uid);
-int get_user_acl();
-int set_user_permissions();
-int set_user_quota();
-int get_user_quota();
-
-/* buckets */
-int get_user_buckets_list();
-int get_bucket_objects_list();
-int create_bucket();
-int delete_bucket();
-int get_bucket_attributes();
-int set_bucket_attributes();
-
-/* objects */
-int create_object ();
-int delete_object();
-int rgw_write();
-int rgw_read();
-int get_object_attributes();
-int set_object_attributes();
-
 #ifdef __cplusplus
 }
 #endif
index 997942dd089dcfdd1a7fbe6aad2af8e895906f69..93fd0196e3fae5496ae3dfc93cb971e8276d1260 100644 (file)
@@ -14,6 +14,8 @@
 #ifndef RGW_FILE_H
 #define RGW_FILE_H
 
+#include <stdint.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -43,7 +45,7 @@ int rgw_check_handle(const struct rgw_file_handle *handle);
  attach rgw namespace
 */
 int rgw_mount(const char *uid, const char *key, const char *secret,
-             const struct rgw_file_handle *handle);
+             struct rgw_file_handle *handle);
 
 /*
   create a new dirctory
@@ -57,7 +59,6 @@ int rgw_create_directory(const struct rgw_file_handle *parent_handle,
 int rgw_create_file(const struct rgw_file_handle *parent_handle,
                    const char* name);
 
-
 /*
   move/rename a new file
 */
@@ -73,7 +74,7 @@ int rgw_unlink(const struct rgw_file_handle *parent_handle, const char* path);
   lookup a directory or file
 */
 int rgw_lookup(const struct rgw_file_handle *parent_handle, const char *path,
-              uint64_t *handle);
+              struct rgw_file_handle *handle);
 
 /*
   read  directory content
index 124e20cb40d2dec325eee6759691ce45072ea985..41cc8510b597f2d1cbdf7ee74b3c53bc0763919a 100644 (file)
 
 #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);
@@ -420,7 +423,7 @@ int RGWLib::get_uri(const uint64_t handle, string& uri)
   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);
@@ -434,6 +437,13 @@ uint64_t RGWLib::get_new_handle(const string& 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);
@@ -494,117 +504,6 @@ void RGWLibIO::init_env(CephContext* cct)
   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;
 
index 3a7da098c6a64d733fc5559c2c39fed5342f6292..840b2697a353f33bfa0136ecfc64b68a239eb167 100644 (file)
@@ -7,12 +7,16 @@
 
 #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
index 9f9259f69b5e542c06bce29ccfdd8a2e2cbabef4..c9155b453884aaa1688723d368cb68f66be798cf 100644 (file)
@@ -1,55 +1,74 @@
 // -*- 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);
@@ -57,14 +76,14 @@ int rgw_mount(const char* uid, const char* key, const char* 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;
 }
@@ -72,20 +91,22 @@ const char* name)
 /*
   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;
 }
@@ -93,50 +114,54 @@ int rgw_unlink(const struct nfs_handle* parent_handle, const char* path)
 /*
   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;
   }
index f43f782a8953125a35ac878d07162e129f1a653f..e53a086df2440d957567e80e1d27ce70e9250665 100644 (file)
@@ -37,7 +37,9 @@ public:
 
   /* generate dynamic handle currently unique per librgw object
    */
-  uint64_t get_new_handle(const string& url);
+  uint64_t get_handle(const string& url);
+
+  int check_handle(uint64_t handle);
 
   int get_uri(const uint64_t handle, string &uri);