This is the mail archive of the
mailing list for the libstdc++ project.
Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 16 Sep 2015 23:17:27 +0100
- Subject: Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.
- Authentication-results: sourceware.org; auth=none
- References: <20150911142140 dot GL2631 at redhat dot com> <55F311D2 dot 8050405 at gmail dot com> <CAH6eHdTjPFof-+ENBLytMsD2AU+6m2WoU020bwGsFLBen4s=yg at mail dot gmail dot com> <55F469CF dot 9010503 at gmail dot com> <20150916144207 dot GY2631 at redhat dot com> <55F9A8A8 dot 3060502 at gmail dot com> <20150916185844 dot GD2631 at redhat dot com> <55F9E75F dot 10602 at gmail dot com>
On 16/09/15 16:04 -0600, Martin Sebor wrote:
Tested powerpc64le-linux, x86_64-dragonfly4.1 and x86_64-netbsd5.1,
do you see any reason not to commit this for now?
I see only a couple of potential problems: a missing test for
PATH_MAX in the unlikely event it's not defined (or is obscenely
In the current patch _GLIBCXX_USE_REALPATH won't be defined unless:
#elif _XOPEN_VERSION >= 700 || defined(PATH_MAX)
so if it's defined and _XOPEN_VERSION < 700 then we know PATH_MAX must
be defined (otherwise _GLIBCXX_USE_REALPATH wouldn't be).
large), and a missing check to avoid infinite loops due to symlinks.
I thought about keeping track of where I'd been while expanding
symlinks, but then realised this will do it:
if (!exists(pa, ec))
// else we can assume no unresolvable symlink loops
If there's a symlink loop then exists(pa) will fail with ELOOP, and we
won't try to resolve it by hand.
And then after each step in the while(!cmpts.empty()) loop I also have
a check for !exists(result, ec), which should even handle the case
where the filesystem changes after the initial exists() call so that a
loop is introduced while we're canonicalising the path.
Any improvements such as hardcoding checks for specific versions of
Solaris or the BSDs are QoI, and this is only an experimental TS, so I
don't want to spend the rest of stage 1 working on one function :-)
My main obstacle to writing good tests right now is having some way to
create and destroy files safely in the tests. It's hard to test
functions like is_symlink() without first creating a symlink in a
known location, and also removing it again cleanly so the next
testsuite run doesn't fail if the file is already present.
One option would be to have libstdc++-v3/testsuite/Makefile create a
new sub-directory as a sandbox for filesystem tests, removing it if it
already exists. Then the tests can put anything they like in that new
dir without fear of trashing the user's files elsewhere on the FS!
I don't know how you feel about Tcl but writing a filesystem.exp
and adding a new "dg-fs" API would let each test can set up the
directory structure it needs.
My Tcl is very weak, but if that's the right approach then I can try