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

Re: Why O_EXCL would make this difference? I am puzzled..

From
Linus Torvalds <torvalds@osdl.org>
Date
Jul 14, 2005, 16:52 UTC
Message-ID
<Pine.LNX.4.58.0507140944580.19183@g5.osdl.org>
In-Reply-To
<Pine.LNX.4.58.0507140904440.19183@g5.osdl.org>
On Thu, 14 Jul 2005, Linus Torvalds wrote:
> 
> I'll strace the dang thing.
It's the "Adding" case in git-merge-one-file-script, which does
	git-checkout-cache -u -f -- "$4"
and it's because of this:
	lstat64("DF", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
	unlink("DF")                            = -1 EISDIR (Is a directory)
	.. unpack the object ..
	open("DF", O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0666) = -1 EEXIST (File exists)
ie the problem is that we actually _have_ a test for this, but it's:
	if (errno == EISDIR && force) {
but if the directory already exists, we do that wrong.

Btw, this also shows a different problem: the symlink handling doesn't do any of this, so you cannot even force a directory to become a symlink.

I think both problems can be fixed by just moving the (EISDIR && force) test down to the "unlink()".

Will try.
		Linus
Previous: Linus Torvalds
Message 3 of 3 in “Why O_EXCL would make this difference? I am puzzled..”
  1. Junio C HamanoJul 14, 2005
  2. Linus TorvaldsJul 14, 2005
  3. Linus TorvaldsJul 14, 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.