From 9bdd92118c815965da45c44356cfccd0c76da6ab Mon Sep 17 00:00:00 2001
From: Thalia Archibald <thalia@archibald.dev>
Date: Wed, 26 Feb 2025 23:34:39 -0800
Subject: [PATCH 1/2] Erase non-pal sys platform paths

---
 src/tools/miri/tests/ui.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/tools/miri/tests/ui.rs b/src/tools/miri/tests/ui.rs
index 85ce38f57d637..c37cf15d40ab0 100644
--- a/src/tools/miri/tests/ui.rs
+++ b/src/tools/miri/tests/ui.rs
@@ -270,13 +270,13 @@ regexes! {
     // erase thread caller ids
     r"call [0-9]+"                  => "call ID",
     // erase platform module paths
-    "sys::pal::[a-z]+::"                  => "sys::pal::PLATFORM::",
+    r"\bsys::([a-z_]+)::[a-z]+::"   => "sys::$1::PLATFORM::",
     // Windows file paths
     r"\\"                           => "/",
     // erase Rust stdlib path
     "[^ \n`]*/(rust[^/]*|checkout)/library/" => "RUSTLIB/",
     // erase platform file paths
-    "sys/pal/[a-z]+/"                    => "sys/pal/PLATFORM/",
+    r"\bsys/([a-z_]+)/[a-z]+\b"     => "sys/$1/PLATFORM",
     // erase paths into the crate registry
     r"[^ ]*/\.?cargo/registry/.*/(.*\.rs)"  => "CARGO_REGISTRY/.../$1",
 }

From 685619e4c93e3b30da36b013ab62c4cf8931b432 Mon Sep 17 00:00:00 2001
From: Thalia Archibald <thalia@archibald.dev>
Date: Tue, 25 Feb 2025 17:45:30 -0800
Subject: [PATCH 2/2] Move fs into sys

---
 .../{sys_common/fs.rs => sys/fs/common.rs}    |  0
 .../sys/{pal/hermit/fs.rs => fs/hermit.rs}    | 12 ++++----
 library/std/src/sys/fs/mod.rs                 | 28 +++++++++++++++++++
 .../src/sys/{pal/solid/fs.rs => fs/solid.rs}  |  6 ++--
 .../src/sys/{pal/uefi/fs.rs => fs/uefi.rs}    |  0
 .../src/sys/{pal/unix/fs.rs => fs/unix.rs}    | 14 ++++++----
 .../src/sys/{pal/unix/fs => fs/unix}/tests.rs |  2 +-
 .../unsupported/fs.rs => fs/unsupported.rs}   |  0
 .../src/sys/{pal/wasi/fs.rs => fs/wasi.rs}    |  6 ++--
 .../sys/{pal/windows/fs.rs => fs/windows.rs}  | 12 ++++----
 .../fs => fs/windows}/remove_dir_all.rs       |  2 +-
 library/std/src/sys/mod.rs                    |  1 +
 library/std/src/sys/pal/hermit/mod.rs         |  1 -
 library/std/src/sys/pal/sgx/mod.rs            |  2 --
 library/std/src/sys/pal/solid/mod.rs          |  1 -
 library/std/src/sys/pal/solid/time.rs         |  2 +-
 library/std/src/sys/pal/teeos/mod.rs          |  2 --
 library/std/src/sys/pal/uefi/mod.rs           |  1 -
 library/std/src/sys/pal/unix/mod.rs           |  1 -
 library/std/src/sys/pal/unsupported/mod.rs    |  1 -
 library/std/src/sys/pal/wasi/mod.rs           |  1 -
 library/std/src/sys/pal/wasip2/mod.rs         |  2 --
 library/std/src/sys/pal/wasm/mod.rs           |  2 --
 library/std/src/sys/pal/windows/mod.rs        |  3 +-
 library/std/src/sys/pal/xous/mod.rs           |  2 --
 library/std/src/sys/pal/zkvm/mod.rs           |  2 --
 library/std/src/sys_common/mod.rs             |  1 -
 .../tests/fail/shims/fs/isolated_file.stderr  | 18 ++++++------
 28 files changed, 70 insertions(+), 55 deletions(-)
 rename library/std/src/{sys_common/fs.rs => sys/fs/common.rs} (100%)
 rename library/std/src/sys/{pal/hermit/fs.rs => fs/hermit.rs} (99%)
 create mode 100644 library/std/src/sys/fs/mod.rs
 rename library/std/src/sys/{pal/solid/fs.rs => fs/solid.rs} (99%)
 rename library/std/src/sys/{pal/uefi/fs.rs => fs/uefi.rs} (100%)
 rename library/std/src/sys/{pal/unix/fs.rs => fs/unix.rs} (99%)
 rename library/std/src/sys/{pal/unix/fs => fs/unix}/tests.rs (98%)
 rename library/std/src/sys/{pal/unsupported/fs.rs => fs/unsupported.rs} (100%)
 rename library/std/src/sys/{pal/wasi/fs.rs => fs/wasi.rs} (99%)
 rename library/std/src/sys/{pal/windows/fs.rs => fs/windows.rs} (99%)
 rename library/std/src/sys/{pal/windows/fs => fs/windows}/remove_dir_all.rs (99%)

diff --git a/library/std/src/sys_common/fs.rs b/library/std/src/sys/fs/common.rs
similarity index 100%
rename from library/std/src/sys_common/fs.rs
rename to library/std/src/sys/fs/common.rs
diff --git a/library/std/src/sys/pal/hermit/fs.rs b/library/std/src/sys/fs/hermit.rs
similarity index 99%
rename from library/std/src/sys/pal/hermit/fs.rs
rename to library/std/src/sys/fs/hermit.rs
index d4bf84dc1854c..e9339ff261c99 100644
--- a/library/std/src/sys/pal/hermit/fs.rs
+++ b/library/std/src/sys/fs/hermit.rs
@@ -1,18 +1,18 @@
-use super::fd::FileDesc;
-use super::hermit_abi::{
-    self, DT_DIR, DT_LNK, DT_REG, DT_UNKNOWN, O_APPEND, O_CREAT, O_DIRECTORY, O_EXCL, O_RDONLY,
-    O_RDWR, O_TRUNC, O_WRONLY, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, dirent64, stat as stat_struct,
-};
 use crate::ffi::{CStr, OsStr, OsString, c_char};
 use crate::io::{self, BorrowedCursor, Error, ErrorKind, IoSlice, IoSliceMut, SeekFrom};
 use crate::os::hermit::ffi::OsStringExt;
+use crate::os::hermit::hermit_abi::{
+    self, DT_DIR, DT_LNK, DT_REG, DT_UNKNOWN, O_APPEND, O_CREAT, O_DIRECTORY, O_EXCL, O_RDONLY,
+    O_RDWR, O_TRUNC, O_WRONLY, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, dirent64, stat as stat_struct,
+};
 use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
 use crate::path::{Path, PathBuf};
 use crate::sync::Arc;
 use crate::sys::common::small_c_string::run_path_with_cstr;
+pub use crate::sys::fs::common::{copy, exists};
+use crate::sys::pal::fd::FileDesc;
 use crate::sys::time::SystemTime;
 use crate::sys::{cvt, unsupported};
-pub use crate::sys_common::fs::{copy, exists};
 use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
 use crate::{fmt, mem};
 
diff --git a/library/std/src/sys/fs/mod.rs b/library/std/src/sys/fs/mod.rs
new file mode 100644
index 0000000000000..c2e19eb393a16
--- /dev/null
+++ b/library/std/src/sys/fs/mod.rs
@@ -0,0 +1,28 @@
+#![deny(unsafe_op_in_unsafe_fn)]
+
+pub mod common;
+
+cfg_if::cfg_if! {
+    if #[cfg(target_family = "unix")] {
+        mod unix;
+        pub use unix::*;
+    } else if #[cfg(target_os = "windows")] {
+        mod windows;
+        pub use windows::*;
+    } else if #[cfg(target_os = "hermit")] {
+        mod hermit;
+        pub use hermit::*;
+    } else if #[cfg(target_os = "solid_asp3")] {
+        mod solid;
+        pub use solid::*;
+    } else if #[cfg(target_os = "uefi")] {
+        mod uefi;
+        pub use uefi::*;
+    } else if #[cfg(target_os = "wasi")] {
+        mod wasi;
+        pub use wasi::*;
+    } else {
+        mod unsupported;
+        pub use unsupported::*;
+    }
+}
diff --git a/library/std/src/sys/pal/solid/fs.rs b/library/std/src/sys/fs/solid.rs
similarity index 99%
rename from library/std/src/sys/pal/solid/fs.rs
rename to library/std/src/sys/fs/solid.rs
index 4e741943283d0..39de933b7248b 100644
--- a/library/std/src/sys/pal/solid/fs.rs
+++ b/library/std/src/sys/fs/solid.rs
@@ -1,4 +1,5 @@
-use super::{abi, error};
+#![allow(dead_code)]
+
 use crate::ffi::{CStr, CString, OsStr, OsString};
 use crate::fmt;
 use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom};
@@ -7,9 +8,10 @@ use crate::os::raw::{c_int, c_short};
 use crate::os::solid::ffi::OsStrExt;
 use crate::path::{Path, PathBuf};
 use crate::sync::Arc;
+pub use crate::sys::fs::common::exists;
+use crate::sys::pal::{abi, error};
 use crate::sys::time::SystemTime;
 use crate::sys::unsupported;
-pub use crate::sys_common::fs::exists;
 use crate::sys_common::ignore_notfound;
 
 type CIntNotMinusOne = core::num::niche_types::NotAllOnes<c_int>;
diff --git a/library/std/src/sys/pal/uefi/fs.rs b/library/std/src/sys/fs/uefi.rs
similarity index 100%
rename from library/std/src/sys/pal/uefi/fs.rs
rename to library/std/src/sys/fs/uefi.rs
diff --git a/library/std/src/sys/pal/unix/fs.rs b/library/std/src/sys/fs/unix.rs
similarity index 99%
rename from library/std/src/sys/pal/unix/fs.rs
rename to library/std/src/sys/fs/unix.rs
index 20ba915af1364..914971934bfb0 100644
--- a/library/std/src/sys/pal/unix/fs.rs
+++ b/library/std/src/sys/fs/unix.rs
@@ -1,3 +1,5 @@
+#![allow(nonstandard_style)]
+#![allow(unsafe_op_in_unsafe_fn)]
 // miri has some special hacks here that make things unused.
 #![cfg_attr(miri, allow(unused))]
 
@@ -79,13 +81,13 @@ use crate::path::{Path, PathBuf};
 use crate::sync::Arc;
 use crate::sys::common::small_c_string::run_path_with_cstr;
 use crate::sys::fd::FileDesc;
+pub use crate::sys::fs::common::exists;
 use crate::sys::time::SystemTime;
 #[cfg(all(target_os = "linux", target_env = "gnu"))]
 use crate::sys::weak::syscall;
 #[cfg(target_os = "android")]
 use crate::sys::weak::weak;
 use crate::sys::{cvt, cvt_r};
-pub use crate::sys_common::fs::exists;
 use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
 use crate::{mem, ptr};
 
@@ -699,6 +701,8 @@ impl Iterator for ReadDir {
         target_os = "hurd",
     ))]
     fn next(&mut self) -> Option<io::Result<DirEntry>> {
+        use crate::sys::os::{errno, set_errno};
+
         if self.end_of_stream {
             return None;
         }
@@ -710,7 +714,7 @@ impl Iterator for ReadDir {
                 // with unlimited or variable NAME_MAX. Many modern platforms guarantee
                 // thread safety for readdir() as long an individual DIR* is not accessed
                 // concurrently, which is sufficient for Rust.
-                super::os::set_errno(0);
+                set_errno(0);
                 let entry_ptr: *const dirent64 = readdir64(self.inner.dirp.0);
                 if entry_ptr.is_null() {
                     // We either encountered an error, or reached the end. Either way,
@@ -719,7 +723,7 @@ impl Iterator for ReadDir {
 
                     // To distinguish between errors and end-of-directory, we had to clear
                     // errno beforehand to check for an error now.
-                    return match super::os::errno() {
+                    return match errno() {
                         0 => None,
                         e => Some(Err(Error::from_raw_os_error(e))),
                     };
@@ -1932,7 +1936,7 @@ pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
 
 fn open_from(from: &Path) -> io::Result<(crate::fs::File, crate::fs::Metadata)> {
     use crate::fs::File;
-    use crate::sys_common::fs::NOT_FILE_ERROR;
+    use crate::sys::fs::common::NOT_FILE_ERROR;
 
     let reader = File::open(from)?;
     let metadata = reader.metadata()?;
@@ -2151,7 +2155,7 @@ pub use remove_dir_impl::remove_dir_all;
     miri
 ))]
 mod remove_dir_impl {
-    pub use crate::sys_common::fs::remove_dir_all;
+    pub use crate::sys::fs::common::remove_dir_all;
 }
 
 // Modern implementation using openat(), unlinkat() and fdopendir()
diff --git a/library/std/src/sys/pal/unix/fs/tests.rs b/library/std/src/sys/fs/unix/tests.rs
similarity index 98%
rename from library/std/src/sys/pal/unix/fs/tests.rs
rename to library/std/src/sys/fs/unix/tests.rs
index 71be3472148b0..8875a318db7d2 100644
--- a/library/std/src/sys/pal/unix/fs/tests.rs
+++ b/library/std/src/sys/fs/unix/tests.rs
@@ -1,4 +1,4 @@
-use crate::sys::pal::unix::fs::FilePermissions;
+use crate::sys::fs::FilePermissions;
 
 #[test]
 fn test_debug_permissions() {
diff --git a/library/std/src/sys/pal/unsupported/fs.rs b/library/std/src/sys/fs/unsupported.rs
similarity index 100%
rename from library/std/src/sys/pal/unsupported/fs.rs
rename to library/std/src/sys/fs/unsupported.rs
diff --git a/library/std/src/sys/pal/wasi/fs.rs b/library/std/src/sys/fs/wasi.rs
similarity index 99%
rename from library/std/src/sys/pal/wasi/fs.rs
rename to library/std/src/sys/fs/wasi.rs
index 6d7d125fc4d4c..773040571bc97 100644
--- a/library/std/src/sys/pal/wasi/fs.rs
+++ b/library/std/src/sys/fs/wasi.rs
@@ -1,6 +1,3 @@
-#![forbid(unsafe_op_in_unsafe_fn)]
-
-use super::fd::WasiFd;
 use crate::ffi::{CStr, OsStr, OsString};
 use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom};
 use crate::mem::{self, ManuallyDrop};
@@ -10,9 +7,10 @@ use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd
 use crate::path::{Path, PathBuf};
 use crate::sync::Arc;
 use crate::sys::common::small_c_string::run_path_with_cstr;
+use crate::sys::fd::WasiFd;
+pub use crate::sys::fs::common::exists;
 use crate::sys::time::SystemTime;
 use crate::sys::unsupported;
-pub use crate::sys_common::fs::exists;
 use crate::sys_common::{AsInner, FromInner, IntoInner, ignore_notfound};
 use crate::{fmt, iter, ptr};
 
diff --git a/library/std/src/sys/pal/windows/fs.rs b/library/std/src/sys/fs/windows.rs
similarity index 99%
rename from library/std/src/sys/pal/windows/fs.rs
rename to library/std/src/sys/fs/windows.rs
index 8fce0496d80c9..362e64abf1ac3 100644
--- a/library/std/src/sys/pal/windows/fs.rs
+++ b/library/std/src/sys/fs/windows.rs
@@ -1,5 +1,5 @@
-use super::api::{self, WinError, set_file_information_by_handle};
-use super::{IoResult, to_u16s};
+#![allow(nonstandard_style)]
+
 use crate::alloc::{Layout, alloc, dealloc};
 use crate::borrow::Cow;
 use crate::ffi::{OsStr, OsString, c_void};
@@ -10,6 +10,8 @@ use crate::os::windows::prelude::*;
 use crate::path::{Path, PathBuf};
 use crate::sync::Arc;
 use crate::sys::handle::Handle;
+use crate::sys::pal::api::{self, WinError, set_file_information_by_handle};
+use crate::sys::pal::{IoResult, fill_utf16_buf, to_u16s, truncate_utf16_at_nul};
 use crate::sys::path::maybe_verbatim;
 use crate::sys::time::SystemTime;
 use crate::sys::{Align8, c, cvt};
@@ -167,7 +169,7 @@ impl DirEntry {
     }
 
     pub fn file_name(&self) -> OsString {
-        let filename = super::truncate_utf16_at_nul(&self.data.cFileName);
+        let filename = truncate_utf16_at_nul(&self.data.cFileName);
         OsString::from_wide(filename)
     }
 
@@ -695,7 +697,7 @@ impl File {
                 // Turn `\??\` into `\\?\` (a verbatim path).
                 subst[1] = b'\\' as u16;
                 // Attempt to convert to a more user-friendly path.
-                let user = super::args::from_wide_to_user_path(
+                let user = crate::sys::args::from_wide_to_user_path(
                     subst.iter().copied().chain([0]).collect(),
                 )?;
                 Ok(PathBuf::from(OsString::from_wide(user.strip_suffix(&[0]).unwrap_or(&user))))
@@ -1492,7 +1494,7 @@ pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> {
 }
 
 fn get_path(f: &File) -> io::Result<PathBuf> {
-    super::fill_utf16_buf(
+    fill_utf16_buf(
         |buf, sz| unsafe {
             c::GetFinalPathNameByHandleW(f.handle.as_raw_handle(), buf, sz, c::VOLUME_NAME_DOS)
         },
diff --git a/library/std/src/sys/pal/windows/fs/remove_dir_all.rs b/library/std/src/sys/fs/windows/remove_dir_all.rs
similarity index 99%
rename from library/std/src/sys/pal/windows/fs/remove_dir_all.rs
rename to library/std/src/sys/fs/windows/remove_dir_all.rs
index 9416049da78f8..f51eced84164f 100644
--- a/library/std/src/sys/pal/windows/fs/remove_dir_all.rs
+++ b/library/std/src/sys/fs/windows/remove_dir_all.rs
@@ -33,7 +33,7 @@ use core::sync::atomic::{AtomicU32, Ordering};
 
 use super::{AsRawHandle, DirBuff, File, FromRawHandle};
 use crate::sys::c;
-use crate::sys::pal::windows::api::WinError;
+use crate::sys::pal::api::WinError;
 use crate::thread;
 
 // The maximum number of times to spin when waiting for deletes to complete.
diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs
index 1032fcba5e2e1..9f8c1e53131a6 100644
--- a/library/std/src/sys/mod.rs
+++ b/library/std/src/sys/mod.rs
@@ -12,6 +12,7 @@ pub mod anonymous_pipe;
 pub mod backtrace;
 pub mod cmath;
 pub mod exit_guard;
+pub mod fs;
 pub mod io;
 pub mod net;
 pub mod os_str;
diff --git a/library/std/src/sys/pal/hermit/mod.rs b/library/std/src/sys/pal/hermit/mod.rs
index 21cbac643bbec..5605c92db5ba3 100644
--- a/library/std/src/sys/pal/hermit/mod.rs
+++ b/library/std/src/sys/pal/hermit/mod.rs
@@ -21,7 +21,6 @@ use crate::os::raw::c_char;
 pub mod args;
 pub mod env;
 pub mod fd;
-pub mod fs;
 pub mod futex;
 pub mod os;
 #[path = "../unsupported/pipe.rs"]
diff --git a/library/std/src/sys/pal/sgx/mod.rs b/library/std/src/sys/pal/sgx/mod.rs
index 37ca6b08c950b..16aa5ab116afe 100644
--- a/library/std/src/sys/pal/sgx/mod.rs
+++ b/library/std/src/sys/pal/sgx/mod.rs
@@ -12,8 +12,6 @@ pub mod abi;
 pub mod args;
 pub mod env;
 pub mod fd;
-#[path = "../unsupported/fs.rs"]
-pub mod fs;
 mod libunwind_integration;
 pub mod os;
 #[path = "../unsupported/pipe.rs"]
diff --git a/library/std/src/sys/pal/solid/mod.rs b/library/std/src/sys/pal/solid/mod.rs
index 06af7bfade059..2c3e50ed59483 100644
--- a/library/std/src/sys/pal/solid/mod.rs
+++ b/library/std/src/sys/pal/solid/mod.rs
@@ -22,7 +22,6 @@ pub mod env;
 // `error` is `pub(crate)` so that it can be accessed by `itron/error.rs` as
 // `crate::sys::error`
 pub(crate) mod error;
-pub mod fs;
 pub mod os;
 #[path = "../unsupported/pipe.rs"]
 pub mod pipe;
diff --git a/library/std/src/sys/pal/solid/time.rs b/library/std/src/sys/pal/solid/time.rs
index 3f9bbb0b63cdb..c39d715c6a6f6 100644
--- a/library/std/src/sys/pal/solid/time.rs
+++ b/library/std/src/sys/pal/solid/time.rs
@@ -35,7 +35,7 @@ impl SystemTime {
         SystemTime(t)
     }
 
-    pub(super) fn from_time_t(t: abi::time_t) -> Self {
+    pub fn from_time_t(t: abi::time_t) -> Self {
         Self(t)
     }
 
diff --git a/library/std/src/sys/pal/teeos/mod.rs b/library/std/src/sys/pal/teeos/mod.rs
index 3632524157db9..2aeaf20134ff2 100644
--- a/library/std/src/sys/pal/teeos/mod.rs
+++ b/library/std/src/sys/pal/teeos/mod.rs
@@ -11,8 +11,6 @@ pub mod args;
 #[path = "../unsupported/env.rs"]
 pub mod env;
 //pub mod fd;
-#[path = "../unsupported/fs.rs"]
-pub mod fs;
 pub mod os;
 #[path = "../unsupported/pipe.rs"]
 pub mod pipe;
diff --git a/library/std/src/sys/pal/uefi/mod.rs b/library/std/src/sys/pal/uefi/mod.rs
index 6a03e240c6bd4..3dc83f6f654b6 100644
--- a/library/std/src/sys/pal/uefi/mod.rs
+++ b/library/std/src/sys/pal/uefi/mod.rs
@@ -15,7 +15,6 @@
 
 pub mod args;
 pub mod env;
-pub mod fs;
 pub mod helpers;
 pub mod os;
 #[path = "../unsupported/pipe.rs"]
diff --git a/library/std/src/sys/pal/unix/mod.rs b/library/std/src/sys/pal/unix/mod.rs
index c0b56d8d2b28a..0565e3ecfb93b 100644
--- a/library/std/src/sys/pal/unix/mod.rs
+++ b/library/std/src/sys/pal/unix/mod.rs
@@ -9,7 +9,6 @@ pub mod weak;
 pub mod args;
 pub mod env;
 pub mod fd;
-pub mod fs;
 pub mod futex;
 #[cfg(any(target_os = "linux", target_os = "android"))]
 pub mod kernel_copy;
diff --git a/library/std/src/sys/pal/unsupported/mod.rs b/library/std/src/sys/pal/unsupported/mod.rs
index b1aaeb1b4c814..526e5008bd504 100644
--- a/library/std/src/sys/pal/unsupported/mod.rs
+++ b/library/std/src/sys/pal/unsupported/mod.rs
@@ -2,7 +2,6 @@
 
 pub mod args;
 pub mod env;
-pub mod fs;
 pub mod os;
 pub mod pipe;
 pub mod process;
diff --git a/library/std/src/sys/pal/wasi/mod.rs b/library/std/src/sys/pal/wasi/mod.rs
index f4588a60ea9a4..a5ae1f513dcba 100644
--- a/library/std/src/sys/pal/wasi/mod.rs
+++ b/library/std/src/sys/pal/wasi/mod.rs
@@ -16,7 +16,6 @@
 pub mod args;
 pub mod env;
 pub mod fd;
-pub mod fs;
 #[allow(unused)]
 #[path = "../wasm/atomics/futex.rs"]
 pub mod futex;
diff --git a/library/std/src/sys/pal/wasip2/mod.rs b/library/std/src/sys/pal/wasip2/mod.rs
index 72c9742b2e549..d4eb436967372 100644
--- a/library/std/src/sys/pal/wasip2/mod.rs
+++ b/library/std/src/sys/pal/wasip2/mod.rs
@@ -12,8 +12,6 @@ pub mod args;
 pub mod env;
 #[path = "../wasi/fd.rs"]
 pub mod fd;
-#[path = "../wasi/fs.rs"]
-pub mod fs;
 #[allow(unused)]
 #[path = "../wasm/atomics/futex.rs"]
 pub mod futex;
diff --git a/library/std/src/sys/pal/wasm/mod.rs b/library/std/src/sys/pal/wasm/mod.rs
index 32d59c4d0f7c4..cfadbdfe00cf6 100644
--- a/library/std/src/sys/pal/wasm/mod.rs
+++ b/library/std/src/sys/pal/wasm/mod.rs
@@ -19,8 +19,6 @@
 #[path = "../unsupported/args.rs"]
 pub mod args;
 pub mod env;
-#[path = "../unsupported/fs.rs"]
-pub mod fs;
 #[path = "../unsupported/os.rs"]
 pub mod os;
 #[path = "../unsupported/pipe.rs"]
diff --git a/library/std/src/sys/pal/windows/mod.rs b/library/std/src/sys/pal/windows/mod.rs
index 1eca346b76c2b..bed79af395b68 100644
--- a/library/std/src/sys/pal/windows/mod.rs
+++ b/library/std/src/sys/pal/windows/mod.rs
@@ -17,7 +17,6 @@ pub mod api;
 pub mod args;
 pub mod c;
 pub mod env;
-pub mod fs;
 #[cfg(not(target_vendor = "win7"))]
 pub mod futex;
 pub mod handle;
@@ -37,7 +36,7 @@ cfg_if::cfg_if! {
 }
 
 /// Map a [`Result<T, WinError>`] to [`io::Result<T>`](crate::io::Result<T>).
-trait IoResult<T> {
+pub trait IoResult<T> {
     fn io_result(self) -> crate::io::Result<T>;
 }
 impl<T> IoResult<T> for Result<T, api::WinError> {
diff --git a/library/std/src/sys/pal/xous/mod.rs b/library/std/src/sys/pal/xous/mod.rs
index 1bd0e67f37162..3022d717b4a58 100644
--- a/library/std/src/sys/pal/xous/mod.rs
+++ b/library/std/src/sys/pal/xous/mod.rs
@@ -3,8 +3,6 @@
 pub mod args;
 #[path = "../unsupported/env.rs"]
 pub mod env;
-#[path = "../unsupported/fs.rs"]
-pub mod fs;
 pub mod os;
 #[path = "../unsupported/pipe.rs"]
 pub mod pipe;
diff --git a/library/std/src/sys/pal/zkvm/mod.rs b/library/std/src/sys/pal/zkvm/mod.rs
index 8d8fe321f6615..ca5b479296def 100644
--- a/library/std/src/sys/pal/zkvm/mod.rs
+++ b/library/std/src/sys/pal/zkvm/mod.rs
@@ -14,8 +14,6 @@ pub mod abi;
 #[path = "../zkvm/args.rs"]
 pub mod args;
 pub mod env;
-#[path = "../unsupported/fs.rs"]
-pub mod fs;
 pub mod os;
 #[path = "../unsupported/pipe.rs"]
 pub mod pipe;
diff --git a/library/std/src/sys_common/mod.rs b/library/std/src/sys_common/mod.rs
index 4dc67d26bd8ff..2a5de7f66661c 100644
--- a/library/std/src/sys_common/mod.rs
+++ b/library/std/src/sys_common/mod.rs
@@ -20,7 +20,6 @@
 #[cfg(test)]
 mod tests;
 
-pub mod fs;
 pub mod process;
 pub mod wstr;
 pub mod wtf8;
diff --git a/src/tools/miri/tests/fail/shims/fs/isolated_file.stderr b/src/tools/miri/tests/fail/shims/fs/isolated_file.stderr
index e611d6e28f857..75167ab5b3877 100644
--- a/src/tools/miri/tests/fail/shims/fs/isolated_file.stderr
+++ b/src/tools/miri/tests/fail/shims/fs/isolated_file.stderr
@@ -1,5 +1,5 @@
 error: unsupported operation: `open` not available when isolation is enabled
-  --> RUSTLIB/std/src/sys/pal/PLATFORM/fs.rs:LL:CC
+  --> RUSTLIB/std/src/sys/fs/PLATFORM.rs:LL:CC
    |
 LL |         let fd = cvt_r(|| unsafe { open64(path.as_ptr(), flags, opts.mode as c_int) })?;
    |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `open` not available when isolation is enabled
@@ -7,14 +7,14 @@ LL |         let fd = cvt_r(|| unsafe { open64(path.as_ptr(), flags, opts.mode a
    = help: set `MIRIFLAGS=-Zmiri-disable-isolation` to disable isolation;
    = help: or set `MIRIFLAGS=-Zmiri-isolation-error=warn` to make Miri return an error code from isolated operations (if supported for that operation) and continue with a warning
    = note: BACKTRACE:
-   = note: inside closure at RUSTLIB/std/src/sys/pal/PLATFORM/fs.rs:LL:CC
-   = note: inside `std::sys::pal::PLATFORM::cvt_r::<i32, {closure@std::sys::pal::PLATFORM::fs::File::open_c::{closure#0}}>` at RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
-   = note: inside `std::sys::pal::PLATFORM::fs::File::open_c` at RUSTLIB/std/src/sys/pal/PLATFORM/fs.rs:LL:CC
-   = note: inside closure at RUSTLIB/std/src/sys/pal/PLATFORM/fs.rs:LL:CC
-   = note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr_stack::<std::sys::pal::PLATFORM::fs::File>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC
-   = note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr::<std::sys::pal::PLATFORM::fs::File>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC
-   = note: inside `std::sys::pal::PLATFORM::small_c_string::run_path_with_cstr::<std::sys::pal::PLATFORM::fs::File>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC
-   = note: inside `std::sys::pal::PLATFORM::fs::File::open` at RUSTLIB/std/src/sys/pal/PLATFORM/fs.rs:LL:CC
+   = note: inside closure at RUSTLIB/std/src/sys/fs/PLATFORM.rs:LL:CC
+   = note: inside `std::sys::pal::PLATFORM::cvt_r::<i32, {closure@std::sys::fs::PLATFORM::File::open_c::{closure#0}}>` at RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
+   = note: inside `std::sys::fs::PLATFORM::File::open_c` at RUSTLIB/std/src/sys/fs/PLATFORM.rs:LL:CC
+   = note: inside closure at RUSTLIB/std/src/sys/fs/PLATFORM.rs:LL:CC
+   = note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr_stack::<std::sys::fs::PLATFORM::File>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC
+   = note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr::<std::sys::fs::PLATFORM::File>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC
+   = note: inside `std::sys::pal::PLATFORM::small_c_string::run_path_with_cstr::<std::sys::fs::PLATFORM::File>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC
+   = note: inside `std::sys::fs::PLATFORM::File::open` at RUSTLIB/std/src/sys/fs/PLATFORM.rs:LL:CC
    = note: inside `std::fs::OpenOptions::_open` at RUSTLIB/std/src/fs.rs:LL:CC
    = note: inside `std::fs::OpenOptions::open::<&std::path::Path>` at RUSTLIB/std/src/fs.rs:LL:CC
    = note: inside `std::fs::File::open::<&str>` at RUSTLIB/std/src/fs.rs:LL:CC