]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
libradosstriper: add function to read into char*
authorMilind Changire <mchangir@redhat.com>
Thu, 27 Jun 2019 13:35:26 +0000 (19:05 +0530)
committerPatrick Donnelly <pdonnell@redhat.com>
Mon, 22 Mar 2021 17:14:00 +0000 (10:14 -0700)
Signed-off-by: Milind Changire <mchangir@redhat.com>
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit 02f5543c8df9e2a175ce5d9a96773b641e212c1c)

src/include/radosstriper/libradosstriper.hpp
src/libradosstriper/libradosstriper.cc

index fb790b0d7ef15343041af9d9175c30e8f9a6ac3a..064c7d2c3d84a4b8d254c42bf8df7dc593377d37 100644 (file)
@@ -168,6 +168,7 @@ namespace libradosstriper
      * synchronously read from the striped object at the specified offset.
      */
     int read(const std::string& soid, ceph::bufferlist* pbl, size_t len, uint64_t off);
+    int read(const std::string& soid, char *buf, size_t len, uint64_t off);
 
     /**
      * asynchronously read from the striped object at the specified offset.
index e98dfc17935aea28bac3263a00a4a97774cce02e..7f23a380550e789a8bc291c8a82c2f1a90819fc9 100644 (file)
@@ -254,6 +254,28 @@ int libradosstriper::RadosStriper::read(const std::string& soid,
   return rados_striper_impl->read(soid, bl, len, off);
 }
 
+int libradosstriper::RadosStriper::read(const std::string& soid,
+                                       char *buf,
+                                       size_t len,
+                                       uint64_t off)
+{
+  bufferlist bl;
+  bufferptr bp = buffer::create_static(len, buf);
+
+  bl.push_back(bp);
+
+  int ret = rados_striper_impl->read(soid, &bl, len, off);
+
+  if (ret >= 0) {
+    if (bl.length() > len)
+      return -ERANGE;
+    if (!bl.is_provided_buffer(buf))
+      bl.begin().copy(bl.length(), buf);
+    ret = bl.length();    // hrm :/
+  }
+  return ret;
+}
+
 int libradosstriper::RadosStriper::aio_read(const std::string& soid,
                                            librados::AioCompletion *c,
                                            bufferlist* bl,