[coreboot] [PATCH] Avoid cross-device renames in build_opt_tbl
Carl-Daniel Hailfinger
c-d.hailfinger.devel.2006 at gmx.net
Tue Dec 2 13:05:45 CET 2008
Aaron Lwe reported that v2 build fails if /tmp and the build directory
are on different file systems.
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.
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");
--
http://www.hailfinger.org/
More information about the coreboot
mailing list