The GNU/Hurd system does not define an arbitrary PATH_MAX limitation, the POSIX 2001 realpath extension can be used instead, and the size of symlinks can be determined.
Details
Diff Detail
- Repository
- rCXX libc++
Event Timeline
src/filesystem/operations.cpp | ||
---|---|---|
533 |
Probably not. I hope we don't.
That would be better IMO, and the only drawback is that we won't catch a GLIBC version released between 1996 and 2003 (which we don't care about). | |
535 | Oh... leave as-is then. |
src/filesystem/operations.cpp | ||
---|---|---|
1088 | I don't love this implementation. It requires an additional system call, and it opens us up to a TOCTOU bug. Otherwise, then we can call back on the lstat version, but we should do better error reporting when ret == size. |
src/filesystem/operations.cpp | ||
---|---|---|
535 | s/NULL/nullptr/ | |
536 | I think we can RAII this up like: std::unique_ptr<char, decltype(&::free)> hold(::realpath(p.c_str(), nullptr), &::free);` if (hold.get() == nullptr) return err.report(capture_errno()); return {hold.get()}; | |
1086 | I would like to see these two paths merged even further. How about: path __read_symlink(const path& p, error_code* ec) { ErrorHandler<path> err("read_symlink", ec, &p); #ifdef PATH_MAX struct NullDeleter { void operator()(void*) const {} }; const size_t size = PATH_MAX + 1; char stack_buff[size]; auto buff = std::unique_ptr<char[], NullDeleter>(stack_buff); #else StatT sb; if (::lstat(p.c_str(), &sb) == -1) { return err.report(capture_errno()); } const size_t size = sb.st_size + 1; auto buff = unique_ptr<char[]>(new char[size]); #endif ::ssize_t ret; if ((ret = ::readlink(p.c_str(), buff.get(), size)) == -1) { return err.report(capture_errno()); } _LIBCPP_ASSERT(ret <= size, "TODO"); _LIBCPP_ASSERT(ret > 0, "TODO"); buff[ret] = 0; return {buff.get()}; } | |
1109 | Use the StatT typedef we already have. |
Sorry for the delay. Committed as r351414. I'll look into merging it into the 8.0 release soon.
Is the extension available on old glibc's? Should that be #if _POSIX_VERSION >= 200112 && defined(__GLIBC__), or just #if _POSIX_VERSION >= 200112?