[coreboot] [PATCH] Avoid cross-device renames in build_opt_tbl

aaron lwe aaron.lwe at gmail.com
Thu Dec 4 04:41:35 CET 2008


> That's due to the rename being performed in build_opt_tbl. Renames can't
> be done across filesystems. I saw that problem in the original patch,
> but I didn't want to ruin the mood by complaining.

I see compiling errors more important than the mood.

>
> Anyway, here is a patch to fix it.
>
> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
>
> Index: LinuxBIOSv2-build_opt_tbl/util/options/build_opt_tbl.c
> ===================================================================
> --- LinuxBIOSv2-build_opt_tbl/util/options/build_opt_tbl.c      (Revision 3788)
> +++ LinuxBIOSv2-build_opt_tbl/util/options/build_opt_tbl.c      (Arbeitskopie)
> @@ -11,7 +11,7 @@
>  #define INPUT_LINE_MAX 256
>  #define MAX_VALUE_BYTE_LENGTH 64
>
> -#define TMPFILE_TEMPLATE "/tmp/build_opt_tbl_XXXXXX"
> +#define TMPFILE_TEMPLATE ".XXXXXX"
>
>  static unsigned char cmos_table[4096];
>
> @@ -215,7 +215,7 @@
>        char *header=0;
>        FILE *fp;
>        int tmpfile;
> -       char tmpfilename[32];
> +       char *tmpfilename;
>        struct cmos_option_table *ct;
>        struct cmos_entries *ce;
>        struct cmos_enums *c_enums, *c_enums_start;
> @@ -485,7 +485,9 @@
>
>        /* See if we want to output a C source file */
>        if(option) {
> -               strcpy(tmpfilename, TMPFILE_TEMPLATE);
> +               tmpfilename = malloc(strlen(option) + strlen(TMPFILE_TEMPLATE) + 1);
> +               strcpy(tmpfilename, option);
> +               strcat(tmpfilename, TMPFILE_TEMPLATE);
>                tmpfile = mkstemp(tmpfilename);
>                if(tmpfile == -1) {
>                         perror("Error - Could not create temporary file");
> @@ -535,7 +537,9 @@
>                struct cmos_option_table *hdr;
>                struct lb_record *ptr, *end;
>
> -               strcpy(tmpfilename, TMPFILE_TEMPLATE);
> +               tmpfilename = malloc(strlen(header) + strlen(TMPFILE_TEMPLATE) + 1);
> +               strcpy(tmpfilename, header);
> +               strcat(tmpfilename, TMPFILE_TEMPLATE);
>                tmpfile = mkstemp(tmpfilename);
>                if(tmpfile == -1) {
>                        perror("Error - Could not create temporary file");
>
>

The patch works well for me and is much better than the statically
allocated method which will probablly cause other people complain due
to their very long path name.

Acked-by: Aaron Lwe <aaron.lwe at gmail.com>




More information about the coreboot mailing list