public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH 3/5] Linux: Emulate fchmodat with AT_SYMLINK_NOFOLLOW using O_PATH [BZ #14578]
Date: Sun, 09 Feb 2020 08:58:00 -0000	[thread overview]
Message-ID: <87y2tcnnnw.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <1a62d1a2-6232-7d2a-f68f-6170d2b0dfc8@cs.ucla.edu> (Paul Eggert's message of "Sun, 9 Feb 2020 00:30:42 -0800")

* Paul Eggert:

> On 1/22/20 12:03 PM, Florian Weimer wrote:
>> +	  if (errno == ENFILE || errno == EMFILE)
>> +	    /* These errors cannot happen with a straight fchmodat
>> +	       operation because it does not create file descriptors,
>> +	       so hide them.  */
>> +	    __set_errno (EOPNOTSUPP);
>> +	  /* Otherwise, this should accurately reflect the expected
>> +	     error from fchmodat (e.g., EBADF or ENOENT).  */
>
> These lines can be omitted. I omitted them when recently adding similar code to 
> Gnulib in <https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/fchmodat.c>. 
> There's no need for fchmodat to masquerade ENFILE and EMFILE as EOPNOTSUPP: 
> POSIX does not require it and masquerading those two errno values would be 
> misleading, in the sense that it would make it harder for the caller to diagnose 
> what actually went wrong.

Hmm.  The error code is really obscure, particularly with AT_FDCWD,
where there is no file descriptor involved.  I hope that we can
eventually make it go away with proper kernel support.  But I see your
point about telling transient errors (such as ENOMEM) from more
persistent ones.

>> +      char buf[32];
>> +      if (__snprintf (buf, sizeof (buf), "/proc/self/fd/%d", pathfd) < 0)
>> +	{
>> +	  __close_nocancel (pathfd);
>> +	  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOPNOTSUPP);
>> +	}
>
> Similarly here. Also, there should be no reason for snprintf to fail. One 
> possibility is to replace this with what's in Gnulib:
>
>    static char const fmt[] = "/proc/self/fd/%d";
>    char buf[sizeof fmt - sizeof "%d" + INT_BUFSIZE_BOUND (int)];
>    sprintf (buf, fmt, pathfd);

I think we should add a proper wrapper for this eventually, where the
buffer allocation in the caller is properly abstracted via a
suitable struct type.

> where INT_BUFSIZE_BOUND is taken from <intprops.h>.
>
> Otherwise, this patch series looks OK to me; thanks for writing it.

Thanks.

What do you think about introducing new symbol versions vs keeping
things as they are in the patch today?

If we do not introduce new symbol versions, we should strive to
backport this change widely, so that users do not run into obscure
failures.

  reply	other threads:[~2020-02-09  8:58 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-22 20:03 [PATCH 0/5] Linux: lchmod and AT_SYMLINK_NOFOLLOW support for fchmodat Florian Weimer
2020-01-22 20:03 ` [PATCH 1/5] support: Add the xlstat function Florian Weimer
2020-01-22 20:03 ` [PATCH 2/5] io: Implement lchmod using fchmodat [BZ #14578] Florian Weimer
2020-01-22 20:03 ` [PATCH 3/5] Linux: Emulate fchmodat with AT_SYMLINK_NOFOLLOW using O_PATH " Florian Weimer
2020-02-09  8:31   ` Paul Eggert
2020-02-09  8:58     ` Florian Weimer [this message]
2020-02-09 10:06       ` Paul Eggert
2020-02-09 10:33         ` Florian Weimer
2020-02-11 15:25         ` Florian Weimer
2020-02-12  1:37           ` Paul Eggert
2020-01-22 20:04 ` [PATCH 4/5] io: Add io/tst-lchmod covering lchmod and fchmodat Florian Weimer
2020-02-11 15:27   ` Florian Weimer
2020-02-12 18:52     ` Adhemerval Zanella
2020-02-12 18:55       ` Florian Weimer
2020-02-12 19:41         ` Adhemerval Zanella
2020-02-12 20:01           ` Florian Weimer
2020-02-12 20:28             ` Florian Weimer
2020-01-22 20:27 ` [PATCH 5/5] Linux: Add op/tst-o_path-locks Florian Weimer
2020-07-21  9:46 ` [PATCH 0/5] Linux: lchmod and AT_SYMLINK_NOFOLLOW support for fchmodat Andreas Schwab
2020-07-21  9:54   ` Florian Weimer
2020-08-17 15:46     ` Dmitry V. Levin
2020-08-25 10:21     ` Andreas Schwab
2020-08-25 10:24       ` Florian Weimer
2020-08-25 10:53         ` Andreas Schwab
2020-08-25 11:04           ` Florian Weimer
2020-08-25 11:08             ` Andreas Schwab
2020-08-25 11:09               ` Florian Weimer
2020-08-25 11:15                 ` Andreas Schwab
2020-08-25 11:16                   ` Florian Weimer
2020-08-25 11:22                     ` Andreas Schwab
2020-08-25 11:28                       ` Florian Weimer
2020-08-25 12:13                         ` Andreas Schwab
2020-08-25 12:16                           ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y2tcnnnw.fsf@mid.deneb.enyo.de \
    --to=fw@deneb.enyo.de \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).