Skip to content

Commit

Permalink
fix: imports
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveLauC committed Jun 10, 2024
1 parent 45b552b commit edcb0dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
26 changes: 12 additions & 14 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ use crate::fcntl::AtFlags;
use crate::fcntl::OFlag;
#[cfg(all(feature = "fs", bsd))]
use crate::sys::stat::FileFlag;
#[cfg(feature = "fs")]
use crate::sys::stat::Mode;
use crate::{Error, NixPath, Result};
#[cfg(not(target_os = "redox"))]
use cfg_if::cfg_if;
use libc::{
c_char, c_int, c_long, c_uint, gid_t, mode_t, off_t, pid_t, size_t, uid_t,
};
use libc::{c_char, c_int, c_long, c_uint, gid_t, off_t, pid_t, size_t, uid_t};
use std::convert::Infallible;
#[cfg(not(target_os = "redox"))]
use std::ffi::CString;
Expand Down Expand Up @@ -428,7 +424,7 @@ feature! {
///
/// * [`dup2()`]
/// * [`dup2_raw()`]
/// * [`dup3()`]
/// * `dup3()`
#[inline]
pub fn dup<Fd: std::os::fd::AsFd>(oldfd: Fd) -> Result<std::os::fd::OwnedFd> {
use std::os::fd::AsRawFd;
Expand Down Expand Up @@ -480,8 +476,7 @@ pub fn dup2_stderr<Fd: std::os::fd::AsFd>(fd: Fd) -> Result<()> {
/// more detail on the exact behavior of this function.
///
/// This function does not allow you to duplicate `oldfd` with any file descriptor
/// you want, to do that, use [`dup2_raw()`]#[inline]
.
/// you want, to do that, use [`dup2_raw()`].
///
/// # Reference
///
Expand Down Expand Up @@ -590,6 +585,9 @@ pub unsafe fn dup2_raw<Fd1: std::os::fd::AsFd, Fd2: std::os::fd::IntoRawFd>(oldf
///
/// This function behaves similar to `dup2()` but allows for flags to be
/// specified.
///
/// This function does not allow you to duplicate `oldfd` with any file descriptor
/// you want, to do that, use [`dup3_raw()`].
#[cfg(any(
netbsdlike,
solarish,
Expand Down Expand Up @@ -706,9 +704,9 @@ pub fn fchdir<Fd: std::os::fd::AsFd>(dirfd: Fd) -> Result<()> {
/// }
/// ```
#[inline]
pub fn mkdir<P: ?Sized + NixPath>(path: &P, mode: Mode) -> Result<()> {
pub fn mkdir<P: ?Sized + NixPath>(path: &P, mode: crate::sys::stat::Mode) -> Result<()> {
let res = path.with_nix_path(|cstr| unsafe {
libc::mkdir(cstr.as_ptr(), mode.bits() as mode_t)
libc::mkdir(cstr.as_ptr(), mode.bits() as libc::mode_t)
})?;

Errno::result(res).map(drop)
Expand Down Expand Up @@ -745,9 +743,9 @@ pub fn mkdir<P: ?Sized + NixPath>(path: &P, mode: Mode) -> Result<()> {
/// ```
#[inline]
#[cfg(not(target_os = "redox"))] // RedoxFS does not support fifo yet
pub fn mkfifo<P: ?Sized + NixPath>(path: &P, mode: Mode) -> Result<()> {
pub fn mkfifo<P: ?Sized + NixPath>(path: &P, mode: crate::sys::stat::Mode) -> Result<()> {
let res = path.with_nix_path(|cstr| unsafe {
libc::mkfifo(cstr.as_ptr(), mode.bits() as mode_t)
libc::mkfifo(cstr.as_ptr(), mode.bits() as libc::mode_t)
})?;

Errno::result(res).map(drop)
Expand All @@ -769,12 +767,12 @@ pub fn mkfifo<P: ?Sized + NixPath>(path: &P, mode: Mode) -> Result<()> {
pub fn mkfifoat<Fd: std::os::fd::AsFd, P: ?Sized + NixPath>(
dirfd: Fd,
path: &P,
mode: Mode,
mode: crate::sys::stat::Mode,
) -> Result<()> {
use std::os::fd::AsRawFd;

let res = path.with_nix_path(|cstr| unsafe {
libc::mkfifoat(dirfd.as_fd().as_raw_fd(), cstr.as_ptr(), mode.bits() as mode_t)
libc::mkfifoat(dirfd.as_fd().as_raw_fd(), cstr.as_ptr(), mode.bits() as libc::mode_t)
})?;

Errno::result(res).map(drop)
Expand Down
2 changes: 1 addition & 1 deletion test/sys/test_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ pub fn test_named_unixdomain() {
// It should be safe considering that s3 will be open within this test
let s3 = unsafe { std::os::fd::BorrowedFd::borrow_raw(s3) };
let mut buf = [0; 5];
read(&s3, &mut buf).unwrap();
read(s3, &mut buf).unwrap();
thr.join().unwrap();

assert_eq!(&buf[..], b"hello");
Expand Down

0 comments on commit edcb0dd

Please sign in to comment.