From: Joao Eduardo Luis Date: Thu, 5 Dec 2013 12:08:35 +0000 (+0000) Subject: tools: ceph-kvstore-tool: output value contents to file on 'get' X-Git-Tag: v0.73~2^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c98c1043e3be40a632bec4c85fc1a4ab9f00d8a5;p=ceph.git tools: ceph-kvstore-tool: output value contents to file on 'get' Signed-off-by: Joao Eduardo Luis --- diff --git a/src/tools/ceph-kvstore-tool.cc b/src/tools/ceph-kvstore-tool.cc index e07391d5c51..76f68294cbe 100644 --- a/src/tools/ceph-kvstore-tool.cc +++ b/src/tools/ceph-kvstore-tool.cc @@ -214,7 +214,7 @@ void usage(const char *pname) << " list [prefix]\n" << " list-crc [prefix]\n" << " exists [key]\n" - << " get \n" + << " get [out ]\n" << " crc \n" << " get-size\n" << " set [ver |in ]\n" @@ -286,9 +286,33 @@ int main(int argc, const char *argv[]) return 1; } std::cout << std::endl; - ostringstream os; - bl.hexdump(os); - std::cout << os.str() << std::endl; + + if (argc >= 6) { + string subcmd(argv[5]); + string out(argv[6]); + + if (subcmd != "out") { + std::cerr << "unrecognized subcmd '" << subcmd << "'" + << std::endl; + return 1; + } + + if (out.empty()) { + std::cerr << "unspecified out file" << std::endl; + return 1; + } + + int err = bl.write_file(argv[6], 0644); + if (err < 0) { + std::cerr << "error writing value to '" << out << "': " + << cpp_strerror(err) << std::endl; + return 1; + } + } else { + ostringstream os; + bl.hexdump(os); + std::cout << os.str() << std::endl; + } } else if (cmd == "crc") { if (argc < 5) {