summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: aac1794)
raw | patch | inline | side by side (parent: aac1794)
author | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Tue, 3 May 2005 22:16:18 +0000 (15:16 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Tue, 3 May 2005 22:16:18 +0000 (15:16 -0700) |
Coda doesn't like cross-directory hardlinks. So try to fall back
on a plain rename instead.
on a plain rename instead.
sha1_file.c | patch | blob | history |
diff --git a/sha1_file.c b/sha1_file.c
index 8f577985afd89ef04a87b4373b5f1d4561600122..e6ce455ae90bd430f2128f454bdb6e0575412486 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -353,8 +353,21 @@ int write_sha1_file(char *buf, unsigned long len, const char *type, unsigned cha
close(fd);
ret = link(tmpfile, filename);
- if (ret < 0)
+ if (ret < 0) {
ret = errno;
+
+ /*
+ * Coda hack - coda doesn't like cross-directory links,
+ * so we fall back to a rename, which will mean that it
+ * won't be able to check collisions, but that's not a
+ * big deal.
+ *
+ * When this succeeds, we just return 0. We have nothing
+ * left to unlink.
+ */
+ if (ret == EXDEV && !rename(tmpfile, filename))
+ return 0;
+ }
unlink(tmpfile);
if (ret) {
if (ret != EEXIST) {