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

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