kconfig: create files in target directory if requested

Otherwise rename() fails when used across filesystem
boundaries.

Change-Id: I22a62310f0e46ac9cfee50b7e9eeed93536ed409
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: http://review.coreboot.org/7504
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Tested-by: build bot (Jenkins)
This commit is contained in:
Patrick Georgi 2014-11-17 14:56:49 +01:00 committed by Patrick Georgi
parent 2dc01324f5
commit 129462da1b
1 changed files with 21 additions and 3 deletions

View File

@ -980,14 +980,26 @@ int conf_write_autoconf(void)
if (conf_split_config()) if (conf_split_config())
return 1; return 1;
char *tmpconfig_name = strdup(".tmpconfig.XXXXXX"); char *tmpconfig_name = malloc(PATH_MAX);
if (getenv("COREBOOT_BUILD_DIR")) {
sprintf(tmpconfig_name, "%s/.tmpconfig.XXXXXX",
getenv("COREBOOT_BUILD_DIR"));
} else {
tmpconfig_name = strdup(".tmpconfig.XXXXXX");
}
if ((i = mkstemp(tmpconfig_name)) == -1) if ((i = mkstemp(tmpconfig_name)) == -1)
return 1; return 1;
out = fdopen(i, "w"); out = fdopen(i, "w");
if (!out) if (!out)
return 1; return 1;
char *tmpconfig_triname = strdup(".tmpconfig_tristate.XXXXXX"); char *tmpconfig_triname = malloc(PATH_MAX);
if (getenv("COREBOOT_BUILD_DIR")) {
sprintf(tmpconfig_triname, "%s/.tmpconfig_tristate.XXXXXX",
getenv("COREBOOT_BUILD_DIR"));
} else {
tmpconfig_triname = strdup(".tmpconfig_tristate.XXXXXX");
}
if ((i = mkstemp(tmpconfig_triname)) == -1) if ((i = mkstemp(tmpconfig_triname)) == -1)
return 1; return 1;
tristate = fdopen(i, "w"); tristate = fdopen(i, "w");
@ -996,7 +1008,13 @@ int conf_write_autoconf(void)
return 1; return 1;
} }
char *tmpconfig_h = strdup(".tmpconfig_tristate.XXXXXX"); char *tmpconfig_h = malloc(PATH_MAX);
if (getenv("COREBOOT_BUILD_DIR")) {
sprintf(tmpconfig_h, "%s/.tmpconfig_tristate.XXXXXX",
getenv("COREBOOT_BUILD_DIR"));
} else {
tmpconfig_h = strdup(".tmpconfig_tristate.XXXXXX");
}
if ((i = mkstemp(tmpconfig_h)) == -1) if ((i = mkstemp(tmpconfig_h)) == -1)
return 1; return 1;
out_h = fdopen(i, "w"); out_h = fdopen(i, "w");