]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmonctl: -o -
authorSage Weil <sage@newdream.net>
Tue, 20 May 2008 04:28:07 +0000 (21:28 -0700)
committerSage Weil <sage@newdream.net>
Tue, 20 May 2008 04:28:07 +0000 (21:28 -0700)
src/cmonctl.cc

index 28958c2c0f740a2e19142930ba4673a30ca17b5d..b3af5b9cb959bce6b88f7196e571fdb2926ec991 100644 (file)
@@ -48,10 +48,14 @@ void handle_ack(MMonCommandAck *ack)
   int len = ack->get_data().length();
   if (len) {
     if (outfile) {
-      int fd = ::open(outfile, O_WRONLY|O_TRUNC|O_CREAT);
-      ::write(fd, ack->get_data().c_str(), len);
-      ::fchmod(fd, 0777);
-      ::close(fd);
+      if (strcmp(outfile, "-") == 0) {
+       ::write(0, ack->get_data().c_str(), len);
+      } else {
+       int fd = ::open(outfile, O_WRONLY|O_TRUNC|O_CREAT);
+       ::write(fd, ack->get_data().c_str(), len);
+       ::fchmod(fd, 0777);
+       ::close(fd);
+      }
       generic_dout(0) << "wrote " << len << " byte payload to " << outfile << dendl;
     } else {
       generic_dout(0) << "got " << len << " byte payload, discarding (specify -o <outfile)" << dendl;