mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
fs: Use readdir() instead of readdir_r() on Android
Bionic also guarantees that readdir() is thread-safe enough.
This commit is contained in:
parent
bc04a4eac4
commit
3eeb3ca407
@ -35,6 +35,7 @@ use libc::dirfd;
|
||||
#[cfg(any(target_os = "linux", target_os = "emscripten"))]
|
||||
use libc::fstatat64;
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "solaris",
|
||||
target_os = "fuchsia",
|
||||
target_os = "redox",
|
||||
@ -46,6 +47,7 @@ use libc::readdir64;
|
||||
#[cfg(any(target_os = "emscripten", target_os = "l4re"))]
|
||||
use libc::readdir64_r;
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "emscripten",
|
||||
target_os = "solaris",
|
||||
@ -211,6 +213,7 @@ struct InnerReadDir {
|
||||
pub struct ReadDir {
|
||||
inner: Arc<InnerReadDir>,
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "solaris",
|
||||
target_os = "illumos",
|
||||
@ -232,6 +235,7 @@ pub struct DirEntry {
|
||||
// readdir() (not readdir_r()), because a) struct dirent may use a flexible
|
||||
// array to store the name, b) it lives only until the next readdir() call.
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "solaris",
|
||||
target_os = "illumos",
|
||||
@ -459,6 +463,7 @@ impl Iterator for ReadDir {
|
||||
type Item = io::Result<DirEntry>;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "solaris",
|
||||
target_os = "fuchsia",
|
||||
@ -498,6 +503,7 @@ impl Iterator for ReadDir {
|
||||
}
|
||||
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "solaris",
|
||||
target_os = "fuchsia",
|
||||
@ -665,6 +671,7 @@ impl DirEntry {
|
||||
}
|
||||
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "solaris",
|
||||
target_os = "illumos",
|
||||
@ -675,6 +682,7 @@ impl DirEntry {
|
||||
unsafe { CStr::from_ptr(self.entry.d_name.as_ptr()) }
|
||||
}
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "solaris",
|
||||
target_os = "illumos",
|
||||
@ -1086,6 +1094,7 @@ pub fn readdir(p: &Path) -> io::Result<ReadDir> {
|
||||
Ok(ReadDir {
|
||||
inner: Arc::new(inner),
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "solaris",
|
||||
target_os = "illumos",
|
||||
@ -1622,6 +1631,7 @@ mod remove_dir_impl {
|
||||
ReadDir {
|
||||
inner: Arc::new(InnerReadDir { dirp, root: dummy_root }),
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "solaris",
|
||||
target_os = "illumos",
|
||||
|
Loading…
Reference in New Issue
Block a user