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

Re: Possible Solaris problem in 'checkout_entry()'

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 19, 2008, 01:05 UTC
Message-ID
<7vwsnz5xrf.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<alpine.LFD.1.00.0803170850090.3020@woody.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 18 quoted lines
> On Mon, 17 Mar 2008, Linus Torvalds wrote:
>>
>> IOW, the real "checking" is taking place in "create_file()", so if the 
>> unlinking failed (due to a read-only directory or something), that's where 
>> we'll do the proper error reporting.
>
> Thinking about this, I'm probably full of sh*t.
>
> My argument is admittedly true in general, but there is one case it is 
> *not* true for: if the old entry was a symlink.
>
> IOW, let's imagine that the directory is read-only (or other permission 
> issue), and we want to unlink the old symlink, which points somewhere we 
> can write to. In that case, the symlink removal is important, because we 
> won't necessarily catch the error when we create the file in place later 
> (because that will just follow the symlink).
>
> So I retract my statement. We *should* check the result of the unlink.

While I agree we should check the result, I think we are safe against the un-unlinkable symlink case. If you have a stale symlink at "dir/file" where you are checking out a new blob, and the directory "dir" the symlink is in is unwritable, then our callpath would look like this:

	checkout_entry()
         unlink("dir/file") -- failure silently ignored which is bad
	 write_entry()
          create_file("dir/file")
           open("dir/file", O_WRONLY | O_CREAT | O_EXCL)
which would fail, and we get:
    error: git-checkout-index: unable to create file a/b (File exists)
from around ll.135 in entry.c::write_entry()
So I'll apply the patch purely as "Root on Solaris safety fix".
Previous: Linus Torvalds
Message 5 of 5 in “Possible Solaris problem in 'checkout_entry()'”
  1. Linus TorvaldsMar 17, 2008
  2. Morten WelinderMar 17, 2008
  3. Linus TorvaldsMar 17, 2008
  4. Linus TorvaldsMar 17, 2008
  5. Junio C HamanoMar 19, 2008

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.