git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD

From
Jan Harkes <jaharkes@cs.cmu.edu>
Date
Oct 26, 2005, 16:55 UTC
Message-ID
<20051026165515.GA16616@delft.aura.cs.cmu.edu>
In-Reply-To
<20051026161552.GA11483@delft.aura.cs.cmu.edu>
On Wed, Oct 26, 2005 at 12:15:52PM -0400, Jan Harkes wrote:
> Checking the SuSv2 manpage for link(2), it doesn't mention either of
> these error codes. But does mention EPERM as a valid error when the
> filesystem doesn't support hardlinks.
>     http://www.opengroup.org/onlinepubs/007908799/xsh/link.html

Re-reading this, I seem to have misinterpreted the text. EPERM is returned when the filesystem doesn't allow hard linking a directory. I guess the closest error would actually be EMLINK, assuming that a filesystem that doesn't support hardlinks would have LINK_MAX set to 1.

    Linux returns EPERM
    Coda returns EXDEV
    BSDs seem to return EOPNOTSUPP.
    MacOS X/Darwin doesn't mention it in their manpages.

Simply falling back on rename when there is any error, as Linus suggested, seems like a pretty good solution right now. Rename should give the same set of errors except when the link target already existed.

Jan
diff --git a/sha1_file.c b/sha1_file.c
index e456799..0eba58c 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1234,15 +1234,14 @@ int move_temp_to_file(const char *tmpfil
 	int ret = link_temp_to_file(tmpfile, filename);
 	if (ret) {
 		/*
-		 * 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.
+		 * The file system may not support hardlinks, so we fall back
+		 * to a rename. We won't be able to check for 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))
+		if (ret && ret != EEXIST && !rename(tmpfile, filename))
 			return 0;
 	}
 	unlink(tmpfile);
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 9 of 17 in “git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD”
  1. Randal L. SchwartzOct 26, 2005
  2. Randal L. SchwartzOct 26, 2005
  3. Johannes SchindelinOct 26, 2005
  4. Randal L. SchwartzOct 26, 2005
  5. Johannes SchindelinOct 26, 2005
  6. Randal L. SchwartzOct 26, 2005
  7. Jan HarkesOct 26, 2005
  8. Johannes SchindelinOct 26, 2005
  9. Jan HarkesOct 26, 2005
  10. Johannes SchindelinOct 26, 2005
  11. Linus TorvaldsOct 26, 2005
  12. Linus TorvaldsOct 26, 2005
  13. Johannes SchindelinOct 26, 2005
  14. Horst von BrandOct 26, 2005
  15. Randal L. SchwartzOct 26, 2005
  16. Junio C HamanoOct 26, 2005
  17. Randal L. SchwartzOct 26, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.