1
1
use { Result , NixPath } ;
2
2
use errno:: Errno ;
3
- #[ cfg( not( target_os = "redox" ) ) ]
4
- use libc:: c_uint;
5
- use libc:: { self , c_int, c_char, size_t, ssize_t} ;
3
+ use libc:: { self , c_int, c_uint, c_char, size_t, ssize_t} ;
6
4
use sys:: stat:: Mode ;
7
5
#[ cfg( not( target_os = "redox" ) ) ]
8
6
use std:: os:: raw;
@@ -162,7 +160,8 @@ libc_bitflags!(
162
160
163
161
pub fn open < P : ?Sized + NixPath > ( path : & P , oflag : OFlag , mode : Mode ) -> Result < RawFd > {
164
162
let fd = path. with_nix_path ( |cstr| {
165
- unsafe { libc:: open ( cstr. as_ptr ( ) , oflag. bits ( ) , mode. bits ( ) ) }
163
+ let modebits = mode. bits ( ) as c_uint ;
164
+ unsafe { libc:: open ( cstr. as_ptr ( ) , oflag. bits ( ) , modebits) }
166
165
} ) ?;
167
166
168
167
Errno :: result ( fd)
@@ -171,7 +170,8 @@ pub fn open<P: ?Sized + NixPath>(path: &P, oflag: OFlag, mode: Mode) -> Result<R
171
170
#[ cfg( not( target_os = "redox" ) ) ]
172
171
pub fn openat < P : ?Sized + NixPath > ( dirfd : RawFd , path : & P , oflag : OFlag , mode : Mode ) -> Result < RawFd > {
173
172
let fd = path. with_nix_path ( |cstr| {
174
- unsafe { libc:: openat ( dirfd, cstr. as_ptr ( ) , oflag. bits ( ) , mode. bits ( ) ) }
173
+ let modebits = c_uint:: from ( mode. bits ( ) ) ;
174
+ unsafe { libc:: openat ( dirfd, cstr. as_ptr ( ) , oflag. bits ( ) , modebits) }
175
175
} ) ?;
176
176
Errno :: result ( fd)
177
177
}
0 commit comments