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

Daniele Forsi dforsi at gmail.com
Mon Aug 25 12:32:46 CEST 2014


2014-08-21 13:37 GMT+02:00 Idwer Vollering:

> 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;

"xw" always fails if filename exists even if it's not the same used
for read or write, yes strerror() will have printed "File exists" but
having to delete the log file by hand is inconvenient (I always create
a log file "just in case" but I rarely need it)

-- 
Daniele Forsi




More information about the flashrom mailing list