summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli_classic.c8
-rw-r--r--flashrom.c8
2 files changed, 11 insertions, 5 deletions
diff --git a/cli_classic.c b/cli_classic.c
index a22d642d4..7d4dee053 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -48,8 +48,10 @@ static void cli_classic_usage(const char *name)
printf(" -h | --help print this help text\n"
" -R | --version print version (release)\n"
" -r | --read <file> read flash and save to <file>\n"
- " -w | --write <file> write <file> to flash\n"
- " -v | --verify <file> verify flash against <file>\n"
+ " -w | --write <file|-> write <file> or the content provided\n"
+ " on the standard input to flash\n"
+ " -v | --verify <file|-> verify flash against <file>\n"
+ " or the content provided on the standard input\n"
" -E | --erase erase flash memory\n"
" -V | --verbose more verbose output\n"
" -c | --chip <chipname> probe only for specified flash chip\n"
@@ -107,7 +109,7 @@ static int check_filename(char *filename, const char *type)
return 1;
}
/* Not an error, but maybe the user intended to specify a CLI option instead of a file name. */
- if (filename[0] == '-')
+ if (filename[0] == '-' && filename[1] != '\0')
fprintf(stderr, "Warning: Supplied %s file name starts with -\n", type);
return 0;
}
diff --git a/flashrom.c b/flashrom.c
index 3a733df67..e1121d86e 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1348,7 +1348,11 @@ int read_buf_from_file(unsigned char *buf, unsigned long size,
int ret = 0;
FILE *image;
- if ((image = fopen(filename, "rb")) == NULL) {
+ if (!strcmp(filename, "-"))
+ image = fdopen(fileno(stdin), "rb");
+ else
+ image = fopen(filename, "rb");
+ if (image == NULL) {
msg_gerr("Error: opening file \"%s\" failed: %s\n", filename, strerror(errno));
return 1;
}
@@ -1359,7 +1363,7 @@ int read_buf_from_file(unsigned char *buf, unsigned long size,
ret = 1;
goto out;
}
- if (image_stat.st_size != (intmax_t)size) {
+ if ((image_stat.st_size != (intmax_t)size) && strcmp(filename, "-")) {
msg_gerr("Error: Image size (%jd B) doesn't match the expected size (%lu B)!\n",
(intmax_t)image_stat.st_size, size);
ret = 1;