]> git.lizzy.rs Git - rust.git/commitdiff
std: use LFS readdir64_r on Linux
authorJosh Stone <cuviper@gmail.com>
Mon, 15 Feb 2016 00:24:02 +0000 (16:24 -0800)
committerJosh Stone <cuviper@gmail.com>
Mon, 15 Feb 2016 03:11:39 +0000 (19:11 -0800)
src/libstd/sys/unix/fs.rs

index ab8b700e193e2061b361e5ac5336240421785c2e..a2ff0d8e1d1ce538196595d9a3e6e046da2111a3 100644 (file)
@@ -15,7 +15,7 @@
 use ffi::{CString, CStr, OsString, OsStr};
 use fmt;
 use io::{self, Error, ErrorKind, SeekFrom};
-use libc::{self, dirent, c_int, mode_t};
+use libc::{self, c_int, mode_t};
 use mem;
 use path::{Path, PathBuf};
 use ptr;
 use sys_common::{AsInner, FromInner};
 
 #[cfg(target_os = "linux")]
-use libc::{stat64, fstat64, lstat64, off64_t, ftruncate64, lseek64};
+use libc::{stat64, fstat64, lstat64, off64_t, ftruncate64, lseek64, dirent64, readdir64_r};
 #[cfg(not(target_os = "linux"))]
 use libc::{stat as stat64, fstat as fstat64, lstat as lstat64, off_t as off64_t,
-           ftruncate as ftruncate64, lseek as lseek64};
+           ftruncate as ftruncate64, lseek as lseek64, dirent as dirent64};
+#[cfg(not(any(target_os = "linux", target_os = "solaris")))]
+use libc::{readdir_r as readdir64_r};
 
 pub struct File(FileDesc);
 
@@ -49,7 +51,7 @@ unsafe impl Send for Dir {}
 unsafe impl Sync for Dir {}
 
 pub struct DirEntry {
-    entry: dirent,
+    entry: dirent64,
     root: Arc<PathBuf>,
     // We need to store an owned copy of the directory name
     // on Solaris because a) it uses a zero-length array to
@@ -224,7 +226,7 @@ fn next(&mut self) -> Option<io::Result<DirEntry>> {
             };
             let mut entry_ptr = ptr::null_mut();
             loop {
-                if libc::readdir_r(self.dirp.0, &mut ret.entry, &mut entry_ptr) != 0 {
+                if readdir64_r(self.dirp.0, &mut ret.entry, &mut entry_ptr) != 0 {
                     return Some(Err(Error::last_os_error()))
                 }
                 if entry_ptr.is_null() {