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

Re: new platform & S_IFGITLINK problem

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
May 4, 2010, 03:39 UTC
Message-ID
<alpine.LFD.2.00.1005032035310.5478@i5.linux-foundation.org>
In-Reply-To
<7vfx2b2ft5.fsf@alter.siamese.dyndns.org>
On Sat, 1 May 2010, Junio C Hamano wrote:
> 
> Yikes.  The current codebase pretty much assumes that IFREG is 0100000,
> IFDIR 0040000, and IFLNK 0120000, and the bits read from "struct stat" and
> the mode bits we store in the index and tree objects are interchangeable.

Yeah. This is painful. I knew it was wrong to just assume everything was sane and used the same traditional values, but I optimistically thought that the st_mode bits were the _one_ thing that everybody agrees on.

I was wrong. 
> Yes, that assumption is a gross POSIX violation but we so far haven't seen
> any platform that matters in real life that assigns the IFMT bits
> differently.

Indeed. Just out of interest - Alan, what _is_ the crazy platform that doesn't match what absolutely everybody else has always done?

> We would need to:
> 
>  (1) rename S_IFGITLINK to GIT_S_IFMODULE;
I'd suggest dropping the "_S_" part, and just calling it
	GIT_IFxyz
	GIT_ISxyz()
Show 13 quoted lines
>  (2) define GIT_S_IF{REG,DIR,LNK} as 0100000, 0040000, and 0120000;
> 
>  (3) write MODE_SYSTEM_TO_GIT() macro to convert from S_IF{REG,DIR,LNK} we
>      read from struct stat to the "canonical" GIT_S_IF{REG,DIR,LNK}
>      values; and
> 
>  (4) change all the code that read mode from struct stat and use it to
>      first use MODE_SYSTEM_TO_GIT().
> 
> Currently 'git grep -e "S_IF[A-Z]" -e "struct stat"' reports around 250
> hits, so it is not infeasible amount of work, but it is not a trivial and
> mechanical replacement, either.  I or somebody need to set aside a block
> of time to do this clean-up and audit the result.

Ugh. And since nobody sane has different values from the system ones, if we miss some case we'll never notice on any sane platform ;(

		Linus
Previous: Alan HourihaneNext: Linus Torvalds
Message 4 of 17 in “new platform & S_IFGITLINK problem”
  1. Alan HourihaneMay 1, 2010
  2. Junio C HamanoMay 2, 2010
  3. Alan HourihaneMay 2, 2010
  4. Linus TorvaldsMay 4, 2010
  5. Linus TorvaldsMay 4, 2010
  6. Andreas EricssonMay 4, 2010
  7. Linus TorvaldsMay 4, 2010
  8. Junio C HamanoMay 4, 2010
  9. Alan HourihaneMay 4, 2010
  10. Alan HourihaneJul 22, 2010
  11. Junio C HamanoJul 25, 2010
  12. Alan HourihaneJul 25, 2010
  13. Ævar Arnfjörð BjarmasonAug 2, 2010
  14. Alan HourihaneAug 2, 2010
  15. Ævar Arnfjörð BjarmasonAug 2, 2010
  16. Jonathan NiederMay 5, 2010
  17. Alan HourihaneMay 5, 2010

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.