[llvm] [SystemZ][z/OS] Query if a file is text and set the text flag accordingly (PR #109664)

kadir çetinkaya via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 10:22:12 PDT 2024


================
@@ -325,8 +325,15 @@ ErrorOr<Status> RealFileSystem::status(const Twine &Path) {
 ErrorOr<std::unique_ptr<File>>
 RealFileSystem::openFileForRead(const Twine &Name) {
   SmallString<256> RealName, Storage;
+  auto OpenFlags = sys::fs::OF_None;
+#ifdef __MVS__
+  // If the file is tagged with a text ccsid, it may require autoconversion.
----------------
kadircet wrote:

thanks for the explanation!

sorry if I am being dense, but I still don't understand why it has to happen in this layer, rather than in https://github.com/llvm/llvm-project/blob/main/llvm/lib/Support/Unix/Path.inc#L1035-L1114:
- it already has access to all of this information
- it has logic that's already dealing with autoconversions
- you can check if we're trying to open a file that exists, even better we've already stat'd the file, so you can check if it contains the tag, without performing any extra system calls on the way.

I assume you're already trying to make sure logic in https://github.com/llvm/llvm-project/blob/main/llvm/lib/Support/Unix/Path.inc#L1098-L1105 triggers by inferring `OF_TEXT` flag for all callers here.

What I am asking for is, why we're not performing that inference at the layer that's shared for all such filesystem operations, i.e. https://github.com/llvm/llvm-project/blob/main/llvm/lib/Support/Unix/Path.inc#L1035-L1114. What breaks/doesn't work?

https://github.com/llvm/llvm-project/pull/109664


More information about the llvm-commits mailing list