]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_filestore_dump: Add utility function get_fd_data()
authorDavid Zafman <david.zafman@inktank.com>
Sat, 7 Jun 2014 00:05:53 +0000 (17:05 -0700)
committerDavid Zafman <dzafman@redhat.com>
Tue, 3 Mar 2015 17:51:30 +0000 (09:51 -0800)
Signed-off-by: David Zafman <david.zafman@inktank.com>
(cherry picked from commit d4a9dafe442f139562497d746f80ba49faa954e8)

src/tools/ceph_filestore_dump.cc

index cabd55890f3be75385b77ad224922d7de60f05d8..154b1b6d43b4be9e7ad23be36043c6aac1b7bdd8 100644 (file)
@@ -386,6 +386,26 @@ int write_simple(sectiontype_t type, int fd)
   return hbl.write_fd(fd);
 }
 
+static int get_fd_data(int fd, bufferlist &bl)
+{
+  uint64_t total = 0;
+  do {
+    ssize_t bytes = bl.read_fd(fd, max_read);
+    if (bytes < 0) {
+      cerr << "read_fd error " << cpp_strerror(-bytes) << std::endl;
+      return 1;
+    }
+
+    if (bytes == 0)
+      break;
+
+    total += bytes;
+  } while(true);
+
+  assert(bl.length() == total);
+  return 0;
+}
+
 static void invalid_path(string &path)
 {
   cerr << "Invalid path to osd store specified: " << path << "\n";