@@ -15,7 +15,7 @@ use os::unix::prelude::*;
1515use ffi:: { CString , CStr , OsString , OsStr } ;
1616use fmt;
1717use io:: { self , Error , ErrorKind , SeekFrom } ;
18- use libc:: { self , dirent , c_int, off_t , mode_t} ;
18+ use libc:: { self , c_int, mode_t} ;
1919use mem;
2020use path:: { Path , PathBuf } ;
2121use ptr;
@@ -26,9 +26,12 @@ use sys::{cvt, cvt_r};
2626use sys_common:: { AsInner , FromInner } ;
2727
2828#[ cfg( target_os = "linux" ) ]
29- use libc:: { stat64, fstat64, lstat64} ;
29+ use libc:: { stat64, fstat64, lstat64, off64_t , ftruncate64 , lseek64 , dirent64 , readdir64_r , open64 } ;
3030#[ 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} ;
3235
3336pub struct File ( FileDesc ) ;
3437
@@ -48,7 +51,7 @@ unsafe impl Send for Dir {}
4851unsafe impl Sync for Dir { }
4952
5053pub struct DirEntry {
51- entry : dirent ,
54+ entry : dirent64 ,
5255 root : Arc < PathBuf > ,
5356 // We need to store an owned copy of the directory name
5457 // on Solaris because a) it uses a zero-length array to
@@ -223,7 +226,7 @@ impl Iterator for ReadDir {
223226 } ;
224227 let mut entry_ptr = ptr:: null_mut ( ) ;
225228 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 {
227230 return Some ( Err ( Error :: last_os_error ( ) ) )
228231 }
229232 if entry_ptr. is_null ( ) {
@@ -394,7 +397,7 @@ impl File {
394397 try!( opts. get_creation_mode ( ) ) |
395398 ( opts. custom_flags as c_int & !libc:: O_ACCMODE ) ;
396399 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 )
398401 } ) ) ;
399402 let fd = FileDesc :: new ( fd) ;
400403
@@ -443,7 +446,7 @@ impl File {
443446
444447 pub fn truncate ( & self , size : u64 ) -> io:: Result < ( ) > {
445448 try!( cvt_r ( || unsafe {
446- libc :: ftruncate ( self . 0 . raw ( ) , size as libc :: off_t )
449+ ftruncate64 ( self . 0 . raw ( ) , size as off64_t )
447450 } ) ) ;
448451 Ok ( ( ) )
449452 }
@@ -460,11 +463,11 @@ impl File {
460463
461464 pub fn seek ( & self , pos : SeekFrom ) -> io:: Result < u64 > {
462465 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 ) ,
466469 } ;
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) } ) ) ;
468471 Ok ( n as u64 )
469472 }
470473
0 commit comments