]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: ceph-monstore-tool: raw map to stdout if outfile not specified
authorJoao Eduardo Luis <joao@redhat.com>
Mon, 29 Dec 2014 17:09:20 +0000 (17:09 +0000)
committerJoao Eduardo Luis <joao@redhat.com>
Mon, 29 Dec 2014 17:50:28 +0000 (17:50 +0000)
Signed-off-by: Joao Eduardo Luis <joao@redhat.com>
src/tools/ceph_monstore_tool.cc

index 338889614302348f0946924fe0d2b89ec348cb36..b946eac589a7480c8aafda103eb8cc3fda4daea5 100644 (file)
@@ -369,12 +369,15 @@ int main(int argc, char **argv) {
       v = st.get(map_type, "last_committed");
     }
 
-    int fd = ::open(outpath.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0666);
-    if (fd < 0) {
-      std::cerr << "error opening output file: "
-                << cpp_strerror(errno) << std::endl;
-      err = EINVAL;
-      goto done;
+    int fd = STDOUT_FILENO;
+    if (!outpath.empty()){
+      fd = ::open(outpath.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0666);
+      if (fd < 0) {
+        std::cerr << "error opening output file: "
+          << cpp_strerror(errno) << std::endl;
+        err = EINVAL;
+        goto done;
+      }
     }
 
     bufferlist bl;
@@ -391,6 +394,12 @@ int main(int argc, char **argv) {
       goto done;
     }
     bl.write_fd(fd);
+
+    if (!outpath.empty()) {
+      std::cout << "wrote " << map_type
+                << " version " << v << " to " << outpath
+                << std::endl;
+    }
   } else if (cmd == "dump-paxos") {
     unsigned dstart = 0;
     unsigned dstop = ~0;