[prev in list] [next in list] [prev in thread] [next in thread]
List: nix-dev
Subject: [Nix-dev] [PATCH] Handle "too many links" from btrfs.
From: nix () davidb ! org (David Brown)
Date: 2010-05-21 5:00:42
Message-ID: 1274418042-5220-1-git-send-email-nix () davidb ! org
[Download RAW message or body]
The btrfs seems to report "too many links" when attempting to rename
the temp link. Handle this case in the same manner as generating too
many links.
---
src/libstore/optimise-store.cc | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/src/libstore/optimise-store.cc b/src/libstore/optimise-store.cc
index d150492..9a3b354 100644
--- a/src/libstore/optimise-store.cc
+++ b/src/libstore/optimise-store.cc
@@ -119,9 +119,21 @@ 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. */
+ 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);
--
1.7.1
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic