public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Alexandre Oliva <oliva@adacore.com>
Cc: gcc Patches <gcc-patches@gcc.gnu.org>,
	"libstdc++" <libstdc++@gcc.gnu.org>
Subject: Re: [PATCH] libstdc++-v3: check for openat
Date: Mon, 27 Jun 2022 16:56:46 +0100	[thread overview]
Message-ID: <CACb0b4np6bFHDboEAHyqFW-8jYpkR7_oZRnzfTiAQk1ojtqLTw@mail.gmail.com> (raw)
In-Reply-To: <CACb0b4nVxRQP_tavzPcusG1JeQ38Z_GzHXBc9V7mGny_XVnCfA@mail.gmail.com>

On Mon, 27 Jun 2022 at 15:00, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On Mon, 27 Jun 2022 at 14:32, Jonathan Wakely <jwakely@redhat.com> wrote:
> >
> > On Mon, 27 Jun 2022 at 14:05, Alexandre Oliva <oliva@adacore.com> wrote:
> > >
> > > On Jun 27, 2022, Alexandre Oliva <oliva@adacore.com> wrote:
> > >
> > > > It looks like the atp.pathname is missing the nonexistent_path
> > > > assigned to variable dir in test_pr99290, so we attempt to open
> > > > subdirs thereof as if with openat.
> > >
> > > This appears to be caused by the early return in fs::_Dir's ctor:
> > >
> > >   _Dir(const fs::path& p, bool skip_permission_denied, bool nofollow,
> > >        [[maybe_unused]] bool filename_only, error_code& ec)
> > >   : _Dir_base(p.c_str(), skip_permission_denied, nofollow, ec)
> > >   {
> > > #if _GLIBCXX_HAVE_DIRFD // && 0
> > >     if (filename_only)
> > >       return; // Do not store path p when we aren't going to use it.
> > > #endif
> >
> > Yes, this needs a fix. If we don't have openat then we always need a
> > full path relative to the CWD, not just a filename relative to a file
> > descriptor for the parent directory.
> >
> > I think we need to store the directory's path if any of dirfd, openat
> > or unlinkat is missing.

i.e.

--- a/libstdc++-v3/src/c++17/fs_dir.cc
+++ b/libstdc++-v3/src/c++17/fs_dir.cc
@@ -48,7 +48,7 @@ struct fs::_Dir : _Dir_base
       [[maybe_unused]] bool filename_only, error_code& ec)
  : _Dir_base(p.c_str(), skip_permission_denied, nofollow, ec)
  {
-#if _GLIBCXX_HAVE_DIRFD
+#if _GLIBCXX_HAVE_DIRFD && _GLIBCXX_HAVE_OPENAT && _GLIBCXX_HAVE_UNLINKAT
    if (filename_only)
      return; // Do not store path p when we aren't going to use it.
#endif



> >
> >
> > >
> > >     if (!ec)
> > >       path = p;
> > >   }
> > >
> > > but somehow disabling the early return to force the saving of path
> > > appears to break copy(): copy.cc's test01() succeeded without the '&& 0'
> > > that I've commented-out above, but started failing to create 'to' in the
> > > copy at line copy.cc:54 when I put it in to prevent the early return.

N.B. it's not supposed to create 'to' there, that line is checking
that it fails and reports an error.

Could the FAIL simply be that rtems gives a different error, not
EISDIR as the test expects?

  VERIFY( ec == std::make_error_code(std::errc::is_a_directory) );

Although that shouldn't depend on anything target-specific, because
the libstdc++ code itself reports that error:

  else if (is_directory(f) && create_symlinks)
    ec = std::make_error_code(errc::is_a_directory);


  reply	other threads:[~2022-06-27 15:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22  6:41 Alexandre Oliva
2022-06-22 10:36 ` Jonathan Wakely
2022-06-23  4:41   ` Alexandre Oliva
2022-06-23  9:29     ` Jonathan Wakely
2022-06-23 11:08   ` Alexandre Oliva
2022-06-23 11:37     ` Jonathan Wakely
2022-06-23 14:05       ` Alexandre Oliva
2022-06-23 17:47         ` Jonathan Wakely
2022-06-27 12:00           ` Alexandre Oliva
2022-06-27 13:05             ` Alexandre Oliva
2022-06-27 13:32               ` Jonathan Wakely
2022-06-27 14:00                 ` Jonathan Wakely
2022-06-27 15:56                   ` Jonathan Wakely [this message]
2022-06-27 22:03                     ` Alexandre Oliva
2022-06-28  8:36                       ` Jonathan Wakely
2022-06-28 12:04                         ` Alexandre Oliva
2022-06-28 13:12                           ` Jonathan Wakely
2022-06-24 11:03         ` Jonathan Wakely
2022-06-27  9:49           ` Alexandre Oliva
2022-06-27  9:52             ` Jonathan Wakely
2022-06-24  2:34     ` Alexandre Oliva

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=CACb0b4np6bFHDboEAHyqFW-8jYpkR7_oZRnzfTiAQk1ojtqLTw@mail.gmail.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=oliva@adacore.com \
    /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).