@@ -34,6 +34,15 @@ use libc::c_char;
34
34
use libc:: dirfd;
35
35
#[ cfg( any( target_os = "linux" , target_os = "emscripten" ) ) ]
36
36
use libc:: fstatat64;
37
+ #[ cfg( any(
38
+ target_os = "solaris" ,
39
+ target_os = "fuchsia" ,
40
+ target_os = "redox" ,
41
+ target_os = "illumos"
42
+ ) ) ]
43
+ use libc:: readdir as readdir64;
44
+ #[ cfg( target_os = "linux" ) ]
45
+ use libc:: readdir64;
37
46
#[ cfg( not( any(
38
47
target_os = "linux" ,
39
48
target_os = "emscripten" ,
@@ -60,9 +69,7 @@ use libc::{
60
69
lstat as lstat64, off_t as off64_t, open as open64, stat as stat64,
61
70
} ;
62
71
#[ cfg( any( target_os = "linux" , target_os = "emscripten" , target_os = "l4re" ) ) ]
63
- use libc:: {
64
- dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, readdir64_r, stat64,
65
- } ;
72
+ use libc:: { dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, stat64} ;
66
73
67
74
pub use crate :: sys_common:: fs:: { remove_dir_all, try_exists} ;
68
75
@@ -202,6 +209,7 @@ struct InnerReadDir {
202
209
pub struct ReadDir {
203
210
inner : Arc < InnerReadDir > ,
204
211
#[ cfg( not( any(
212
+ target_os = "linux" ,
205
213
target_os = "solaris" ,
206
214
target_os = "illumos" ,
207
215
target_os = "fuchsia" ,
@@ -223,6 +231,7 @@ pub struct DirEntry {
223
231
// array to store the name, b) its lifetime between readdir
224
232
// calls is not guaranteed.
225
233
#[ cfg( any(
234
+ target_os = "linux" ,
226
235
target_os = "solaris" ,
227
236
target_os = "illumos" ,
228
237
target_os = "fuchsia" ,
@@ -449,6 +458,7 @@ impl Iterator for ReadDir {
449
458
type Item = io:: Result < DirEntry > ;
450
459
451
460
#[ cfg( any(
461
+ target_os = "linux" ,
452
462
target_os = "solaris" ,
453
463
target_os = "fuchsia" ,
454
464
target_os = "redox" ,
@@ -464,7 +474,7 @@ impl Iterator for ReadDir {
464
474
// is safe to use in threaded applications and it is generally preferred
465
475
// over the readdir_r(3C) function.
466
476
super :: os:: set_errno ( 0 ) ;
467
- let entry_ptr = libc :: readdir ( self . inner . dirp . 0 ) ;
477
+ let entry_ptr = readdir64 ( self . inner . dirp . 0 ) ;
468
478
if entry_ptr. is_null ( ) {
469
479
// null can mean either the end is reached or an error occurred.
470
480
// So we had to clear errno beforehand to check for an error now.
@@ -492,6 +502,7 @@ impl Iterator for ReadDir {
492
502
}
493
503
494
504
#[ cfg( not( any(
505
+ target_os = "linux" ,
495
506
target_os = "solaris" ,
496
507
target_os = "fuchsia" ,
497
508
target_os = "redox" ,
@@ -647,7 +658,6 @@ impl DirEntry {
647
658
}
648
659
#[ cfg( any(
649
660
target_os = "android" ,
650
- target_os = "linux" ,
651
661
target_os = "emscripten" ,
652
662
target_os = "l4re" ,
653
663
target_os = "haiku" ,
@@ -658,6 +668,7 @@ impl DirEntry {
658
668
unsafe { CStr :: from_ptr ( self . entry . d_name . as_ptr ( ) ) . to_bytes ( ) }
659
669
}
660
670
#[ cfg( any(
671
+ target_os = "linux" ,
661
672
target_os = "solaris" ,
662
673
target_os = "illumos" ,
663
674
target_os = "fuchsia" ,
@@ -1068,6 +1079,7 @@ pub fn readdir(p: &Path) -> io::Result<ReadDir> {
1068
1079
Ok ( ReadDir {
1069
1080
inner : Arc :: new ( inner) ,
1070
1081
#[ cfg( not( any(
1082
+ target_os = "linux" ,
1071
1083
target_os = "solaris" ,
1072
1084
target_os = "illumos" ,
1073
1085
target_os = "fuchsia" ,
0 commit comments