]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: Move cleanbin() function to common/util.cc
authorDavid Zafman <dzafman@redhat.com>
Tue, 30 Aug 2016 18:05:16 +0000 (11:05 -0700)
committerDavid Zafman <dzafman@redhat.com>
Tue, 8 Nov 2016 23:16:52 +0000 (15:16 -0800)
Signed-off-by: David Zafman <dzafman@redhat.com>
src/common/util.cc
src/include/util.h
src/tools/CMakeLists.txt
src/tools/ceph_objectstore_tool.cc

index ec3881afad89598879a61810586cf7a72393aad5..5ab1e441a30b6fd7411b9f21bc47f68aeb173f91 100644 (file)
@@ -267,3 +267,26 @@ void dump_services(Formatter* f, const map<string, list<int> >& services, const
   }
   f->close_section();
 }
+
+// Convert non-printable characters to '\###'
+void cleanbin(string &str)
+{
+  bool cleaned = false;
+  string clean;
+
+  for (string::iterator it = str.begin(); it != str.end(); ++it) {
+    if (!isprint(*it)) {
+      clean.push_back('\\');
+      clean.push_back('0' + ((*it >> 6) & 7));
+      clean.push_back('0' + ((*it >> 3) & 7));
+      clean.push_back('0' + (*it & 7));
+      cleaned = true;
+    } else {
+      clean.push_back(*it);
+    }
+  }
+
+  if (cleaned)
+    str = clean;
+  return;
+}
index 30c2e30895dabe8a509ce3cadb92355c5ba76fc1..6a85f1b894a17fe45560797376308cf63f972df1 100644 (file)
@@ -82,4 +82,5 @@ void collect_sys_info(map<string, string> *m, CephContext *cct);
 /// @param type the service type of given @p services, for example @p osd or @p mon.
 void dump_services(Formatter* f, const map<string, list<int> >& services, const char* type);
 
+void cleanbin(string &str);
 #endif /* CEPH_UTIL_H */
index 9478ee2272465bc4353eea680a3dd71724562aca..0d53ca6cd645e0fdc9b6cd1d0c1bd76488f0a0c3 100644 (file)
@@ -3,6 +3,7 @@ set(rados_srcs
   RadosDump.cc
   rados/RadosImport.cc
   rados/PoolDump.cc
+  ${PROJECT_SOURCE_DIR}/src/common/util.cc
   ${PROJECT_SOURCE_DIR}/src/common/obj_bencher.cc)
 add_executable(rados ${rados_srcs})
 target_link_libraries(rados librados global ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} radosstriper)
index ab1ae81dc808bdf4465bf208b0e47f2e60fee235..b120fadc5960c372b53c0d0f4c066bf46039ff8c 100644 (file)
@@ -42,6 +42,7 @@
 #include "rebuild_mondb.h"
 #include "ceph_objectstore_tool.h"
 #include "include/compat.h"
+#include "include/util.h"
 
 namespace po = boost::program_options;
 using namespace std;
@@ -298,29 +299,6 @@ bool debug = false;
 super_header sh;
 uint64_t testalign;
 
-// Convert non-printable characters to '\###'
-static void cleanbin(string &str)
-{
-  bool cleaned = false;
-  string clean;
-
-  for (string::iterator it = str.begin(); it != str.end(); ++it) {
-    if (!isprint(*it)) {
-      clean.push_back('\\');
-      clean.push_back('0' + ((*it >> 6) & 7));
-      clean.push_back('0' + ((*it >> 3) & 7));
-      clean.push_back('0' + (*it & 7));
-      cleaned = true;
-    } else {
-      clean.push_back(*it);
-    }
-  }
-
-  if (cleaned)
-    str = clean;
-  return;
-}
-
 static int get_fd_data(int fd, bufferlist &bl)
 {
   uint64_t total = 0;