]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tool: ceph-kvstore-tool's store-crc command did not save result to the file as expected
authorChang Liu <liuchang0812@gmail.com>
Wed, 8 Nov 2017 07:14:54 +0000 (15:14 +0800)
committerChang Liu <liuchang0812@gmail.com>
Thu, 9 Nov 2017 03:16:06 +0000 (11:16 +0800)
"store-crc <path>" command did not save result to <path>, it didn't use <path>
argument and alwayls passed a NULL to "st.traverse" function. now we will create file
<path>, pass a *ofstream to "st.traverse" function.

Fiexes: http://tracker.ceph.com/issues/22092

Signed-off-by: Chang Liu <liuchang0812@gmail.com>
src/tools/ceph_kvstore_tool.cc

index 9319b487f5d2e3448cb40c04a72478d7b6ac22e7..6bc1786409d0146534b34d3affd5d4d70242cf45 100644 (file)
@@ -13,6 +13,7 @@
 #include <map>
 #include <set>
 #include <string>
+#include <fstream>
 
 #include <boost/scoped_ptr.hpp>
 
@@ -558,8 +559,13 @@ int main(int argc, const char *argv[])
     }
 
   } else if (cmd == "store-crc") {
-    uint32_t crc = st.traverse(string(), true, NULL);
-    std::cout << "store at '" << path << "' crc " << crc << std::endl;
+    if (argc < 4) {
+      usage(argv[0]);
+      return 1;
+    }
+    std::ofstream fs(argv[4]);
+    uint32_t crc = st.traverse(string(), true, &fs);
+    std::cout << "store at '" << argv[4] << "' crc " << crc << std::endl;
 
   } else if (cmd == "compact") {
     st.compact();