diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc index 9da3afffd..40a0385af 100644 --- a/src/libstore/build/local-derivation-goal.cc +++ b/src/libstore/build/local-derivation-goal.cc @@ -388,9 +388,8 @@ void LocalDerivationGoal::cleanupPostOutputsRegisteredModeNonCheck() #if __linux__ -static void linkOrCopy(LocalFSStore & store, const StorePath & from_, const Path & to) +static void linkOrCopy(const Path & from, const Path & to) { - auto from = store.toRealPathForHardLink(from_); if (link(from.c_str(), to.c_str()) == -1) { /* Hard-linking fails if we exceed the maximum link count on a file (e.g. 32000 of ext3), which is quite possible after a @@ -715,7 +714,7 @@ void LocalDerivationGoal::startBuilder() if (S_ISDIR(lstat(r).st_mode)) dirsInChroot.insert_or_assign(p, r); else - linkOrCopy(getLocalStore(), i, chrootRootDir + p); + linkOrCopy(r, chrootRootDir + p); } /* If we're repairing, checking or rebuilding part of a @@ -1600,7 +1599,7 @@ void LocalDerivationGoal::addDependency(const StorePath & path) throw Error("could not add path '%s' to sandbox", worker.store.printStorePath(path)); } else - linkOrCopy(getLocalStore(), path, target); + linkOrCopy(source, target); #else throw Error("don't know how to make path '%s' (produced by a recursive Nix call) appear in the sandbox", diff --git a/src/libstore/local-fs-store.hh b/src/libstore/local-fs-store.hh index 19858f5c8..488109501 100644 --- a/src/libstore/local-fs-store.hh +++ b/src/libstore/local-fs-store.hh @@ -73,16 +73,6 @@ public: return getRealStoreDir() + "/" + std::string(storePath, storeDir.size() + 1); } - /** - * If the real path is hardlinked with something else, we might - * prefer to refer to the other path instead. This is the case with - * overlayfs, for example. - */ - virtual Path toRealPathForHardLink(const StorePath & storePath) - { - return Store::toRealPath(storePath); - } - std::optional getBuildLogExact(const StorePath & path) override; }; diff --git a/src/libstore/local-overlay-store.cc b/src/libstore/local-overlay-store.cc index 73902e9ba..732b4d6ce 100644 --- a/src/libstore/local-overlay-store.cc +++ b/src/libstore/local-overlay-store.cc @@ -268,14 +268,6 @@ std::pair LocalOverlayStore::verifyAllValidPaths(RepairFlag } -Path LocalOverlayStore::toRealPathForHardLink(const StorePath & path) -{ - return lowerStore->isValidPath(path) - ? lowerStore->Store::toRealPath(path) - : Store::toRealPath(path); -} - - void LocalOverlayStore::remountIfNecessary() { if (!_remountRequired) return; diff --git a/src/libstore/local-overlay-store.hh b/src/libstore/local-overlay-store.hh index 8ed7516db..ac730c77c 100644 --- a/src/libstore/local-overlay-store.hh +++ b/src/libstore/local-overlay-store.hh @@ -186,12 +186,6 @@ private: */ std::pair verifyAllValidPaths(RepairFlag repair) override; - /** - * For lower-store paths, we used the lower store location. This avoids the - * wasteful "copying up" that would otherwise happen. - */ - Path toRealPathForHardLink(const StorePath & storePath) override; - /** * Deletion only effects the upper layer, so we ignore lower-layer referrers. */