This really bit me while trying to wrap up the tests for 'guix
environment --container'.  Thanks to Ludovic for tracking this down!

- Dave
From 482a31152260f48d1e96ffe74a2b1a9898d5f09c Mon Sep 17 00:00:00 2001
From: David Thompson <[email protected]>
Date: Fri, 16 Oct 2015 14:00:00 -0400
Subject: [PATCH] build: Do not clobber existing files when bind mounting.

* gnu/build/file-systems.scm (mount-file-system): Do not touch
  'mount-point' if it already exists.
---
 gnu/build/file-systems.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index 377bec2..df6d3da 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -347,7 +347,8 @@ run a file system check."
        ;; Create the mount point.  Most of the time this is a directory, but
        ;; in the case of a bind mount, a regular file may be needed.
        (if (and (= MS_BIND (logand flags MS_BIND))
-                (regular-file? source))
+                (regular-file? source)
+                (not (file-exists? mount-point)))
            (begin
              (mkdir-p (dirname mount-point))
              (call-with-output-file mount-point (const #t)))
-- 
2.5.0

Reply via email to