[U-Boot] [PATCH 9/9] mkenvimage: Default to stdout if the output argument is absent or "-"
David Wagner
david.wagner at free-electrons.com
Wed Nov 23 21:28:18 CET 2011
Signed-off-by: David Wagner <david.wagner at free-electrons.com>
---
tools/mkenvimage.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c
index fa6eb6e..8ba63d2 100644
--- a/tools/mkenvimage.c
+++ b/tools/mkenvimage.c
@@ -261,11 +261,15 @@ int main(int argc, char **argv)
if (redundant)
*(dataptr + sizeof(targetendian_crc)) = 1;
- bin_fd = creat(bin_filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
- if (bin_fd == -1) {
- fprintf(stderr, "Can't open output file \"%s\": %s\n",
- bin_filename, strerror(errno));
- return EXIT_FAILURE;
+ if (!bin_filename || strcmp(bin_filename, "-") == 0) {
+ bin_fd = STDOUT_FILENO;
+ } else {
+ bin_fd = creat(bin_filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ if (bin_fd == -1) {
+ fprintf(stderr, "Can't open output file \"%s\": %s\n",
+ bin_filename, strerror(errno));
+ return EXIT_FAILURE;
+ }
}
if (write(bin_fd, dataptr, sizeof(*dataptr) * datasize) !=
--
1.7.7.3
More information about the U-Boot
mailing list