If the ExternalFS has already remapped a path then the
RedirectingFileSystem should not change it to the originally provided
path. This fixes the original path always being used if multiple VFS
overlays were provided and the path wasn't found in the highest (ie.
first in the chain).
This also renames IsVFSMapped to ExposesExternalVFSPath and only
sets it if UseExternalName is true. This flag then represents that the
Status has an external path that's different from its virtual path.
Right now the contained path is still the external path, but further PRs
will change this to *always* be the virtual path. Clients that need the
external can then request it specifically.
Note that even though ExposesExternalVFSPath isn't set for all
VFS-mapped paths, IsVFSMapped was only being used by a hack in
FileManager that was specific to module searching. In that case
UseExternalNames is always true and so that hack still applies.
Resolves rdar://90578880 and llvm-project#53306.
An incremental patch you could try would be:
... dropping all the other changes.
This limits the redirection hack to only apply when a RedirectingFS is involved (leaving until later the fine-tuning of when IsVFSMapped gets set). If this smaller change still causes a test failure, it might be easier to reason about why / how to fix it / be sure that the fix is sound.
Eventually we might want something like:
I imagine that's not going to succeed yet due to the CWD behaviour in the VFSes, but as a speculative patch it might help track down whatever the problem is.