[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 1/2] Use '-' to read from stdin



Modify virFileReadAll to open stdin when '-' is given as the filename.

Signed-off-by: Michael Williams <mspacex gmail com>
---
 src/util/util.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/util/util.c b/src/util/util.c
index df4dfac..554d68e 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -443,7 +443,13 @@ virFileReadLimFD(int fd, int maxlen, char **buf)
  int virFileReadAll(const char *path, int maxlen, char **buf)
 {
-    int fd = open(path, O_RDONLY);
+    int fd;
+
+    if (strcmp(path,"-") == 0)
+    	fd = fileno(stdin);
+    else
+        fd = open(path, O_RDONLY);
+
     if (fd < 0) {
         virReportSystemError(errno, _("Failed to open file '%s'"), path);
         return -1;
-- 
1.7.3.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]