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

Re: [PATCH] sha1_file: make sure correct error is propagated

From
FGFrancis Galiegue <fg@one2team.net>
Date
Nov 14, 2008, 20:08 UTC
Message-ID
<200811142108.46762.fg@one2team.net>
In-Reply-To
<491DD671.8070801@op5.se>
Le Friday 14 November 2008 20:50:09 Andreas Ericsson, vous avez écrit :
Show 24 quoted lines
> Francis Galiegue wrote:
> > Le Friday 14 November 2008 20:05:19 Junio C Hamano, vous avez écrit :
> > [...]
> >
> >>>  	fd = mkstemp(buffer);
> >>> -	if (fd < 0 && dirlen && (errno != EPERM)) {
> >>> +	if (fd < 0 && dirlen && (errno != EACCESS)) {
> >>
> >> Is this accepting the two as equivalents???
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe git" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> > Well, looking at mkdir(2), it says:
> >
> >        EPERM  The file system containing pathname does not support the
> > creation of directories.
> >
> > Hmm, err... git would fail at an earlier point anyway, wouldn't it? Even
> > git init would fail there.
>
> Not necessarily. .git could be mounted erroneously from via a networked
> filesystem but without write permissions. 

In which case EACCESS would be returned anyway. There is quite a difference between EACCESS (Permission denied) and EPERM (operation not permitted).

Basically, my understanding is that mkdir() will only return EPERM if the underlying filesystem can not even CREATE directories on the filesystem. So, unless you are doing very bizarre things with your git repository, I cannot see how you can even trigger an EPERM unless you asked for it.

> Yes, other things would fail 
> then too, but both EPERM and EACCESS are valid and possible return codes.

And so is ENOSPC, and so is EIO, and so is... It's endless. I think focus should be made on the most common ones, and EACCESS _is_ such one. Others just aren't.

This is why I suggested replacing EPERM with EACCESS in the first place: EACCESS is by far the most common error code you will get (even root will get that on a read-only filesystem, not EPERM).

-- 
fge
Previous: Andreas EricssonNext: Junio C Hamano
Message 7 of 9 in “sha1_file: make sure correct error is propagated”
  1. sha1_file: make sure correct error is propagatedSam Vilain, Nov 14, 2008
  2. Francis GaliegueNov 14, 2008
  3. Sam VilainNov 14, 2008
  4. Junio C HamanoNov 14, 2008
  5. Francis GaliegueNov 14, 2008
  6. Andreas EricssonNov 14, 2008
  7. Francis GaliegueNov 14, 2008
  8. Junio C HamanoNov 15, 2008
  9. Sam VilainNov 15, 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.