[1/2] tools/shim: Fix race condition creating linkfarm.stamp
diff mbox series

Message ID 20190902164148.28977-2-andrew.cooper3@citrix.com
State New
Headers show
Series
  • tools/shim: Bodge things harder
Related show

Commit Message

Andrew Cooper Sept. 2, 2019, 4:41 p.m. UTC
In the case the while loop gets interrupted, the target musn't appear as
up-to-date.  The mov $X.tmp $X must be the last action of the rule.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Jackson <Ian.Jackson@citrix.com>
CC: Wei Liu <wl@xen.org>
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
CC: Sander Eikelenboom <linux@eikelenboom.it>
---
 tools/firmware/xen-dir/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ian Jackson Sept. 2, 2019, 5:01 p.m. UTC | #1
Andrew Cooper writes ("[PATCH 1/2] tools/shim: Fix race condition creating linkfarm.stamp"):
> In the case the while loop gets interrupted, the target musn't appear as
> up-to-date.  The mov $X.tmp $X must be the last action of the rule.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

Patch
diff mbox series

diff --git a/tools/firmware/xen-dir/Makefile b/tools/firmware/xen-dir/Makefile
index 697bbbd57b..df3f5a7006 100644
--- a/tools/firmware/xen-dir/Makefile
+++ b/tools/firmware/xen-dir/Makefile
@@ -32,9 +32,9 @@  linkfarm.stamp: $(DEP_DIRS) $(DEP_FILES) FORCE
 		echo $(f) >> linkfarm.stamp.tmp ;)
 	cmp -s linkfarm.stamp.tmp linkfarm.stamp && \
 		rm linkfarm.stamp.tmp || { \
+		cat linkfarm.stamp.tmp | while read f; \
+		  do rm -f "$(D)/$$f"; ln -s "$(XEN_ROOT)/$$f" "$(D)/$$f"; done; \
 		mv linkfarm.stamp.tmp linkfarm.stamp; \
-		cat linkfarm.stamp | while read f; \
-		  do rm -f "$(D)/$$f"; ln -s "$(XEN_ROOT)/$$f" "$(D)/$$f"; done \
 		}
 
 # Copy enough of the tree to build the shim hypervisor