diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2017-02-01 22:30:40 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-07-14 15:14:37 +0100 |
commit | 02958a6ee4050f75188df371a4118efb89685c8c (patch) | |
tree | 8717eb3d2abeb4c088ecf7ca9e9abb37b34d861d | |
parent | c56f1e06c4c470a023b02c7019112eb852f08d44 (diff) | |
download | busybox-w32-02958a6ee4050f75188df371a4118efb89685c8c.tar.gz busybox-w32-02958a6ee4050f75188df371a4118efb89685c8c.tar.bz2 busybox-w32-02958a6ee4050f75188df371a4118efb89685c8c.zip |
kbuild: simulate force-renaming on Windows
Calling rename() when a file with the target name exists already fails
on Windows.
Let's simply delete the target file, if it exists. This is usually a
dangerous thing as it leaves time between deleting and renaming, during
which (theoretically) another thread or process could have created the
same file, and the rename() would fail again. Practically, we are
talking about the kbuild system used to configure the build, where it
does not matter, as we do not expect any other thread or process to
interfere with the configuration files.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
-rw-r--r-- | scripts/kconfig/confdata.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 8f4ecbd33..1d77aefb7 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
@@ -571,15 +571,24 @@ int conf_write(const char *name) | |||
571 | fclose(out); | 571 | fclose(out); |
572 | if (out_h) { | 572 | if (out_h) { |
573 | fclose(out_h); | 573 | fclose(out_h); |
574 | #ifdef __MINGW32__ | ||
575 | unlink("include/autoconf.h"); | ||
576 | #endif | ||
574 | rename(".tmpconfig.h", "include/autoconf.h"); | 577 | rename(".tmpconfig.h", "include/autoconf.h"); |
575 | } | 578 | } |
576 | if (!name || basename != conf_def_filename) { | 579 | if (!name || basename != conf_def_filename) { |
577 | if (!name) | 580 | if (!name) |
578 | name = conf_def_filename; | 581 | name = conf_def_filename; |
579 | sprintf(tmpname, "%s.old", name); | 582 | sprintf(tmpname, "%s.old", name); |
583 | #ifdef __MINGW32__ | ||
584 | unlink(tmpname); | ||
585 | #endif | ||
580 | rename(name, tmpname); | 586 | rename(name, tmpname); |
581 | } | 587 | } |
582 | sprintf(tmpname, "%s%s", dirname, basename); | 588 | sprintf(tmpname, "%s%s", dirname, basename); |
589 | #ifdef __MINGW32__ | ||
590 | unlink(tmpname); | ||
591 | #endif | ||
583 | if (rename(newname, tmpname)) | 592 | if (rename(newname, tmpname)) |
584 | return 1; | 593 | return 1; |
585 | 594 | ||