public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101510] New: std::filesystem::create_directory  on an existing symlink to a directory
@ 2021-07-19 12:35 enometh at meer dot net
  2021-07-19 22:44 ` [Bug libstdc++/101510] " redi at gcc dot gnu.org
                   ` (24 more replies)
  0 siblings, 25 replies; 26+ messages in thread
From: enometh at meer dot net @ 2021-07-19 12:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

            Bug ID: 101510
           Summary: std::filesystem::create_directory  on an existing
                    symlink to a directory
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: enometh at meer dot net
  Target Milestone: ---

cppreference.com states

```     
bool create_directory( const std::filesystem::path& p );

Creates the directory p as if by POSIX mkdir() with a second argument of
static_cast<int>(std::filesystem::perms::all) (the parent directory must
already exist). If the function fails because p resolves to an existing
directory, no error is reported. Otherwise on failure an error is reported.
```

This should accomodate situations when `p' resolves to an existing directory
when `p' it is a symbolic link.

However create_directory(p) fails when p is a symbolic link which points
to an existing directory.

The standard usage pattern is to call mkdir(p) - and if it fails on EEXIST
to stat(2) p - following symlinks, and check if is a directory. The pattern
is used to ensure that `p' can be treated as a directory for further
operations and this includes p being a symbolic link to a directory)

This use of pattern is defeated if user code is replaced with a call to
std::create_directory without considering the symlink following
semantics of the pattern. (eg. replacing glib g_mkdir_with_parents with
std::fs::create_directories)

I think libstdc++ follow symlinks when resolving names for the create_directory
and create_directory functions.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
@ 2021-07-19 22:44 ` redi at gcc dot gnu.org
  2021-07-20 11:43 ` redi at gcc dot gnu.org
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-19 22:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
   Last reconfirmed|                            |2021-07-19
     Ever confirmed|0                           |1

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
  2021-07-19 22:44 ` [Bug libstdc++/101510] " redi at gcc dot gnu.org
@ 2021-07-20 11:43 ` redi at gcc dot gnu.org
  2021-07-20 11:46 ` redi at gcc dot gnu.org
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-20 11:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |WAITING

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Madhu from comment #0)
> However create_directory(p) fails when p is a symbolic link which points
> to an existing directory.

No it doesn't.

It returns false to tell you that it didn't create a directory, but "no error
is reported" as required by the specification. Returning false is not reporting
an error. If create_directory(p) reports an error then it throws an exception
of type filesystem_error, see
https://en.cppreference.com/w/cpp/filesystem/create_directory#Exceptions

Are you misunderstanding the function's semantics?

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
  2021-07-19 22:44 ` [Bug libstdc++/101510] " redi at gcc dot gnu.org
  2021-07-20 11:43 ` redi at gcc dot gnu.org
@ 2021-07-20 11:46 ` redi at gcc dot gnu.org
  2021-07-20 11:58 ` cvs-commit at gcc dot gnu.org
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-20 11:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Madhu from comment #0)
> cppreference.com states
> 
> ```	
> bool create_directory( const std::filesystem::path& p );
> 
> Creates the directory p as if by POSIX mkdir() with a second argument of
> static_cast<int>(std::filesystem::perms::all) (the parent directory must
> already exist). If the function fails because p resolves to an existing
> directory, no error is reported. Otherwise on failure an error is reported.
> ```
> 
> This should accomodate situations when `p' resolves to an existing directory
> when `p' it is a symbolic link.
> 
> However create_directory(p) fails when p is a symbolic link which points
> to an existing directory.
> 
> The standard usage pattern is to call mkdir(p) - and if it fails on EEXIST
> to stat(2) p - following symlinks, and check if is a directory. The pattern
> is used to ensure that `p' can be treated as a directory for further
> operations and this includes p being a symbolic link to a directory)

You can do this with create_directory. If create_directory(p) doesn't throw an
exception, then is_directory(p) is true. Or without exceptions:

  std::error_code ec;
  create_directory(p, ec);
  if (!ec)
  {
    // p resolves to a directory
  }

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (2 preceding siblings ...)
  2021-07-20 11:46 ` redi at gcc dot gnu.org
@ 2021-07-20 11:58 ` cvs-commit at gcc dot gnu.org
  2021-07-20 12:01 ` redi at gcc dot gnu.org
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-20 11:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:0c4ae4ff46b1d7633f1e06f57d348b5817b8f640

commit r12-2413-g0c4ae4ff46b1d7633f1e06f57d348b5817b8f640
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jul 20 12:35:37 2021 +0100

    libstdc++: Add more tests for filesystem::create_directory [PR101510]

    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

    libstdc++-v3/ChangeLog:

            PR libstdc++/101510
            * src/c++17/fs_ops.cc (create_dir): Adjust whitespace.
            * testsuite/27_io/filesystem/operations/create_directory.cc:
            Test creating directory with name of existing symlink to
            directory.
            * testsuite/experimental/filesystem/operations/create_directory.cc:
            Likewise.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (3 preceding siblings ...)
  2021-07-20 11:58 ` cvs-commit at gcc dot gnu.org
@ 2021-07-20 12:01 ` redi at gcc dot gnu.org
  2021-07-20 15:55 ` enometh at meer dot net
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-20 12:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I've added tests to verify that the behaviour is correct, and those tests pass
with all versions of GCC.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (4 preceding siblings ...)
  2021-07-20 12:01 ` redi at gcc dot gnu.org
@ 2021-07-20 15:55 ` enometh at meer dot net
  2021-07-20 16:00 ` redi at gcc dot gnu.org
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: enometh at meer dot net @ 2021-07-20 15:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #5 from Madhu <enometh at meer dot net> ---
*  "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
<bug-101510-34102-sqMEQj9IHu@http.gcc.gnu.org/bugzilla/>
Wrote on Tue, 20 Jul 2021 11:46:32 +0000

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510
>
> --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> (In reply to Madhu from comment #0)
>> cppreference.com states
>>
>> ```
>> bool create_directory( const std::filesystem::path& p );
>>
>> Creates the directory p as if by POSIX mkdir() with a second argument of
>> static_cast<int>(std::filesystem::perms::all) (the parent directory must
>> already exist). If the function fails because p resolves to an existing
>> directory, no error is reported. Otherwise on failure an error is reported.
>> ```
>>
>> This should accomodate situations when `p' resolves to an existing directory
>> when `p' it is a symbolic link.
>>
>> However create_directory(p) fails when p is a symbolic link which points
>> to an existing directory.
>>
>> The standard usage pattern is to call mkdir(p) - and if it fails on EEXIST
>> to stat(2) p - following symlinks, and check if is a directory. The pattern
>> is used to ensure that `p' can be treated as a directory for further
>> operations and this includes p being a symbolic link to a directory)
>
> You can do this with create_directory. If create_directory(p) doesn't throw an
> exception, then is_directory(p) is true. Or without exceptions:
>
>   std::error_code ec;
>   create_directory(p, ec);
>   if (!ec)
>   {
>     // p resolves to a directory
>   }
>

It looks like I did indeed get the semantics wrong

I was going by the usage from databasePath() in
https://github.com/WebKit/WebKit/blob/main/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabaseTracker.cpp#L142
which calls ensureDatabaseDirectoryExists() in
https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/sql/SQLiteFileSystem.cpp#L59
which calls makeAllDirectories()
https://github.com/WebKit/WebKit/blob/main/Source/WTF/wtf/FileSystem.cpp#L733

The check is for only on the boolean value of ec, which is wrong
according to the spec, Thanks!

Instead of precipitately filing the bug here I should have filed it
with WebKit.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (5 preceding siblings ...)
  2021-07-20 15:55 ` enometh at meer dot net
@ 2021-07-20 16:00 ` redi at gcc dot gnu.org
  2021-07-20 16:20 ` enometh at meer dot net
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-20 16:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|WAITING                     |RESOLVED

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Madhu from comment #5)
> It looks like I did indeed get the semantics wrong

OK, thanks for confirming.

> I was going by the usage from databasePath() in
> https://github.com/WebKit/WebKit/blob/main/Source/WebKit/NetworkProcess/
> WebStorage/LocalStorageDatabaseTracker.cpp#L142
> which calls ensureDatabaseDirectoryExists() in
> https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/sql/
> SQLiteFileSystem.cpp#L59
> which calls makeAllDirectories()
> https://github.com/WebKit/WebKit/blob/main/Source/WTF/wtf/FileSystem.cpp#L733
> 
> The check is for only on the boolean value of ec, which is wrong
> according to the spec, Thanks!

That looks correct to me. It's the same as the example as I showed above.

If ec does not have a value, it means no error occurred. That means either the
directory was created, or already exists.

> Instead of precipitately filing the bug here I should have filed it
> with WebKit.

Are you *actually* seeing incorrect behaviour, or just concluding there is a
bug by reading the code?

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (6 preceding siblings ...)
  2021-07-20 16:00 ` redi at gcc dot gnu.org
@ 2021-07-20 16:20 ` enometh at meer dot net
  2021-07-20 16:25 ` redi at gcc dot gnu.org
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: enometh at meer dot net @ 2021-07-20 16:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #7 from Madhu <enometh at meer dot net> ---
*  "redi at gcc dot gnu.org"
<bug-101510-34102-7EIpFELo9R@http.gcc.gnu.org/bugzilla/>
Wrote on Tue, 20 Jul 2021 16:00:55 +0000
>> I was going by the usage from databasePath() in
>> https://github.com/WebKit/WebKit/blob/main/Source/WebKit/NetworkProcess/
>> WebStorage/LocalStorageDatabaseTracker.cpp#L142
>> which calls ensureDatabaseDirectoryExists() in
>> https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/sql/
>> SQLiteFileSystem.cpp#L59
>> which calls makeAllDirectories()
>> https://github.com/WebKit/WebKit/blob/main/Source/WTF/wtf/FileSystem.cpp#L733
>>
>> The check is for only on the boolean value of ec, which is wrong
>> according to the spec, Thanks!
>
> That looks correct to me. It's the same as the example as I showed above.
>
> If ec does not have a value, it means no error occurred. That means either the
> directory was created, or already exists.
>
>> Instead of precipitately filing the bug here I should have filed it
>> with WebKit.
>
> Are you *actually* seeing incorrect behaviour, or just concluding
> there is a bug by reading the code?

[There is a problem and I misread the code at first.]

The databasePath() function in the first reference consumes a boolean
value which is false and incorrectly assumes there is an error.  (it
correctly reports that the directory could not be created, but then it
assumes that the directory does not exist.)

This is incorrect behaviour when the name does resolve to a directory

The semantics really mean that the boolean value of ec should be
ignored for this usage pattern where you want to ensure a directory
exists.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (7 preceding siblings ...)
  2021-07-20 16:20 ` enometh at meer dot net
@ 2021-07-20 16:25 ` redi at gcc dot gnu.org
  2021-07-20 16:40 ` enometh at meer dot net
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-20 16:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think you are still confused between the bool that crate_directory returns,
and the bool that you get from !ec

The bool that is returned tells you if a new directory was created.

The bool you get from !ec tells you if the directory exists (whether it was
created or already existed).

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (8 preceding siblings ...)
  2021-07-20 16:25 ` redi at gcc dot gnu.org
@ 2021-07-20 16:40 ` enometh at meer dot net
  2021-07-20 16:53 ` redi at gcc dot gnu.org
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: enometh at meer dot net @ 2021-07-20 16:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #9 from Madhu <enometh at meer dot net> ---
*  "redi at gcc dot gnu.org" 
<bug-101510-34102-aFAnZEywsl@http.gcc.gnu.org/bugzilla/>
Wrote on Tue, 20 Jul 2021 16:25:44 +0000

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510
>
> --- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> I think you are still confused between the bool that crate_directory returns,
> and the bool that you get from !ec
>
> The bool that is returned tells you if a new directory was created.
>
> The bool you get from !ec tells you if the directory exists (whether it was
> created or already existed).

I'm afraid I'm still confused. From what you suggest I should be able to write

// return true if p resolves to an existing directory
int
ensure_directories(p)
{
 std::error_code ec;
 std::filesystem::create_directories("p", ec);
 return !ec;
}


But this does not work

$ mkdir xxx
$ ln -sv fff asdf
$ ls asdf
asdf -> xxx

std::filesystem::create_directories("asdf", ec);
ec.value() = 20, !ec = 0

ensure_directories would return false but it shouldn't because asdf
resolves to an existing directory.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (9 preceding siblings ...)
  2021-07-20 16:40 ` enometh at meer dot net
@ 2021-07-20 16:53 ` redi at gcc dot gnu.org
  2021-07-20 16:57 ` enometh at meer dot net
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-20 16:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |---
             Status|RESOLVED                    |WAITING

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
So then that would be a problem with create_directories, not create_directory
(which is the subject of the bug you reported).

Could you please provide an actual (complete) testcase showing the actual
problem?

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (10 preceding siblings ...)
  2021-07-20 16:53 ` redi at gcc dot gnu.org
@ 2021-07-20 16:57 ` enometh at meer dot net
  2021-07-20 16:58 ` redi at gcc dot gnu.org
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: enometh at meer dot net @ 2021-07-20 16:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #11 from Madhu <enometh at meer dot net> ---
sorry for the typos in my last message - i should've proofread - but
they should be fairly obvious. ( I wrote "p" instead of p, and fff
instead of xxx, etc.)

I think my initial problem remains

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (11 preceding siblings ...)
  2021-07-20 16:57 ` enometh at meer dot net
@ 2021-07-20 16:58 ` redi at gcc dot gnu.org
  2021-07-20 16:59 ` redi at gcc dot gnu.org
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-20 16:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |ASSIGNED

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is the code from create_directories:

  file_status st = symlink_status(p, ec);
  if (is_directory(st))
    return false;
  else if (ec && !status_known(st))
    return false;
  else if (exists(st))
    {
      if (!ec)
        ec = std::make_error_code(std::errc::not_a_directory);
      return false;
    }


The first line should use status not symlink_status, that's the bug.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (12 preceding siblings ...)
  2021-07-20 16:58 ` redi at gcc dot gnu.org
@ 2021-07-20 16:59 ` redi at gcc dot gnu.org
  2021-07-20 17:05 ` enometh at meer dot net
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-20 16:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Madhu from comment #11)
> I think my initial problem remains

Well your "initial problem" was talking exclusively about create_directory,
which works perfectly.

There is a problem is a **different** function, however when you report a bug
saying "A doesn't work" it's hard to know that you meant "B doesn't work".

This is why you're supposed to provide a testcase, so we don't have to guess
what you're actually trying to say.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (13 preceding siblings ...)
  2021-07-20 16:59 ` redi at gcc dot gnu.org
@ 2021-07-20 17:05 ` enometh at meer dot net
  2021-07-20 19:35 ` cvs-commit at gcc dot gnu.org
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: enometh at meer dot net @ 2021-07-20 17:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #14 from Madhu <enometh at meer dot net> ---
*  "redi at gcc dot gnu.org"
Wrote on Tue, 20 Jul 2021 16:59:20 +0000
> Well your "initial problem" was talking exclusively about
> create_directory, which works perfectly.
>
> There is a problem is a **different** function, however when you
> report a bug saying "A doesn't work" it's hard to know that you
> meant "B doesn't work".
>
> This is why you're supposed to provide a testcase, so we don't have
> to guess what you're actually trying to say.

Mea maxima culpa.

The title is wrong - create_directories was the only function I tested
before posting.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (14 preceding siblings ...)
  2021-07-20 17:05 ` enometh at meer dot net
@ 2021-07-20 19:35 ` cvs-commit at gcc dot gnu.org
  2021-07-20 19:38 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-20 19:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #15 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:124eaa50e0a34f5f89572c1aa812c50979da58fc

commit r12-2421-g124eaa50e0a34f5f89572c1aa812c50979da58fc
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jul 20 18:15:48 2021 +0100

    libstdc++: Fix create_directories to resolve symlinks [PR101510]

    When filesystem__create_directories checks to see if the path already
    exists and resovles to a directory, it uses filesystem::symlink_status,
    which means it reports an error if the path is a symlink. It should use
    filesystem::status, so that the target directory is detected, and no
    error is reported.

    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

    libstdc++-v3/ChangeLog:

            PR libstdc++/101510
            * src/c++17/fs_ops.cc (fs::create_directories): Use status
            instead of symlink_status.
            * src/filesystem/ops.cc (fs::create_directories): Likewise.
            * testsuite/27_io/filesystem/operations/create_directories.cc:
            * testsuite/27_io/filesystem/operations/create_directory.cc: Do
            not test with symlinks on Windows.
            *
testsuite/experimental/filesystem/operations/create_directories.cc:
            * testsuite/experimental/filesystem/operations/create_directory.cc:
            Do not test with symlinks on Windows.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (15 preceding siblings ...)
  2021-07-20 19:35 ` cvs-commit at gcc dot gnu.org
@ 2021-07-20 19:38 ` redi at gcc dot gnu.org
  2021-07-21  1:47 ` enometh at meer dot net
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-20 19:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #16 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk now, I'll backport it too, but not in time for 11.2

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (16 preceding siblings ...)
  2021-07-20 19:38 ` redi at gcc dot gnu.org
@ 2021-07-21  1:47 ` enometh at meer dot net
  2021-08-11 15:42 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: enometh at meer dot net @ 2021-07-21  1:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #17 from Madhu <enometh at meer dot net> ---
*  "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
<bug-101510-34102-c424azDJT7@http.gcc.gnu.org/bugzilla/>
Wrote on Tue, 20 Jul 2021 19:38:18 +0000

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510
> Fixed on trunk now, I'll backport it too, but not in time for 11.2

Thanks!

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (17 preceding siblings ...)
  2021-07-21  1:47 ` enometh at meer dot net
@ 2021-08-11 15:42 ` cvs-commit at gcc dot gnu.org
  2021-08-11 15:42 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11 15:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #18 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:c5f17274aabe61bb0193b8b68283c1f1da5ee699

commit r11-8849-gc5f17274aabe61bb0193b8b68283c1f1da5ee699
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jul 20 12:35:37 2021 +0100

    libstdc++: Add more tests for filesystem::create_directory [PR101510]

    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

    libstdc++-v3/ChangeLog:

            PR libstdc++/101510
            * src/c++17/fs_ops.cc (create_dir): Adjust whitespace.
            * testsuite/27_io/filesystem/operations/create_directory.cc:
            Test creating directory with name of existing symlink to
            directory.
            * testsuite/experimental/filesystem/operations/create_directory.cc:
            Likewise.

    (cherry picked from commit 0c4ae4ff46b1d7633f1e06f57d348b5817b8f640)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (18 preceding siblings ...)
  2021-08-11 15:42 ` cvs-commit at gcc dot gnu.org
@ 2021-08-11 15:42 ` cvs-commit at gcc dot gnu.org
  2021-08-11 16:35 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11 15:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #19 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:bde28c60c70079416dd2181f882c0694e019eaef

commit r11-8850-gbde28c60c70079416dd2181f882c0694e019eaef
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jul 20 18:15:48 2021 +0100

    libstdc++: Fix create_directories to resolve symlinks [PR101510]

    When filesystem__create_directories checks to see if the path already
    exists and resolves to a directory, it uses filesystem::symlink_status,
    which means it reports an error if the path is a symlink. It should use
    filesystem::status, so that the target directory is detected, and no
    error is reported.

    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

    libstdc++-v3/ChangeLog:

            PR libstdc++/101510
            * src/c++17/fs_ops.cc (fs::create_directories): Use status
            instead of symlink_status.
            * src/filesystem/ops.cc (fs::create_directories): Likewise.
            * testsuite/27_io/filesystem/operations/create_directories.cc:
            Check symlink to existing directory.
            * testsuite/27_io/filesystem/operations/create_directory.cc: Do
            not test with symlinks on Windows.
            *
testsuite/experimental/filesystem/operations/create_directories.cc:
            Check symlink to existing directory.
            * testsuite/experimental/filesystem/operations/create_directory.cc:
            Do not test with symlinks on Windows.

    (cherry picked from commit 124eaa50e0a34f5f89572c1aa812c50979da58fc)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (19 preceding siblings ...)
  2021-08-11 15:42 ` cvs-commit at gcc dot gnu.org
@ 2021-08-11 16:35 ` cvs-commit at gcc dot gnu.org
  2021-08-11 16:35 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11 16:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #20 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:f28d0e3a39246767b5fcdbe5c2bc005a45253246

commit r10-10030-gf28d0e3a39246767b5fcdbe5c2bc005a45253246
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jul 20 12:35:37 2021 +0100

    libstdc++: Add more tests for filesystem::create_directory [PR101510]

    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

    libstdc++-v3/ChangeLog:

            PR libstdc++/101510
            * src/c++17/fs_ops.cc (create_dir): Adjust whitespace.
            * testsuite/27_io/filesystem/operations/create_directory.cc:
            Test creating directory with name of existing symlink to
            directory.
            * testsuite/experimental/filesystem/operations/create_directory.cc:
            Likewise.

    (cherry picked from commit 0c4ae4ff46b1d7633f1e06f57d348b5817b8f640)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (20 preceding siblings ...)
  2021-08-11 16:35 ` cvs-commit at gcc dot gnu.org
@ 2021-08-11 16:35 ` cvs-commit at gcc dot gnu.org
  2021-08-11 22:50 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11 16:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #21 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:86bdcd21a1be008df28648b185c12221d917a166

commit r10-10031-g86bdcd21a1be008df28648b185c12221d917a166
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jul 20 18:15:48 2021 +0100

    libstdc++: Fix create_directories to resolve symlinks [PR101510]

    When filesystem__create_directories checks to see if the path already
    exists and resolves to a directory, it uses filesystem::symlink_status,
    which means it reports an error if the path is a symlink. It should use
    filesystem::status, so that the target directory is detected, and no
    error is reported.

    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

    libstdc++-v3/ChangeLog:

            PR libstdc++/101510
            * src/c++17/fs_ops.cc (fs::create_directories): Use status
            instead of symlink_status.
            * src/filesystem/ops.cc (fs::create_directories): Likewise.
            * testsuite/27_io/filesystem/operations/create_directories.cc:
            Check symlink to existing directory.
            * testsuite/27_io/filesystem/operations/create_directory.cc: Do
            not test with symlinks on Windows.
            *
testsuite/experimental/filesystem/operations/create_directories.cc:
            Check symlink to existing directory.
            * testsuite/experimental/filesystem/operations/create_directory.cc:
            Do not test with symlinks on Windows.

    (cherry picked from commit 124eaa50e0a34f5f89572c1aa812c50979da58fc)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (21 preceding siblings ...)
  2021-08-11 16:35 ` cvs-commit at gcc dot gnu.org
@ 2021-08-11 22:50 ` cvs-commit at gcc dot gnu.org
  2021-08-11 22:50 ` cvs-commit at gcc dot gnu.org
  2021-08-11 22:53 ` redi at gcc dot gnu.org
  24 siblings, 0 replies; 26+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11 22:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #22 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:1a5cc427fbc796fd97218b3d9b80b6a22268893a

commit r9-9668-g1a5cc427fbc796fd97218b3d9b80b6a22268893a
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jul 20 12:35:37 2021 +0100

    libstdc++: Add more tests for filesystem::create_directory [PR101510]

    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

    libstdc++-v3/ChangeLog:

            PR libstdc++/101510
            * src/c++17/fs_ops.cc (create_dir): Adjust whitespace.
            * testsuite/27_io/filesystem/operations/create_directory.cc:
            Test creating directory with name of existing symlink to
            directory.
            * testsuite/experimental/filesystem/operations/create_directory.cc:
            Likewise.

    (cherry picked from commit 0c4ae4ff46b1d7633f1e06f57d348b5817b8f640)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (22 preceding siblings ...)
  2021-08-11 22:50 ` cvs-commit at gcc dot gnu.org
@ 2021-08-11 22:50 ` cvs-commit at gcc dot gnu.org
  2021-08-11 22:53 ` redi at gcc dot gnu.org
  24 siblings, 0 replies; 26+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11 22:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

--- Comment #23 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:f8ac77533951d79d4e6a65841aa30293b2f11fdd

commit r9-9669-gf8ac77533951d79d4e6a65841aa30293b2f11fdd
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jul 20 18:15:48 2021 +0100

    libstdc++: Fix create_directories to resolve symlinks [PR101510]

    When filesystem__create_directories checks to see if the path already
    exists and resolves to a directory, it uses filesystem::symlink_status,
    which means it reports an error if the path is a symlink. It should use
    filesystem::status, so that the target directory is detected, and no
    error is reported.

    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

    libstdc++-v3/ChangeLog:

            PR libstdc++/101510
            * src/c++17/fs_ops.cc (fs::create_directories): Use status
            instead of symlink_status.
            * src/filesystem/ops.cc (fs::create_directories): Likewise.
            * testsuite/27_io/filesystem/operations/create_directories.cc:
            Check symlink to existing directory.
            * testsuite/27_io/filesystem/operations/create_directory.cc: Do
            not test with symlinks on Windows.
            *
testsuite/experimental/filesystem/operations/create_directories.cc:
            Check symlink to existing directory.
            * testsuite/experimental/filesystem/operations/create_directory.cc:
            Do not test with symlinks on Windows.

    (cherry picked from commit 124eaa50e0a34f5f89572c1aa812c50979da58fc)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug libstdc++/101510] std::filesystem::create_directory  on an existing symlink to a directory
  2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
                   ` (23 preceding siblings ...)
  2021-08-11 22:50 ` cvs-commit at gcc dot gnu.org
@ 2021-08-11 22:53 ` redi at gcc dot gnu.org
  24 siblings, 0 replies; 26+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-11 22:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.5
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #24 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 9.5, 10.4 and 11.3, thanks for the report.

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2021-08-11 22:53 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19 12:35 [Bug c++/101510] New: std::filesystem::create_directory on an existing symlink to a directory enometh at meer dot net
2021-07-19 22:44 ` [Bug libstdc++/101510] " redi at gcc dot gnu.org
2021-07-20 11:43 ` redi at gcc dot gnu.org
2021-07-20 11:46 ` redi at gcc dot gnu.org
2021-07-20 11:58 ` cvs-commit at gcc dot gnu.org
2021-07-20 12:01 ` redi at gcc dot gnu.org
2021-07-20 15:55 ` enometh at meer dot net
2021-07-20 16:00 ` redi at gcc dot gnu.org
2021-07-20 16:20 ` enometh at meer dot net
2021-07-20 16:25 ` redi at gcc dot gnu.org
2021-07-20 16:40 ` enometh at meer dot net
2021-07-20 16:53 ` redi at gcc dot gnu.org
2021-07-20 16:57 ` enometh at meer dot net
2021-07-20 16:58 ` redi at gcc dot gnu.org
2021-07-20 16:59 ` redi at gcc dot gnu.org
2021-07-20 17:05 ` enometh at meer dot net
2021-07-20 19:35 ` cvs-commit at gcc dot gnu.org
2021-07-20 19:38 ` redi at gcc dot gnu.org
2021-07-21  1:47 ` enometh at meer dot net
2021-08-11 15:42 ` cvs-commit at gcc dot gnu.org
2021-08-11 15:42 ` cvs-commit at gcc dot gnu.org
2021-08-11 16:35 ` cvs-commit at gcc dot gnu.org
2021-08-11 16:35 ` cvs-commit at gcc dot gnu.org
2021-08-11 22:50 ` cvs-commit at gcc dot gnu.org
2021-08-11 22:50 ` cvs-commit at gcc dot gnu.org
2021-08-11 22:53 ` redi at gcc dot gnu.org

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).