]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw-admin: bucket list also specifies object namespace
authorYehuda Sadeh <yehuda@inktank.com>
Wed, 17 Apr 2013 00:44:46 +0000 (17:44 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 8 May 2013 18:01:17 +0000 (11:01 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_bucket.cc
src/rgw/rgw_common.h
src/rgw/rgw_json_enc.cc
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index e49dfe97729e29041f793aa6ccf5ffafef81ac66..a90200ae970404bfaa126ff50979c6cdc484c5b2 100644 (file)
@@ -1185,8 +1185,8 @@ int main(int argc, char **argv)
       do {
         list<rgw_bi_log_entry> entries;
         ret = store->list_objects(bucket, max_entries - count, prefix, delim,
-                                  marker, result, common_prefixes, true, ns,
-                                  &truncated, NULL);
+                                  marker, result, common_prefixes, true,
+                                  ns, false, &truncated, NULL);
         if (ret < 0) {
           cerr << "ERROR: store->list_objects(): " << cpp_strerror(-ret) << std::endl;
           return -ret;
index e4f158e13ada43724c7fffc6796cd29983b092d1..6348fe04d725ffc8ca240074f2dd365041821538 100644 (file)
@@ -292,7 +292,7 @@ int rgw_remove_bucket(RGWRados *store, rgw_bucket& bucket, bool delete_children)
   if (delete_children) {
     ret = store->list_objects(bucket, max, prefix, delim, marker,
             objs, common_prefixes,
-            false, ns, (bool *)false, NULL);
+            false, ns, true, NULL, NULL);
 
     if (ret < 0)
       return ret;
@@ -307,7 +307,7 @@ int rgw_remove_bucket(RGWRados *store, rgw_bucket& bucket, bool delete_children)
       objs.clear();
 
       ret = store->list_objects(bucket, max, prefix, delim, marker, objs, common_prefixes,
-                                false, ns, (bool *)false, NULL);
+                                false, ns, true, NULL, NULL);
       if (ret < 0)
         return ret;
     }
@@ -549,7 +549,8 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
   do {
     vector<RGWObjEnt> result;
     int r = store->list_objects(bucket, max, prefix, delim, marker,
-                                result, common_prefixes, false, ns,
+                                result, common_prefixes, false,
+                                ns, true,
                                 &is_truncated, NULL);
 
     if (r < 0) {
index 784a7edd9bff8fd60e90b4b05c5e657fa5cef52e..2201a7ca564a500394e30cfb09e5a1f50014ceaa 100644 (file)
@@ -660,6 +660,7 @@ struct req_state {
 /** Store basic data on an object */
 struct RGWObjEnt {
   std::string name;
+  std::string ns;
   std::string owner;
   std::string owner_display_name;
   uint64_t size;
index b376be991b3d83a72f7f0daa3cef67e905a4e681..895ef0a7eea3fa432491d7913dfa31f9d6f53e70 100644 (file)
@@ -400,6 +400,7 @@ void RGWBucketInfo::dump(Formatter *f) const
 void RGWObjEnt::dump(Formatter *f) const
 {
   encode_json("name", name, f);
+  encode_json("namespace", ns, f);
   encode_json("owner", owner, f);
   encode_json("owner_display_name", owner_display_name, f);
   encode_json("size", size, f);
index 8ddf242a8bcc8358373de2820b722314114de840..ff4f5177acf57037249a024b5a24416cfece84a6 100644 (file)
@@ -430,7 +430,7 @@ int RGWGetObj::iterate_user_manifest_parts(rgw_bucket& bucket, string& obj_prefi
 #define MAX_LIST_OBJS 100
     int r = store->list_objects(bucket, MAX_LIST_OBJS, obj_prefix, delim, marker,
                                 objs, common_prefixes,
-                                true, no_ns, &is_truncated, NULL);
+                                true, no_ns, true, &is_truncated, NULL);
     if (r < 0)
       return r;
 
@@ -804,7 +804,7 @@ void RGWListBucket::execute()
     return;
 
   ret = store->list_objects(s->bucket, max, prefix, delimiter, marker, objs, common_prefixes,
-                               !!(s->prot_flags & RGW_REST_SWIFT), no_ns, &is_truncated, NULL);
+                               !!(s->prot_flags & RGW_REST_SWIFT), no_ns, true, &is_truncated, NULL);
 }
 
 int RGWGetBucketLogging::verify_permission()
@@ -2431,7 +2431,7 @@ void RGWListBucketMultiparts::execute()
   }
   marker_meta = marker.get_meta();
   ret = store->list_objects(s->bucket, max_uploads, prefix, delimiter, marker_meta, objs, common_prefixes,
-                               !!(s->prot_flags & RGW_REST_SWIFT), mp_ns, &is_truncated, &mp_filter);
+                               !!(s->prot_flags & RGW_REST_SWIFT), mp_ns, true, &is_truncated, &mp_filter);
   if (!objs.empty()) {
     vector<RGWObjEnt>::iterator iter;
     RGWMultipartUploadEntry entry;
index 2846f0772c327c6c5aa44ef2bf9f17b20eb827e1..113977fec5c671999ddd46d79e1236b7cfca4364 100644 (file)
@@ -1151,7 +1151,8 @@ int RGWRados::decode_policy(bufferlist& bl, ACLOwner *owner)
  */
 int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string& delim,
                           string& marker, vector<RGWObjEnt>& result, map<string, bool>& common_prefixes,
-                          bool get_content_type, string& ns, bool *is_truncated, RGWAccessListFilter *filter)
+                          bool get_content_type, string& ns, bool enforce_ns,
+                           bool *is_truncated, RGWAccessListFilter *filter)
 {
   int count = 0;
   bool truncated;
@@ -1178,7 +1179,9 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
       string obj = eiter->first;
       string key = obj;
 
-      if (!rgw_obj::translate_raw_obj_to_obj_in_ns(obj, ns)) {
+      bool check_ns = rgw_obj::translate_raw_obj_to_obj_in_ns(obj, ns);
+
+      if (enforce_ns && !check_ns) {
         if (!ns.empty()) {
           /* we've iterated past the namespace we're searching -- done now */
           truncated = false;
@@ -1206,6 +1209,7 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
 
       RGWObjEnt ent = eiter->second;
       ent.name = obj;
+      ent.ns = ns;
       result.push_back(ent);
       count++;
     }
index dc10539141771a53a34a7edef987e518982090b8..664ccef36bc0bd464416169862a6fde2b0f7c427 100644 (file)
@@ -651,7 +651,7 @@ public:
    */
   virtual int list_objects(rgw_bucket& bucket, int max, std::string& prefix, std::string& delim,
                    std::string& marker, std::vector<RGWObjEnt>& result, map<string, bool>& common_prefixes,
-                  bool get_content_type, string& ns, bool *is_truncated, RGWAccessListFilter *filter);
+                  bool get_content_type, string& ns, bool enforce_ns, bool *is_truncated, RGWAccessListFilter *filter);
 
   virtual int create_pool(rgw_bucket& bucket);