[flashrom] [patch] exit when the same filename is used for reading/writing flash chip content and to store log output

Idwer Vollering vidwer at gmail.com
Thu Aug 21 13:37:29 CEST 2014


Tested on physical hardware, built on FreeBSD (less portability 'headaches').

Signed-off-By: Idwer Vollering <vidwer at gmail.com>

Index: cli_output.c
===================================================================
--- cli_output.c        (revision 1846)
+++ cli_output.c        (working copy)
@@ -52,8 +52,12 @@
                msg_gerr("No logfile name specified.\n");
                return 1;
        }
-       if ((logfile = fopen(filename, "w")) == NULL) {
+       if ((logfile = fopen(filename, "xw")) == NULL) {
                msg_gerr("Error: opening log file \"%s\" failed:
%s\n", filename, strerror(errno));
+               msg_gdbg("This means that flashrom can't write log output\n" \
+                       "to the file you specified (\"%s\"),\n" \
+                       "or you are using the same filename to read
from/write to (-r / -w)\n" \
+                       "and write the log output to (-o).\n", filename);
                return 1;
        }
        return 0;




More information about the flashrom mailing list