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

Re: [PATCH] compat: convert modes to use portable file type values

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 1, 2014, 20:09 UTC
Message-ID
<xmqq7fybp1xb.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAEvUa7nsz1UX5+qakPGW=wTR_VRJU3r+VkgVt9qiCDUz30MweA@mail.gmail.com>
David Michael <fedora.dm0@gmail.com> writes:
Show 16 quoted lines
>> Huh?  I am confused.  Since when is it legal to give NULL as statbuf
>> to (l)stat(2)?
>>
>> Wouldn't something like this be sufficient and necessary?
>>
>>         int rc = stat(path, buf);
>>         if (rc)
>>                 return rc;
>>
>> That is, let the underlying stat(2) diagnose any and all problems
>> (and leave clues in errno) and parrot its return value to the caller
>> to signal the failure?
>
> Alright, it wasn't immediately clear to me from the OpenGroup page on
> stat() if that would always be safe.  I will just test the return code
> in v2.

It is irrelevant if that is safe or not. As long as we are emulating the underlying stat(), whether it is unsafe for stat(), we should just throw whatever the user throws at us at the underlying stat() and let it behave as if our emulation layer were not there.

Which is what the above snippet does.
Previous: David Michael
Message 12 of 12 in “compat: convert modes to use portable file type values”
  1. compat: convert modes to use portable file type valuesDavid Michael, Nov 30, 2014
  2. Torsten BögershausenNov 30, 2014
  3. David MichaelDec 1, 2014
  4. Torsten BögershausenDec 1, 2014
  5. David MichaelDec 1, 2014
  6. David MichaelDec 1, 2014
  7. Junio C HamanoDec 1, 2014
  8. Duy NguyenDec 1, 2014
  9. David MichaelDec 1, 2014
  10. Junio C HamanoDec 1, 2014
  11. David MichaelDec 1, 2014
  12. Junio C HamanoDec 1, 2014

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.