@@ -15,7 +15,7 @@ use os::unix::prelude::*;
15
15
use ffi:: { CString , CStr , OsString , OsStr } ;
16
16
use fmt;
17
17
use io:: { self , Error , ErrorKind , SeekFrom } ;
18
- use libc:: { self , dirent , c_int, off_t , mode_t} ;
18
+ use libc:: { self , c_int, mode_t} ;
19
19
use mem;
20
20
use path:: { Path , PathBuf } ;
21
21
use ptr;
@@ -26,9 +26,12 @@ use sys::{cvt, cvt_r};
26
26
use sys_common:: { AsInner , FromInner } ;
27
27
28
28
#[ cfg( target_os = "linux" ) ]
29
- use libc:: { stat64, fstat64, lstat64} ;
29
+ use libc:: { stat64, fstat64, lstat64, off64_t , ftruncate64 , lseek64 , dirent64 , readdir64_r , open64 } ;
30
30
#[ cfg( not( target_os = "linux" ) ) ]
31
- use libc:: { stat as stat64, fstat as fstat64, lstat as lstat64} ;
31
+ use libc:: { stat as stat64, fstat as fstat64, lstat as lstat64, off_t as off64_t,
32
+ ftruncate as ftruncate64, lseek as lseek64, dirent as dirent64, open as open64} ;
33
+ #[ cfg( not( any( target_os = "linux" , target_os = "solaris" ) ) ) ]
34
+ use libc:: { readdir_r as readdir64_r} ;
32
35
33
36
pub struct File ( FileDesc ) ;
34
37
@@ -48,7 +51,7 @@ unsafe impl Send for Dir {}
48
51
unsafe impl Sync for Dir { }
49
52
50
53
pub struct DirEntry {
51
- entry : dirent ,
54
+ entry : dirent64 ,
52
55
root : Arc < PathBuf > ,
53
56
// We need to store an owned copy of the directory name
54
57
// on Solaris because a) it uses a zero-length array to
@@ -223,7 +226,7 @@ impl Iterator for ReadDir {
223
226
} ;
224
227
let mut entry_ptr = ptr:: null_mut ( ) ;
225
228
loop {
226
- 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 {
227
230
return Some ( Err ( Error :: last_os_error ( ) ) )
228
231
}
229
232
if entry_ptr. is_null ( ) {
@@ -394,7 +397,7 @@ impl File {
394
397
try!( opts. get_creation_mode ( ) ) |
395
398
( opts. custom_flags as c_int & !libc:: O_ACCMODE ) ;
396
399
let fd = try!( cvt_r ( || unsafe {
397
- libc :: open ( path. as_ptr ( ) , flags, opts. mode as c_int )
400
+ open64 ( path. as_ptr ( ) , flags, opts. mode as c_int )
398
401
} ) ) ;
399
402
let fd = FileDesc :: new ( fd) ;
400
403
@@ -443,7 +446,7 @@ impl File {
443
446
444
447
pub fn truncate ( & self , size : u64 ) -> io:: Result < ( ) > {
445
448
try!( cvt_r ( || unsafe {
446
- libc :: ftruncate ( self . 0 . raw ( ) , size as libc :: off_t )
449
+ ftruncate64 ( self . 0 . raw ( ) , size as off64_t )
447
450
} ) ) ;
448
451
Ok ( ( ) )
449
452
}
@@ -460,11 +463,11 @@ impl File {
460
463
461
464
pub fn seek ( & self , pos : SeekFrom ) -> io:: Result < u64 > {
462
465
let ( whence, pos) = match pos {
463
- SeekFrom :: Start ( off) => ( libc:: SEEK_SET , off as off_t ) ,
464
- SeekFrom :: End ( off) => ( libc:: SEEK_END , off as off_t ) ,
465
- SeekFrom :: Current ( off) => ( libc:: SEEK_CUR , off as off_t ) ,
466
+ SeekFrom :: Start ( off) => ( libc:: SEEK_SET , off as off64_t ) ,
467
+ SeekFrom :: End ( off) => ( libc:: SEEK_END , off as off64_t ) ,
468
+ SeekFrom :: Current ( off) => ( libc:: SEEK_CUR , off as off64_t ) ,
466
469
} ;
467
- let n = try!( cvt ( unsafe { libc :: lseek ( self . 0 . raw ( ) , pos, whence) } ) ) ;
470
+ let n = try!( cvt ( unsafe { lseek64 ( self . 0 . raw ( ) , pos, whence) } ) ) ;
468
471
Ok ( n as u64 )
469
472
}
470
473
0 commit comments