Skip to content

Commit 60fe496

Browse files
authored
Rollup merge of rust-lang#94749 - RalfJung:remove-dir-all-miri, r=cuviper
remove_dir_all: use fallback implementation on Miri Fixes rust-lang/miri#1966 The new implementation requires `openat`, `unlinkat`, and `fdopendir`. These cannot easily be shimmed in Miri since libstd does not expose APIs corresponding to them. So for now it is probably easiest to just use the fallback code in Miri. Nobody should run Miri as root anyway...
2 parents 9702ad9 + b8b9a7e commit 60fe496

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

std/src/fs.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -2049,9 +2049,10 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
20492049
///
20502050
/// [changes]: io#platform-specific-behavior
20512051
///
2052-
/// On macOS before version 10.10 and REDOX this function is not protected against time-of-check to
2053-
/// time-of-use (TOCTOU) race conditions, and should not be used in security-sensitive code on
2054-
/// those platforms. All other platforms are protected.
2052+
/// On macOS before version 10.10 and REDOX, as well as when running in Miri for any target, this
2053+
/// function is not protected against time-of-check to time-of-use (TOCTOU) race conditions, and
2054+
/// should not be used in security-sensitive code on those platforms. All other platforms are
2055+
/// protected.
20552056
///
20562057
/// # Errors
20572058
///

std/src/sys/unix/fs.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1517,14 +1517,14 @@ pub fn chroot(dir: &Path) -> io::Result<()> {
15171517

15181518
pub use remove_dir_impl::remove_dir_all;
15191519

1520-
// Fallback for REDOX and ESP-IDF
1521-
#[cfg(any(target_os = "redox", target_os = "espidf"))]
1520+
// Fallback for REDOX and ESP-IDF (and Miri)
1521+
#[cfg(any(target_os = "redox", target_os = "espidf", miri))]
15221522
mod remove_dir_impl {
15231523
pub use crate::sys_common::fs::remove_dir_all;
15241524
}
15251525

15261526
// Modern implementation using openat(), unlinkat() and fdopendir()
1527-
#[cfg(not(any(target_os = "redox", target_os = "espidf")))]
1527+
#[cfg(not(any(target_os = "redox", target_os = "espidf", miri)))]
15281528
mod remove_dir_impl {
15291529
use super::{cstr, lstat, Dir, DirEntry, InnerReadDir, ReadDir};
15301530
use crate::ffi::CStr;

0 commit comments

Comments
 (0)