Skip to content

Commit 8f2d7d9

Browse files
committed
std: use LFS readdir64_r on Linux
1 parent dcdfed4 commit 8f2d7d9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/libstd/sys/unix/fs.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use os::unix::prelude::*;
1515
use ffi::{CString, CStr, OsString, OsStr};
1616
use fmt;
1717
use io::{self, Error, ErrorKind, SeekFrom};
18-
use libc::{self, dirent, c_int, mode_t};
18+
use libc::{self, c_int, mode_t};
1919
use mem;
2020
use path::{Path, PathBuf};
2121
use ptr;
@@ -26,10 +26,12 @@ use sys::{cvt, cvt_r};
2626
use sys_common::{AsInner, FromInner};
2727

2828
#[cfg(target_os = "linux")]
29-
use libc::{stat64, fstat64, lstat64, off64_t, ftruncate64, lseek64};
29+
use libc::{stat64, fstat64, lstat64, off64_t, ftruncate64, lseek64, dirent64, readdir64_r};
3030
#[cfg(not(target_os = "linux"))]
3131
use libc::{stat as stat64, fstat as fstat64, lstat as lstat64, off_t as off64_t,
32-
ftruncate as ftruncate64, lseek as lseek64};
32+
ftruncate as ftruncate64, lseek as lseek64, dirent as dirent64};
33+
#[cfg(not(any(target_os = "linux", target_os = "solaris")))]
34+
use libc::{readdir_r as readdir64_r};
3335

3436
pub struct File(FileDesc);
3537

@@ -49,7 +51,7 @@ unsafe impl Send for Dir {}
4951
unsafe impl Sync for Dir {}
5052

5153
pub struct DirEntry {
52-
entry: dirent,
54+
entry: dirent64,
5355
root: Arc<PathBuf>,
5456
// We need to store an owned copy of the directory name
5557
// on Solaris because a) it uses a zero-length array to
@@ -224,7 +226,7 @@ impl Iterator for ReadDir {
224226
};
225227
let mut entry_ptr = ptr::null_mut();
226228
loop {
227-
if libc::readdir_r(self.dirp.0, &mut ret.entry, &mut entry_ptr) != 0 {
229+
if readdir64_r(self.dirp.0, &mut ret.entry, &mut entry_ptr) != 0 {
228230
return Some(Err(Error::last_os_error()))
229231
}
230232
if entry_ptr.is_null() {

0 commit comments

Comments
 (0)