From: David Zafman Date: Sat, 7 Jun 2014 00:05:53 +0000 (-0700) Subject: ceph_filestore_dump: Add utility function get_fd_data() X-Git-Tag: v0.86~180^2~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d4a9dafe442f139562497d746f80ba49faa954e8;p=ceph.git ceph_filestore_dump: Add utility function get_fd_data() Signed-off-by: David Zafman --- diff --git a/src/tools/ceph_filestore_dump.cc b/src/tools/ceph_filestore_dump.cc index dc94ec72bba6..672e2aa3c2dc 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";