From: David Zafman Date: Thu, 22 Jan 2015 21:02:39 +0000 (-0800) Subject: ceph-dencoder: Add ability to import from stdin by specifying "-" X-Git-Tag: v9.0.2~168^2~45 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fb42407e5fa6757856e6b48e728977c4d2837397;p=ceph.git ceph-dencoder: Add ability to import from stdin by specifying "-" Signed-off-by: David Zafman --- diff --git a/src/test/encoding/ceph_dencoder.cc b/src/test/encoding/ceph_dencoder.cc index 6de0c2b150f0..077c770511a7 100644 --- a/src/test/encoding/ceph_dencoder.cc +++ b/src/test/encoding/ceph_dencoder.cc @@ -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);