Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert common syscalls to safe I/O types #1863

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::errno::Errno;
use crate::fcntl::{self, OFlag};
use crate::sys;
use crate::{sys, AsDirFd};
use crate::{Error, NixPath, Result};
use cfg_if::cfg_if;
use std::ffi;
Expand Down Expand Up @@ -39,18 +39,18 @@ impl Dir {
mode: sys::stat::Mode,
) -> Result<Self> {
let fd = fcntl::open(path, oflag, mode)?;
Dir::from_fd(fd)
Dir::from_fd(fd.into_raw_fd())
SUPERCILEX marked this conversation as resolved.
Show resolved Hide resolved
}

/// Opens the given path as with `fcntl::openat`.
pub fn openat<P: ?Sized + NixPath>(
dirfd: RawFd,
pub fn openat<Fd: AsDirFd, P: ?Sized + NixPath>(
dirfd: Fd,
path: &P,
oflag: OFlag,
mode: sys::stat::Mode,
) -> Result<Self> {
let fd = fcntl::openat(dirfd, path, oflag, mode)?;
Dir::from_fd(fd)
Dir::from_fd(fd.into_raw_fd())
}

/// Converts from a descriptor-based object, closing the descriptor on success or failure.
Expand Down
Loading