Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/env/log_fd/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ pub struct LogFd(RawFd);
impl LogFd {
/// Opens a file with the given `path`.
pub fn open<P: ?Sized + NixPath>(path: &P, perm: Permission) -> IoResult<Self> {
let flags = OFlag::from(perm) | OFlag::O_CLOEXEC;
// Permission 644
let mode = Mode::S_IRUSR | Mode::S_IWUSR | Mode::S_IRGRP | Mode::S_IROTH;
fail_point!("log_fd::open::fadvise_dontneed", |_| {
let fd =
LogFd(fcntl::open(path, perm.into(), mode).map_err(|e| from_nix_error(e, "open"))?);
let fd = LogFd(fcntl::open(path, flags, mode).map_err(|e| from_nix_error(e, "open"))?);
#[cfg(target_os = "linux")]
unsafe {
extern crate libc;
Expand All @@ -54,14 +54,14 @@ impl LogFd {
Ok(fd)
});
Ok(LogFd(
fcntl::open(path, perm.into(), mode).map_err(|e| from_nix_error(e, "open"))?,
fcntl::open(path, flags, mode).map_err(|e| from_nix_error(e, "open"))?,
))
}

/// Opens a file with the given `path`. The specified file will be created
/// first if not exists.
pub fn create<P: ?Sized + NixPath>(path: &P) -> IoResult<Self> {
let flags = OFlag::O_RDWR | OFlag::O_CREAT;
let flags = OFlag::O_RDWR | OFlag::O_CREAT | OFlag::O_CLOEXEC;
// Permission 644
let mode = Mode::S_IRUSR | Mode::S_IWUSR | Mode::S_IRGRP | Mode::S_IROTH;
let fd = fcntl::open(path, flags, mode).map_err(|e| from_nix_error(e, "open"))?;
Expand Down
Loading