From d4a9dafe442f139562497d746f80ba49faa954e8 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Fri, 6 Jun 2014 17:05:53 -0700 Subject: [PATCH] ceph_filestore_dump: Add utility function get_fd_data() Signed-off-by: David Zafman --- src/tools/ceph_filestore_dump.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/tools/ceph_filestore_dump.cc b/src/tools/ceph_filestore_dump.cc index dc94ec72bba..672e2aa3c2d 100644 --- a/src/tools/ceph_filestore_dump.cc +++ b/src/tools/ceph_filestore_dump.cc @@ -388,6 +388,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"; -- 2.47.3