diff options
author | Nicolas Pitre <nicolas.pitre@linaro.org> | 2018-03-15 23:56:20 +0300 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-03-21 12:18:10 +0300 |
commit | 825d487583089f9a33d31650c9c41f6474aab7fc (patch) | |
tree | 5aeb3b755703fca443fdfe3bb40da5ba355515ca /scripts/adjust_autoksyms.sh | |
parent | 0c8efd610b58cb23cefdfa12015799079aef94ae (diff) | |
download | linux-825d487583089f9a33d31650c9c41f6474aab7fc.tar.xz |
kbuild: make scripts/adjust_autoksyms.sh robust against timestamp races
Some filesystems have timestamps with coarse precision that may allow
for a recently built object file to have the same timestamp as the
updated time on one of its dependency files. When that happens, the
object file doesn't get rebuilt as it should.
This is especially the case on filesystems that don't have sub-second
time precision, such as ext3 or Ext4 with 128B inodes.
Let's prevent that by making sure updated dependency files have a newer
timestamp than the first file we created (i.e. autoksyms.h.tmpnew).
Reported-by: Thomas Lindroth <thomas.lindroth@gmail.com>
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Tested-by: Thomas Lindroth <thomas.lindroth@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/adjust_autoksyms.sh')
-rwxr-xr-x | scripts/adjust_autoksyms.sh | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/adjust_autoksyms.sh b/scripts/adjust_autoksyms.sh index 513da1a4a2da..d67830e6e360 100755 --- a/scripts/adjust_autoksyms.sh +++ b/scripts/adjust_autoksyms.sh @@ -84,6 +84,13 @@ while read sympath; do depfile="include/config/ksym/${sympath}.h" mkdir -p "$(dirname "$depfile")" touch "$depfile" + # Filesystems with coarse time precision may create timestamps + # equal to the one from a file that was very recently built and that + # needs to be rebuild. Let's guard against that by making sure our + # dep files are always newer than the first file we created here. + while [ ! "$depfile" -nt "$new_ksyms_file" ]; do + touch "$depfile" + done echo $((count += 1)) done | tail -1 ) changed=${changed:-0} |