diff options
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/build.cc | 2 | ||||
-rw-r--r-- | src/libstore/local-store.cc | 4 | ||||
-rw-r--r-- | src/libstore/optimise-store.cc | 16 | ||||
-rw-r--r-- | src/libstore/store-api.hh | 2 |
4 files changed, 20 insertions, 4 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc index a482ace00c22..8ce8c873d6a3 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -267,7 +267,7 @@ public: MakeError(SubstError, Error) -MakeError(BuildError, Error) /* denoted a permanent build failure */ +MakeError(BuildError, Error) /* denotes a permanent build failure */ ////////////////////////////////////////////////////////////////////// diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index cf0d559bdfb9..c7530f1b1bae 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1036,6 +1036,8 @@ void LocalStore::exportPath(const Path & path, bool sign, writeInt(1, hashAndWriteSink); Path tmpDir = createTempDir(); + PathLocks tmpDirLock(singleton<PathSet, Path>(tmpDir)); + tmpDirLock.setDeletion(true); AutoDelete delTmp(tmpDir); Path hashFile = tmpDir + "/hash"; writeFile(hashFile, printHash(hash)); @@ -1085,6 +1087,8 @@ Path LocalStore::importPath(bool requireSignature, Source & source) store path follows the archive data proper), and besides, we don't know yet whether the signature is valid. */ Path tmpDir = createTempDir(nixStore); + PathLocks tmpDirLock(singleton<PathSet, Path>(tmpDir)); + tmpDirLock.setDeletion(true); AutoDelete delTmp(tmpDir); /* !!! could be GC'ed! */ Path unpacked = tmpDir + "/unpacked"; diff --git a/src/libstore/optimise-store.cc b/src/libstore/optimise-store.cc index d15049201ea4..3ed54e24d773 100644 --- a/src/libstore/optimise-store.cc +++ b/src/libstore/optimise-store.cc @@ -119,9 +119,23 @@ static void hashAndLink(bool dryRun, HashToPath & hashToPath, } /* Atomically replace the old file with the new hard link. */ - if (rename(tempLink.c_str(), path.c_str()) == -1) + if (rename(tempLink.c_str(), path.c_str()) == -1) { + if (errno == EMLINK) { + /* Some filesystems generate too many links on the + rename, rather than on the original link. + (Probably it temporarily increases the st_nlink + field before decreasing it again.) */ + printMsg(lvlInfo, format("`%1%' has maximum number of links") % prevPath.first); + hashToPath[hash] = std::pair<Path, ino_t>(path, st.st_ino); + + /* Unlink the temp link. */ + if (unlink(tempLink.c_str()) == -1) + printMsg(lvlError, format("unable to unlink `%1%'") % tempLink); + return; + } throw SysError(format("cannot rename `%1%' to `%2%'") % tempLink % path); + } } else printMsg(lvlTalkative, format("would link `%1%' to `%2%'") % path % prevPath.first); diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index fbe0cce81e94..3b81bfa39438 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -16,8 +16,6 @@ namespace nix { typedef std::map<Path, Path> Roots; - - struct GCOptions { /* Garbage collector operation: |