]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: fix leading-slash special case, again
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 12 Jan 2016 23:21:56 +0000 (18:21 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:07:59 +0000 (12:07 -0500)
Fix boilerplate to sanitize relative_object_name() in rgw_create
as well as the RGWStatObjRequest case of RGWLibFS::stat_leaf.
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.cc
src/test/librgw_file.cc

index 86c57f418a832a7f62c4cafd5a276d8add7e8cdd..07962edafe4e5e420b84893892d3c26321e25eaf 100644 (file)
@@ -91,7 +91,8 @@ namespace rgw {
       case 0:
       {
        std::string obj_name{parent->relative_object_name()};
-       if (obj_name.back() != '/')
+       if ((obj_name.length() > 0) &&
+           (obj_name.back() != '/'))
          obj_name += "/";
        obj_name += path;
        RGWStatObjRequest req(cct, get_user(),
@@ -692,7 +693,11 @@ int rgw_create(struct rgw_fs *rgw_fs,
     return -EEXIST;
   } else {
     /* expand and check name */
-    std::string obj_name{parent->relative_object_name() + "/" + name};
+    std::string obj_name{parent->relative_object_name()};
+    if ((obj_name.size() > 0) &&
+       (obj_name.back() != '/'))
+      obj_name += "/";
+    obj_name += name;
     if (! valid_s3_object_name(obj_name)) {
       return -EINVAL;
     } else {
@@ -858,37 +863,6 @@ int rgw_unlink(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh,
   return -rc;
 }
 
-void dump_buckets(void) {
-  /* get the bucket list */
-  string marker; // XXX need to match offset
-  string end_marker;
-  uint64_t bucket_count, bucket_objcount;
-
-  RGWUserBuckets buckets;
-  uint64_t max_buckets = g_ceph_context->_conf->rgw_list_buckets_max_chunk;
-  bool is_truncated;
-
-  RGWRados* store = rgwlib.get_store();
-
-  /* XXX check offsets */
-  uint64_t ix = 3;
-  rgw_user uid("testuser");
-  int rc = rgw_read_user_buckets(store, uid, buckets, marker, end_marker,
-                                max_buckets, true, &is_truncated);
-  if (rc == 0) {
-    bucket_count = 0;
-    bucket_objcount = 0;
-    map<string, RGWBucketEnt>& m = buckets.get_buckets();
-    for (auto& ib : m) {
-      RGWBucketEnt& bent = ib.second;
-      bucket_objcount += bent.count;
-      marker = ib.first;
-      std::cout << bent.bucket.name.c_str() << " ix: " << ix++ << std::endl;
-    }
-    bucket_count += m.size();
-  }
-} /* dump_buckets */
-
 /*
   lookup object by name (POSIX style)
 */
index ed1360940725959694ce97cae4da9323a5e11d54..5ed0cb4077f3c55ce6ab931df903364b3a4868b3 100644 (file)
@@ -72,14 +72,6 @@ TEST(LibRGW, GETATTR_ROOT) {
   }
 }
 
-extern "C" {
-extern void dump_buckets(void);
-}
-
-TEST(LibRGW, DUMP_BUCKETS) {
-  dump_buckets();
-}
-
 extern "C" {
   static bool r1_cb(const char* name, void *arg, uint64_t offset) {
     // don't need arg--it would point to fids1