mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 09:06:15 +02:00
* When building in a chroot, make a copy of a file if hard-linking
fails. This is likely to happen after a `nix-store --optimise', because some files may have 32000 links (NIX-111).
This commit is contained in:
parent
6b9f6b0222
commit
8520542071
1 changed files with 13 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
||||||
#include "globals.hh"
|
#include "globals.hh"
|
||||||
#include "local-store.hh"
|
#include "local-store.hh"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
#include "archive.hh"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -1604,8 +1605,18 @@ void DerivationGoal::startBuilder()
|
||||||
dirsInChroot.insert(*i);
|
dirsInChroot.insert(*i);
|
||||||
else {
|
else {
|
||||||
Path p = chrootRootDir + *i;
|
Path p = chrootRootDir + *i;
|
||||||
if (link(i->c_str(), p.c_str()) == -1)
|
if (link(i->c_str(), p.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 `nix-store
|
||||||
|
--optimise'. Make a copy instead. */
|
||||||
|
if (errno != EMLINK)
|
||||||
throw SysError(format("linking `%1%' to `%2%'") % p % *i);
|
throw SysError(format("linking `%1%' to `%2%'") % p % *i);
|
||||||
|
StringSink sink;
|
||||||
|
dumpPath(*i, sink);
|
||||||
|
StringSource source(sink.s);
|
||||||
|
restorePath(p, source);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue