Skip to content

Commit fcf97ca

Browse files
committed
Convert mode byte by byte for open
1 parent 1f89ccd commit fcf97ca

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/fcntl.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use {Result, NixPath};
22
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};
64
use sys::stat::Mode;
75
#[cfg(not(target_os = "redox"))]
86
use std::os::raw;
@@ -162,7 +160,8 @@ libc_bitflags!(
162160

163161
pub fn open<P: ?Sized + NixPath>(path: &P, oflag: OFlag, mode: Mode) -> Result<RawFd> {
164162
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) }
166165
})?;
167166

168167
Errno::result(fd)
@@ -171,7 +170,8 @@ pub fn open<P: ?Sized + NixPath>(path: &P, oflag: OFlag, mode: Mode) -> Result<R
171170
#[cfg(not(target_os = "redox"))]
172171
pub fn openat<P: ?Sized + NixPath>(dirfd: RawFd, path: &P, oflag: OFlag, mode: Mode) -> Result<RawFd> {
173172
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) }
175175
})?;
176176
Errno::result(fd)
177177
}

0 commit comments

Comments
 (0)