Skip to content

Commit 46a79c5

Browse files
committed
fix: imports
1 parent 8735162 commit 46a79c5

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

src/unistd.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ use crate::fcntl::AtFlags;
2020
use crate::fcntl::OFlag;
2121
#[cfg(all(feature = "fs", bsd))]
2222
use crate::sys::stat::FileFlag;
23-
#[cfg(feature = "fs")]
24-
use crate::sys::stat::Mode;
2523
use crate::{Error, NixPath, Result};
2624
#[cfg(not(target_os = "redox"))]
2725
use cfg_if::cfg_if;
28-
use libc::{
29-
c_char, c_int, c_long, c_uint, gid_t, mode_t, off_t, pid_t, size_t, uid_t,
30-
};
26+
use libc::{c_char, c_int, c_long, c_uint, gid_t, off_t, pid_t, size_t, uid_t};
3127
use std::convert::Infallible;
3228
#[cfg(not(target_os = "redox"))]
3329
use std::ffi::CString;
@@ -428,7 +424,7 @@ feature! {
428424
///
429425
/// * [`dup2()`]
430426
/// * [`dup2_raw()`]
431-
/// * [`dup3()`]
427+
/// * `dup3()`
432428
#[inline]
433429
pub fn dup<Fd: std::os::fd::AsFd>(oldfd: Fd) -> Result<std::os::fd::OwnedFd> {
434430
use std::os::fd::AsRawFd;
@@ -480,8 +476,7 @@ pub fn dup2_stderr<Fd: std::os::fd::AsFd>(fd: Fd) -> Result<()> {
480476
/// more detail on the exact behavior of this function.
481477
///
482478
/// This function does not allow you to duplicate `oldfd` with any file descriptor
483-
/// you want, to do that, use [`dup2_raw()`]#[inline]
484-
.
479+
/// you want, to do that, use [`dup2_raw()`].
485480
///
486481
/// # Reference
487482
///
@@ -590,6 +585,9 @@ pub unsafe fn dup2_raw<Fd1: std::os::fd::AsFd, Fd2: std::os::fd::IntoRawFd>(oldf
590585
///
591586
/// This function behaves similar to `dup2()` but allows for flags to be
592587
/// specified.
588+
///
589+
/// This function does not allow you to duplicate `oldfd` with any file descriptor
590+
/// you want, to do that, use [`dup3_raw()`].
593591
#[cfg(any(
594592
netbsdlike,
595593
solarish,
@@ -706,9 +704,9 @@ pub fn fchdir<Fd: std::os::fd::AsFd>(dirfd: Fd) -> Result<()> {
706704
/// }
707705
/// ```
708706
#[inline]
709-
pub fn mkdir<P: ?Sized + NixPath>(path: &P, mode: Mode) -> Result<()> {
707+
pub fn mkdir<P: ?Sized + NixPath>(path: &P, mode: crate::sys::stat::Mode) -> Result<()> {
710708
let res = path.with_nix_path(|cstr| unsafe {
711-
libc::mkdir(cstr.as_ptr(), mode.bits() as mode_t)
709+
libc::mkdir(cstr.as_ptr(), mode.bits() as libc::mode_t)
712710
})?;
713711

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

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

776774
let res = path.with_nix_path(|cstr| unsafe {
777-
libc::mkfifoat(dirfd.as_fd().as_raw_fd(), cstr.as_ptr(), mode.bits() as mode_t)
775+
libc::mkfifoat(dirfd.as_fd().as_raw_fd(), cstr.as_ptr(), mode.bits() as libc::mode_t)
778776
})?;
779777

780778
Errno::result(res).map(drop)

test/sys/test_socket.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ pub fn test_named_unixdomain() {
16931693
// It should be safe considering that s3 will be open within this test
16941694
let s3 = unsafe { std::os::fd::BorrowedFd::borrow_raw(s3) };
16951695
let mut buf = [0; 5];
1696-
read(&s3, &mut buf).unwrap();
1696+
read(s3, &mut buf).unwrap();
16971697
thr.join().unwrap();
16981698

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

0 commit comments

Comments
 (0)