[Xen-devel] [PATCH 1/2] tools/shim: Fix race condition creating linkfarm.stamp

Andrew Cooper posted 2 patches 6 years, 5 months ago
[Xen-devel] [PATCH 1/2] tools/shim: Fix race condition creating linkfarm.stamp
Posted by Andrew Cooper 6 years, 5 months ago
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(-)

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
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 1/2] tools/shim: Fix race condition creating linkfarm.stamp
Posted by Ian Jackson 6 years, 5 months ago
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>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel