From 1b6ee8f4c7e74f75e1f49b43cf22be7730b30649 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 13 Jun 2013 17:29:56 +0200 Subject: Allow hard links between the outputs of a derivation --- src/libstore/build.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/libstore/build.cc') diff --git a/src/libstore/build.cc b/src/libstore/build.cc index e49c66fc576a..20ed2de39005 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -844,6 +844,11 @@ private: bool repair; map redirectedBadOutputs; + /* Set of inodes seen during calls to canonicalisePathMetaData() + for this build's outputs. This needs to be shared between + outputs to allow hard links between outputs. */ + InodesSeen inodesSeen; + /* Magic exit code denoting that setting up the child environment failed. (It's possible that the child actually returns the exit code, but ah well.) */ @@ -1493,7 +1498,7 @@ void DerivationGoal::buildDone() /* Canonicalise first. This ensures that the path we're rewriting doesn't contain a hard link to /etc/shadow or something like that. */ - canonicalisePathMetaData(path, buildUser.enabled() ? buildUser.getUID() : -1); + canonicalisePathMetaData(path, buildUser.enabled() ? buildUser.getUID() : -1, inodesSeen); /* FIXME: this is in-memory. */ StringSink sink; @@ -2307,7 +2312,7 @@ void DerivationGoal::computeClosure() /* Get rid of all weird permissions. This also checks that all files are owned by the build user, if applicable. */ canonicalisePathMetaData(path, - buildUser.enabled() && rewrittenPaths.find(path) == rewrittenPaths.end() ? buildUser.getUID() : -1); + buildUser.enabled() && rewrittenPaths.find(path) == rewrittenPaths.end() ? buildUser.getUID() : -1, inodesSeen); /* For this output path, find the references to other paths contained in it. Compute the SHA-256 NAR hash at the same -- cgit 1.4.1