This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Map ERROR_BAD_PATHNAME to errc::no_such_file_or_directory on windows
ClosedPublic

Authored by mstorsjo on Feb 27 2021, 2:50 PM.

Details

Summary

Opening a path like \\server (without a trailing share name and path) produces this error, while opening e.g. \\server\share (for a nonexistent server/share) produces ERROR_BAD_NETPATH (which already is mapped).

This happens in some testcases (in fs.op.proximate); as proximate() calls weakly_canonical() on the inputs, weakly_canonical() checks whether the path exists or not. When the error code wasn't recognized (it mapped to errc::invalid_argument), the stat operation wasn't conclusive and weakly_canonical() errored out. With the proper error code mapping, this isn't considered an error, just a nonexistent path, and weakly_canonical() can proceed.

This roughly matches what MS STL does - it doesn't have ERROR_BAD_PATHNAME in its error code mapping table, but it checks for this error code specifically in the return of their correspondence of the stat function.

Diff Detail

Event Timeline

mstorsjo requested review of this revision.Feb 27 2021, 2:50 PM
mstorsjo created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2021, 2:50 PM
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald Transcript
curdeius accepted this revision.Feb 28 2021, 1:41 AM
curdeius added a subscriber: curdeius.

LGTM.

ldionne accepted this revision.Mar 4 2021, 3:54 PM
This revision is now accepted and ready to land.Mar 4 2021, 3:54 PM