about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-01-14 14:19:09 -0500
committerTavian Barnes <tavianator@tavianator.com>2022-01-21 07:59:14 -0500
commit3eeb3ca40732ac56a9c5a9e4d9dc961644409db2 (patch)
treeb2e5f538ca573a9f5e6fe215f2e5c49270bb67b9
parentbc04a4eac47dcdc9feb3061dcc683e9d420227ab (diff)
fs: Use readdir() instead of readdir_r() on Android
Bionic also guarantees that readdir() is thread-safe enough.
-rw-r--r--library/std/src/sys/unix/fs.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs
index d1bd1f6d0eb..1617188ca60 100644
--- a/library/std/src/sys/unix/fs.rs
+++ b/library/std/src/sys/unix/fs.rs
@@ -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",