Changeset 3789

Show
Ignore:
Timestamp:
12/02/08 13:26:17 (5 weeks ago)
Author:
stepan
Message:

build_opt_tbl:
make sure the temporary files are created in the same directory as the
target files so they can be rename()d. This fixes a compilation issue on
machines with the build directory living on another partition than /tmp.
Pretty trivial.

Signed-off-by: Stefan Reinauer <stepan@…>
Acked-by: Stefan Reinauer <stepan@…>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/coreboot-v2/util/options/build_opt_tbl.c

    r3783 r3789  
    55#include <ctype.h> 
    66#include <errno.h> 
     7#include <libgen.h> 
    78#include "../../src/include/pc80/mc146818rtc.h" 
    89#include "../../src/include/boot/coreboot_tables.h" 
     
    1213#define MAX_VALUE_BYTE_LENGTH 64 
    1314 
    14 #define TMPFILE_TEMPLATE "/tmp/build_opt_tbl_XXXXXX" 
     15#define TMPFILE_LEN 256 
     16#define TMPFILE_TEMPLATE "/build_opt_tbl_XXXXXX" 
    1517 
    1618static unsigned char cmos_table[4096]; 
     
    216218        FILE *fp; 
    217219        int tmpfile; 
    218         char tmpfilename[32]; 
     220        char tmpfilename[TMPFILE_LEN]; 
    219221        struct cmos_option_table *ct; 
    220222        struct cmos_entries *ce; 
     
    486488        /* See if we want to output a C source file */ 
    487489        if(option) { 
    488                 strcpy(tmpfilename, TMPFILE_TEMPLATE); 
     490                strncpy(tmpfilename, dirname(option), TMPFILE_LEN); 
     491                strncat(tmpfilename, TMPFILE_TEMPLATE, TMPFILE_LEN); 
    489492                tmpfile = mkstemp(tmpfilename); 
    490493                if(tmpfile == -1) { 
     
    536539                struct lb_record *ptr, *end; 
    537540 
    538                 strcpy(tmpfilename, TMPFILE_TEMPLATE); 
     541                strncpy(tmpfilename, dirname(option), TMPFILE_LEN); 
     542                strncat(tmpfilename, TMPFILE_TEMPLATE, TMPFILE_LEN); 
    539543                tmpfile = mkstemp(tmpfilename); 
    540544                if(tmpfile == -1) {