]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-dencoder: Add ability to import from stdin by specifying "-"
authorDavid Zafman <dzafman@redhat.com>
Thu, 22 Jan 2015 21:02:39 +0000 (13:02 -0800)
committerDavid Zafman <dzafman@redhat.com>
Wed, 13 May 2015 20:09:11 +0000 (13:09 -0700)
Signed-off-by: David Zafman <dzafman@redhat.com>
src/test/encoding/ceph_dencoder.cc

index 6de0c2b150f0f6be0d2537550ef16aa337cc8a4f..077c770511a7923f1cf23956a70897ea95376548 100644 (file)
@@ -23,6 +23,8 @@
 #undef TYPE_NOCOPY
 #undef MESSAGE
 
+#define MB(m) ((m) * 1024 * 1024)
+
 void usage(ostream &out)
 {
   out << "usage: ceph-dencoder [commands ...]" << std::endl;
@@ -358,7 +360,14 @@ int main(int argc, const char **argv)
        usage(cerr);
        exit(1);
       }
-      int r = encbl.read_file(*i, &err);
+      int r;
+      if (*i == string("-")) {
+        *i = "stdin";
+       // Read up to 1mb if stdin specified
+       r = encbl.read_fd(STDIN_FILENO, MB(1));
+      } else {
+       r = encbl.read_file(*i, &err);
+      }
       if (r < 0) {
         cerr << "error reading " << *i << ": " << err << std::endl;
         exit(1);