[PATCH] D135849: [llvm] Return canonical virtual path from `RedirectingFileSystem`

Ben Langmuir via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 3 09:52:51 PDT 2023


benlangmuir added a comment.

> You mean diagnosing whenever the spelling in the VFS definition differs from its realpath?

Right, this would be ideal, but may be too expensive in practice.

> How could we make that work with symlinks in place?

Ah right, we are intentionally allowing symlinks in the VFS path (e.g. Foo.framework/Headers) because we don't correctly handle symlink resolution in the VFS itself.

You can get the canonical spelling of a symlink in a couple of ways: you can readdir the parent directory and find all case-insensitive matches.  If there is only 1, that's the spelling, if there are more than 1  then it's a case-sensitive filesystem and the original path must be correct.  Another way that is OS-specific is on Darwin you can `open(..., O_SYMLINK)` the path component to open the symlink itself and then `fcntl(..., F_GETPATH, ...)` to get its realpath.  Both of these approaches require handling each component of the path individually, though each step is cacheable.  Not sure if there are any better ways.

As I said, not sure we can afford to diagnose this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135849/new/

https://reviews.llvm.org/D135849



More information about the cfe-commits mailing list