summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2020-05-31 15:17:16 -0600
committerAlan Somers <asomers@gmail.com>2020-05-31 19:07:15 -0600
commit1ae5dd8b16aed61958fd3ce488ed7fd459743652 (patch)
tree17c28555c9b2cd3db3741dcd28b7401d08ad3678 /src/sys
parent84e66d7a29234d16d62c5fa5bc5b66ad5504c2a2 (diff)
downloadnix-1ae5dd8b16aed61958fd3ce488ed7fd459743652.zip
Convert the crate to edition 2018
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/aio.rs37
-rw-r--r--src/sys/epoll.rs6
-rw-r--r--src/sys/event.rs3
-rw-r--r--src/sys/eventfd.rs4
-rw-r--r--src/sys/inotify.rs9
-rw-r--r--src/sys/ioctl/bsd.rs2
-rw-r--r--src/sys/ioctl/mod.rs6
-rw-r--r--src/sys/memfd.rs4
-rw-r--r--src/sys/mman.rs10
-rw-r--r--src/sys/ptrace/bsd.rs10
-rw-r--r--src/sys/ptrace/linux.rs10
-rw-r--r--src/sys/quota.rs4
-rw-r--r--src/sys/reboot.rs4
-rw-r--r--src/sys/select.rs14
-rw-r--r--src/sys/sendfile.rs7
-rw-r--r--src/sys/signal.rs14
-rw-r--r--src/sys/signalfd.rs8
-rw-r--r--src/sys/socket/addr.rs23
-rw-r--r--src/sys/socket/mod.rs14
-rw-r--r--src/sys/socket/sockopt.rs13
-rw-r--r--src/sys/stat.rs8
-rw-r--r--src/sys/statfs.rs9
-rw-r--r--src/sys/statvfs.rs5
-rw-r--r--src/sys/sysinfo.rs4
-rw-r--r--src/sys/termios.rs14
-rw-r--r--src/sys/uio.rs16
-rw-r--r--src/sys/wait.rs10
27 files changed, 113 insertions, 155 deletions
diff --git a/src/sys/aio.rs b/src/sys/aio.rs
index c912fc83..1afdb358 100644
--- a/src/sys/aio.rs
+++ b/src/sys/aio.rs
@@ -21,20 +21,19 @@
//! [`aio_cancel_all`](fn.aio_cancel_all.html), though the operating system may
//! not support this for all filesystems and devices.
-use {Error, Result};
-use errno::Errno;
+use crate::{Error, Result};
+use crate::errno::Errno;
use std::os::unix::io::RawFd;
use libc::{c_void, off_t, size_t};
-use libc;
use std::borrow::{Borrow, BorrowMut};
use std::fmt;
use std::fmt::Debug;
use std::marker::PhantomData;
use std::mem;
use std::ptr::{null, null_mut};
-use sys::signal::*;
+use crate::sys::signal::*;
use std::thread;
-use sys::time::TimeSpec;
+use crate::sys::time::TimeSpec;
libc_enum! {
/// Mode for `AioCb::fsync`. Controls whether only data or both data and
@@ -226,8 +225,6 @@ impl<'a> AioCb<'a> {
/// [`fsync`](#method.fsync) operation.
///
/// ```
- /// # extern crate tempfile;
- /// # extern crate nix;
/// # use nix::errno::Errno;
/// # use nix::Error;
/// # use nix::sys::aio::*;
@@ -287,8 +284,6 @@ impl<'a> AioCb<'a> {
/// Create an `AioCb` from a mutable slice and read into it.
///
/// ```
- /// # extern crate tempfile;
- /// # extern crate nix;
/// # use nix::errno::Errno;
/// # use nix::Error;
/// # use nix::sys::aio::*;
@@ -363,8 +358,6 @@ impl<'a> AioCb<'a> {
/// Create an `AioCb` from a Vector and use it for writing
///
/// ```
- /// # extern crate tempfile;
- /// # extern crate nix;
/// # use nix::errno::Errno;
/// # use nix::Error;
/// # use nix::sys::aio::*;
@@ -394,9 +387,6 @@ impl<'a> AioCb<'a> {
/// Create an `AioCb` from a `Bytes` object
///
/// ```
- /// # extern crate bytes;
- /// # extern crate tempfile;
- /// # extern crate nix;
/// # use bytes::Bytes;
/// # use nix::sys::aio::*;
/// # use nix::sys::signal::SigevNotify;
@@ -419,9 +409,6 @@ impl<'a> AioCb<'a> {
/// using an un`Box`ed `Bytes` object.
///
/// ```
- /// # extern crate bytes;
- /// # extern crate tempfile;
- /// # extern crate nix;
/// # use bytes::Bytes;
/// # use nix::sys::aio::*;
/// # use nix::sys::signal::SigevNotify;
@@ -480,8 +467,6 @@ impl<'a> AioCb<'a> {
/// Create an `AioCb` from a Vector and use it for reading
///
/// ```
- /// # extern crate tempfile;
- /// # extern crate nix;
/// # use nix::errno::Errno;
/// # use nix::Error;
/// # use nix::sys::aio::*;
@@ -642,8 +627,6 @@ impl<'a> AioCb<'a> {
/// Construct an `AioCb` from a slice and use it for writing.
///
/// ```
- /// # extern crate tempfile;
- /// # extern crate nix;
/// # use nix::errno::Errno;
/// # use nix::Error;
/// # use nix::sys::aio::*;
@@ -726,8 +709,6 @@ impl<'a> AioCb<'a> {
/// result.
///
/// ```
- /// # extern crate tempfile;
- /// # extern crate nix;
/// # use nix::errno::Errno;
/// # use nix::Error;
/// # use nix::sys::aio::*;
@@ -781,8 +762,6 @@ impl<'a> AioCb<'a> {
/// is an alternative to `aio_suspend`, used by most of the other examples.
///
/// ```
- /// # extern crate tempfile;
- /// # extern crate nix;
/// # use nix::errno::Errno;
/// # use nix::Error;
/// # use nix::sys::aio::*;
@@ -925,8 +904,6 @@ impl<'a> AioCb<'a> {
/// descriptor.
///
/// ```
-/// # extern crate tempfile;
-/// # extern crate nix;
/// # use nix::errno::Errno;
/// # use nix::Error;
/// # use nix::sys::aio::*;
@@ -979,8 +956,6 @@ pub fn aio_cancel_all(fd: RawFd) -> Result<AioCancelStat> {
/// Use `aio_suspend` to block until an aio operation completes.
///
/// ```
-/// # extern crate tempfile;
-/// # extern crate nix;
/// # use nix::sys::aio::*;
/// # use nix::sys::signal::SigevNotify;
/// # use std::os::unix::io::AsRawFd;
@@ -1087,8 +1062,6 @@ impl<'a> LioCb<'a> {
/// [`AioCb::error`] to poll.
///
/// ```
- /// # extern crate tempfile;
- /// # extern crate nix;
/// # use nix::sys::aio::*;
/// # use nix::sys::signal::SigevNotify;
/// # use std::os::unix::io::AsRawFd;
@@ -1144,8 +1117,6 @@ impl<'a> LioCb<'a> {
///
/// # Examples
/// ```no_run
- /// # extern crate tempfile;
- /// # extern crate nix;
/// # use nix::Error;
/// # use nix::errno::Errno;
/// # use nix::sys::aio::*;
diff --git a/src/sys/epoll.rs b/src/sys/epoll.rs
index 074a8451..2437bbe2 100644
--- a/src/sys/epoll.rs
+++ b/src/sys/epoll.rs
@@ -1,10 +1,10 @@
-use Result;
-use errno::Errno;
+use crate::Result;
+use crate::errno::Errno;
use libc::{self, c_int};
use std::os::unix::io::RawFd;
use std::ptr;
use std::mem;
-use ::Error;
+use crate::Error;
libc_bitflags!(
pub struct EpollFlags: c_int {
diff --git a/src/sys/event.rs b/src/sys/event.rs
index cf9393bd..2b403c1e 100644
--- a/src/sys/event.rs
+++ b/src/sys/event.rs
@@ -1,12 +1,11 @@
/* TOOD: Implement for other kqueue based systems
*/
-use {Errno, Result};
+use crate::{Errno, Result};
#[cfg(not(target_os = "netbsd"))]
use libc::{timespec, time_t, c_int, c_long, intptr_t, uintptr_t};
#[cfg(target_os = "netbsd")]
use libc::{timespec, time_t, c_long, intptr_t, uintptr_t, size_t};
-use libc;
use std::os::unix::io::RawFd;
use std::ptr;
use std::mem;
diff --git a/src/sys/eventfd.rs b/src/sys/eventfd.rs
index c5a54e46..baaaa89d 100644
--- a/src/sys/eventfd.rs
+++ b/src/sys/eventfd.rs
@@ -1,7 +1,7 @@
use libc;
use std::os::unix::io::RawFd;
-use Result;
-use errno::Errno;
+use crate::Result;
+use crate::errno::Errno;
libc_bitflags! {
pub struct EfdFlags: libc::c_int {
diff --git a/src/sys/inotify.rs b/src/sys/inotify.rs
index e6c2cf64..078015b6 100644
--- a/src/sys/inotify.rs
+++ b/src/sys/inotify.rs
@@ -23,7 +23,6 @@
//! }
//! ```
-use libc;
use libc::{
c_char,
c_int,
@@ -32,10 +31,10 @@ use std::ffi::{OsString,OsStr,CStr};
use std::os::unix::ffi::OsStrExt;
use std::mem::size_of;
use std::os::unix::io::{RawFd,AsRawFd,FromRawFd};
-use unistd::read;
-use Result;
-use NixPath;
-use errno::Errno;
+use crate::unistd::read;
+use crate::Result;
+use crate::NixPath;
+use crate::errno::Errno;
libc_bitflags! {
/// Configuration options for [`inotify_add_watch`](fn.inotify_add_watch.html).
diff --git a/src/sys/ioctl/bsd.rs b/src/sys/ioctl/bsd.rs
index 20c80448..f39c0eb6 100644
--- a/src/sys/ioctl/bsd.rs
+++ b/src/sys/ioctl/bsd.rs
@@ -6,7 +6,7 @@ pub type ioctl_num_type = ::libc::c_ulong;
pub type ioctl_param_type = ::libc::c_int;
mod consts {
- use ::sys::ioctl::ioctl_num_type;
+ use crate::sys::ioctl::ioctl_num_type;
#[doc(hidden)]
pub const VOID: ioctl_num_type = 0x2000_0000;
#[doc(hidden)]
diff --git a/src/sys/ioctl/mod.rs b/src/sys/ioctl/mod.rs
index 3bcdd266..60f169db 100644
--- a/src/sys/ioctl/mod.rs
+++ b/src/sys/ioctl/mod.rs
@@ -221,6 +221,8 @@
//!
//! # fn main() {}
//! ```
+use cfg_if::cfg_if;
+
#[cfg(any(target_os = "android", target_os = "linux", target_os = "redox"))]
#[macro_use]
mod linux;
@@ -317,7 +319,6 @@ macro_rules! ioctl_none {
///
/// ```no_run
/// # #[macro_use] extern crate nix;
-/// # extern crate libc;
/// # use libc::TIOCNXCL;
/// # use std::fs::File;
/// # use std::os::unix::io::AsRawFd;
@@ -396,7 +397,6 @@ macro_rules! ioctl_read {
/// # Example
///
/// ```
-/// # extern crate libc;
/// # #[macro_use] extern crate nix;
/// # #[cfg(any(target_os = "android", target_os = "linux"))]
/// ioctl_read_bad!(tcgets, libc::TCGETS, libc::termios);
@@ -470,7 +470,6 @@ macro_rules! ioctl_write_ptr {
/// # Example
///
/// ```
-/// # extern crate libc;
/// # #[macro_use] extern crate nix;
/// # #[cfg(any(target_os = "android", target_os = "linux"))]
/// ioctl_write_ptr_bad!(tcsets, libc::TCSETS, libc::termios);
@@ -590,7 +589,6 @@ cfg_if!{
/// # Examples
///
/// ```
-/// # extern crate libc;
/// # #[macro_use] extern crate nix;
/// # #[cfg(any(target_os = "android", target_os = "linux"))]
/// ioctl_write_int_bad!(tcsbrk, libc::TCSBRK);
diff --git a/src/sys/memfd.rs b/src/sys/memfd.rs
index 9672429b..51b7e6b1 100644
--- a/src/sys/memfd.rs
+++ b/src/sys/memfd.rs
@@ -1,7 +1,7 @@
use libc;
use std::os::unix::io::RawFd;
-use Result;
-use errno::Errno;
+use crate::Result;
+use crate::errno::Errno;
use std::ffi::CStr;
libc_bitflags!(
diff --git a/src/sys/mman.rs b/src/sys/mman.rs
index dfa46264..5a5dd89e 100644
--- a/src/sys/mman.rs
+++ b/src/sys/mman.rs
@@ -1,12 +1,12 @@
-use {Error, Result};
+use crate::{Error, Result};
#[cfg(not(target_os = "android"))]
-use NixPath;
-use errno::Errno;
+use crate::NixPath;
+use crate::errno::Errno;
#[cfg(not(target_os = "android"))]
-use fcntl::OFlag;
+use crate::fcntl::OFlag;
use libc::{self, c_int, c_void, size_t, off_t};
#[cfg(not(target_os = "android"))]
-use sys::stat::Mode;
+use crate::sys::stat::Mode;
use std::os::unix::io::RawFd;
libc_bitflags!{
diff --git a/src/sys/ptrace/bsd.rs b/src/sys/ptrace/bsd.rs
index 18265d31..e85afc76 100644
--- a/src/sys/ptrace/bsd.rs
+++ b/src/sys/ptrace/bsd.rs
@@ -1,9 +1,10 @@
-use errno::Errno;
+use cfg_if::cfg_if;
+use crate::errno::Errno;
use libc::{self, c_int};
use std::ptr;
-use sys::signal::Signal;
-use unistd::Pid;
-use Result;
+use crate::sys::signal::Signal;
+use crate::unistd::Pid;
+use crate::Result;
pub type RequestType = c_int;
@@ -128,7 +129,6 @@ pub fn kill(pid: Pid) -> Result<()> {
///
/// # Example
/// ```rust
-/// extern crate nix;
/// use nix::sys::ptrace::step;
/// use nix::unistd::Pid;
/// use nix::sys::signal::Signal;
diff --git a/src/sys/ptrace/linux.rs b/src/sys/ptrace/linux.rs
index 6c9559e2..49a45d64 100644
--- a/src/sys/ptrace/linux.rs
+++ b/src/sys/ptrace/linux.rs
@@ -1,11 +1,12 @@
//! For detailed description of the ptrace requests, consult `man ptrace`.
+use cfg_if::cfg_if;
use std::{mem, ptr};
-use {Error, Result};
-use errno::Errno;
+use crate::{Error, Result};
+use crate::errno::Errno;
use libc::{self, c_void, c_long, siginfo_t};
-use ::unistd::Pid;
-use sys::signal::Signal;
+use crate::unistd::Pid;
+use crate::sys::signal::Signal;
pub type AddressType = *mut ::libc::c_void;
@@ -391,7 +392,6 @@ pub fn kill(pid: Pid) -> Result<()> {
///
/// # Example
/// ```rust
-/// extern crate nix;
/// use nix::sys::ptrace::step;
/// use nix::unistd::Pid;
/// use nix::sys::signal::Signal;
diff --git a/src/sys/quota.rs b/src/sys/quota.rs
index db97b0e7..1199d5f9 100644
--- a/src/sys/quota.rs
+++ b/src/sys/quota.rs
@@ -15,8 +15,8 @@
use std::default::Default;
use std::{mem, ptr};
use libc::{self, c_int, c_char};
-use {Result, NixPath};
-use errno::Errno;
+use crate::{Result, NixPath};
+use crate::errno::Errno;
struct QuotaCmd(QuotaSubCmd, QuotaType);
diff --git a/src/sys/reboot.rs b/src/sys/reboot.rs
index d18b44d6..e3191306 100644
--- a/src/sys/reboot.rs
+++ b/src/sys/reboot.rs
@@ -1,7 +1,7 @@
//! Reboot/shutdown or enable/disable Ctrl-Alt-Delete.
-use {Error, Result};
-use errno::Errno;
+use crate::{Error, Result};
+use crate::errno::Errno;
use libc;
use std::convert::Infallible;
use std::mem::drop;
diff --git a/src/sys/select.rs b/src/sys/select.rs
index a46985bc..a576c7e4 100644
--- a/src/sys/select.rs
+++ b/src/sys/select.rs
@@ -4,10 +4,10 @@ use std::ops::Range;
use std::os::unix::io::RawFd;
use std::ptr::{null, null_mut};
use libc::{self, c_int};
-use Result;
-use errno::Errno;
-use sys::signal::SigSet;
-use sys::time::{TimeSpec, TimeVal};
+use crate::Result;
+use crate::errno::Errno;
+use crate::sys::signal::SigSet;
+use crate::sys::time::{TimeSpec, TimeVal};
pub use libc::FD_SETSIZE;
@@ -49,7 +49,6 @@ impl FdSet {
/// # Example
///
/// ```
- /// # extern crate nix;
/// # use nix::sys::select::FdSet;
/// # fn main() {
/// let mut set = FdSet::new();
@@ -73,7 +72,6 @@ impl FdSet {
/// # Examples
///
/// ```
- /// # extern crate nix;
/// # use nix::sys::select::FdSet;
/// # use std::os::unix::io::RawFd;
/// let mut set = FdSet::new();
@@ -275,8 +273,8 @@ where
mod tests {
use super::*;
use std::os::unix::io::RawFd;
- use sys::time::{TimeVal, TimeValLike};
- use unistd::{write, pipe};
+ use crate::sys::time::{TimeVal, TimeValLike};
+ use crate::unistd::{write, pipe};
#[test]
fn fdset_insert() {
diff --git a/src/sys/sendfile.rs b/src/sys/sendfile.rs
index 1618558a..84fe2a91 100644
--- a/src/sys/sendfile.rs
+++ b/src/sys/sendfile.rs
@@ -1,10 +1,11 @@
+use cfg_if::cfg_if;
use std::os::unix::io::RawFd;
use std::ptr;
use libc::{self, off_t};
-use Result;
-use errno::Errno;
+use crate::Result;
+use crate::errno::Errno;
/// Copy up to `count` bytes to `out_fd` from `in_fd` starting at `offset`.
///
@@ -36,7 +37,7 @@ cfg_if! {
if #[cfg(any(target_os = "freebsd",
target_os = "ios",
target_os = "macos"))] {
- use sys::uio::IoVec;
+ use crate::sys::uio::IoVec;
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
struct SendfileHeaderTrailer<'a>(
diff --git a/src/sys/signal.rs b/src/sys/signal.rs
index 2b36c957..710e65f5 100644
--- a/src/sys/signal.rs
+++ b/src/sys/signal.rs
@@ -3,9 +3,9 @@
///! Operating system signals.
-use libc;
-use {Error, Result};
-use errno::Errno;
+use crate::{Error, Result};
+use crate::errno::Errno;
+use crate::unistd::Pid;
use std::convert::TryFrom;
use std::mem;
use std::fmt;
@@ -623,8 +623,6 @@ pub unsafe fn sigaction(signal: Signal, sigaction: &SigAction) -> Result<SigActi
///
/// ```no_run
/// # #[macro_use] extern crate lazy_static;
-/// # extern crate libc;
-/// # extern crate nix;
/// # use std::convert::TryFrom;
/// # use std::sync::atomic::{AtomicBool, Ordering};
/// # use nix::sys::signal::{self, Signal, SigHandler};
@@ -735,7 +733,7 @@ pub fn sigprocmask(how: SigmaskHow, set: Option<&SigSet>, oldset: Option<&mut Si
Errno::result(res).map(drop)
}
-pub fn kill<T: Into<Option<Signal>>>(pid: ::unistd::Pid, signal: T) -> Result<()> {
+pub fn kill<T: Into<Option<Signal>>>(pid: Pid, signal: T) -> Result<()> {
let res = unsafe { libc::kill(pid.into(),
match signal.into() {
Some(s) => s as libc::c_int,
@@ -751,7 +749,7 @@ pub fn kill<T: Into<Option<Signal>>>(pid: ::unistd::Pid, signal: T) -> Result<()
/// If `pgrp` less then or equal 1, the behavior is platform-specific.
/// If `signal` is `None`, `killpg` will only preform error checking and won't
/// send any signal.
-pub fn killpg<T: Into<Option<Signal>>>(pgrp: ::unistd::Pid, signal: T) -> Result<()> {
+pub fn killpg<T: Into<Option<Signal>>>(pgrp: Pid, signal: T) -> Result<()> {
let res = unsafe { libc::killpg(pgrp.into(),
match signal.into() {
Some(s) => s as libc::c_int,
@@ -802,7 +800,6 @@ pub enum SigevNotify {
#[cfg(not(any(target_os = "openbsd", target_os = "redox")))]
mod sigevent {
- use libc;
use std::mem;
use std::ptr;
use super::SigevNotify;
@@ -1019,7 +1016,6 @@ mod tests {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_sigaction() {
- use libc;
thread::spawn(|| {
extern fn test_sigaction_handler(_: libc::c_int) {}
extern fn test_sigaction_action(_: libc::c_int,
diff --git a/src/sys/signalfd.rs b/src/sys/signalfd.rs
index 6482eeb3..e3ded1f7 100644
--- a/src/sys/signalfd.rs
+++ b/src/sys/signalfd.rs
@@ -16,10 +16,10 @@
//! Please note that signal discarding is not specific to `signalfd`, but also happens with regular
//! signal handlers.
use libc;
-use unistd;
-use {Error, Result};
-use errno::Errno;
-pub use sys::signal::{self, SigSet};
+use crate::unistd;
+use crate::{Error, Result};
+use crate::errno::Errno;
+pub use crate::sys::signal::{self, SigSet};
pub use libc::signalfd_siginfo as siginfo;
use std::os::unix::io::{RawFd, AsRawFd};
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs
index 27883254..cdfa704d 100644
--- a/src/sys/socket/addr.rs
+++ b/src/sys/socket/addr.rs
@@ -1,20 +1,19 @@
use super::sa_family_t;
-use {Error, Result, NixPath};
-use errno::Errno;
-use libc;
+use crate::{Error, Result, NixPath};
+use crate::errno::Errno;
use std::{fmt, mem, net, ptr, slice};
use std::ffi::OsStr;
use std::hash::{Hash, Hasher};
use std::path::Path;
use std::os::unix::ffi::OsStrExt;
#[cfg(any(target_os = "android", target_os = "linux"))]
-use ::sys::socket::addr::netlink::NetlinkAddr;
+use crate::sys::socket::addr::netlink::NetlinkAddr;
#[cfg(any(target_os = "android", target_os = "linux"))]
-use ::sys::socket::addr::alg::AlgAddr;
+use crate::sys::socket::addr::alg::AlgAddr;
#[cfg(any(target_os = "ios", target_os = "macos"))]
use std::os::unix::io::RawFd;
#[cfg(any(target_os = "ios", target_os = "macos"))]
-use ::sys::socket::addr::sys_control::SysControlAddr;
+use crate::sys::socket::addr::sys_control::SysControlAddr;
#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
@@ -851,7 +850,7 @@ impl fmt::Display for SockAddr {
#[cfg(any(target_os = "android", target_os = "linux"))]
pub mod netlink {
- use ::sys::socket::addr::AddressFamily;
+ use crate::sys::socket::addr::AddressFamily;
use libc::{sa_family_t, sockaddr_nl};
use std::{fmt, mem};
@@ -949,11 +948,11 @@ pub mod alg {
#[cfg(any(target_os = "ios", target_os = "macos"))]
pub mod sys_control {
- use ::sys::socket::addr::AddressFamily;
+ use crate::sys::socket::addr::AddressFamily;
use libc::{self, c_uchar};
use std::{fmt, mem};
use std::os::unix::io::RawFd;
- use {Errno, Error, Result};
+ use crate::{Errno, Error, Result};
// FIXME: Move type into `libc`
#[repr(C)]
@@ -1021,7 +1020,7 @@ pub mod sys_control {
#[cfg(any(target_os = "android", target_os = "linux"))]
mod datalink {
- use super::{libc, fmt, AddressFamily};
+ use super::{fmt, AddressFamily};
/// Hardware Address
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
@@ -1093,7 +1092,7 @@ mod datalink {
target_os = "netbsd",
target_os = "openbsd"))]
mod datalink {
- use super::{libc, fmt, AddressFamily};
+ use super::{fmt, AddressFamily};
/// Hardware Address
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
@@ -1180,7 +1179,7 @@ mod datalink {
#[cfg(target_os = "linux")]
pub mod vsock {
- use ::sys::socket::addr::AddressFamily;
+ use crate::sys::socket::addr::AddressFamily;
use libc::{sa_family_t, sockaddr_vm};
use std::{fmt, mem};
use std::hash::{Hash, Hasher};
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index a3c0d128..6909c154 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -1,14 +1,14 @@
//! Socket interface functions
//!
//! [Further reading](http://man7.org/linux/man-pages/man7/socket.7.html)
-use {Error, Result};
-use errno::Errno;
+use cfg_if::cfg_if;
+use crate::{Error, Result, errno::Errno};
use libc::{self, c_void, c_int, iovec, socklen_t, size_t,
CMSG_FIRSTHDR, CMSG_NXTHDR, CMSG_DATA, CMSG_LEN};
use std::{mem, ptr, slice};
use std::os::unix::io::RawFd;
-use sys::time::TimeVal;
-use sys::uio::IoVec;
+use crate::sys::time::TimeVal;
+use crate::sys::uio::IoVec;
mod addr;
pub mod sockopt;
@@ -30,11 +30,11 @@ pub use self::addr::{
LinkAddr,
};
#[cfg(any(target_os = "android", target_os = "linux"))]
-pub use ::sys::socket::addr::netlink::NetlinkAddr;
+pub use crate::sys::socket::addr::netlink::NetlinkAddr;
#[cfg(any(target_os = "android", target_os = "linux"))]
-pub use sys::socket::addr::alg::AlgAddr;
+pub use crate::sys::socket::addr::alg::AlgAddr;
#[cfg(target_os = "linux")]
-pub use sys::socket::addr::vsock::VsockAddr;
+pub use crate::sys::socket::addr::vsock::VsockAddr;
pub use libc::{
cmsghdr,
diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs
index fa19fb76..cbdf6691 100644
--- a/src/sys/socket/sockopt.rs
+++ b/src/sys/socket/sockopt.rs
@@ -1,7 +1,8 @@
+use cfg_if::cfg_if;
use super::{GetSockOpt, SetSockOpt};
-use Result;
-use errno::Errno;
-use sys::time::TimeVal;
+use crate::Result;
+use crate::errno::Errno;
+use crate::sys::time::TimeVal;
use libc::{self, c_int, c_void, socklen_t};
use std::mem::{
self,
@@ -650,7 +651,7 @@ mod test {
#[test]
fn is_socket_type_unix() {
use super::super::*;
- use ::unistd::close;
+ use crate::unistd::close;
let (a, b) = socketpair(AddressFamily::Unix, SockType::Stream, None, SockFlag::empty()).unwrap();
let a_type = getsockopt(a, super::SockType).unwrap();
@@ -662,7 +663,7 @@ mod test {
#[test]
fn is_socket_type_dgram() {
use super::super::*;
- use ::unistd::close;
+ use crate::unistd::close;
let s = socket(AddressFamily::Inet, SockType::Datagram, SockFlag::empty(), None).unwrap();
let s_type = getsockopt(s, super::SockType).unwrap();
@@ -676,7 +677,7 @@ mod test {
#[test]
fn can_get_listen_on_tcp_socket() {
use super::super::*;
- use ::unistd::close;
+ use crate::unistd::close;
let s = socket(AddressFamily::Inet, SockType::Stream, SockFlag::empty(), None).unwrap();
let s_listening = getsockopt(s, super::AcceptConn).unwrap();
diff --git a/src/sys/stat.rs b/src/sys/stat.rs
index f8fae4ee..c3915b09 100644
--- a/src/sys/stat.rs
+++ b/src/sys/stat.rs
@@ -1,14 +1,12 @@
pub use libc::{dev_t, mode_t};
pub use libc::stat as FileStat;
-use {Result, NixPath};
-use errno::Errno;
+use crate::{Result, NixPath, errno::Errno};
#[cfg(not(target_os = "redox"))]
-use fcntl::{AtFlags, at_rawfd};
-use libc;
+use crate::fcntl::{AtFlags, at_rawfd};
use std::mem;
use std::os::unix::io::RawFd;
-use sys::time::{TimeSpec, TimeVal};
+use crate::sys::time::{TimeSpec, TimeVal};
libc_bitflags!(
pub struct SFlag: mode_t {
diff --git a/src/sys/statfs.rs b/src/sys/statfs.rs
index 8e421167..3d46be9c 100644
--- a/src/sys/statfs.rs
+++ b/src/sys/statfs.rs
@@ -4,10 +4,7 @@ use std::os::unix::io::AsRawFd;
#[cfg(not(any(target_os = "linux", target_os = "android")))]
use std::ffi::CStr;
-use libc;
-
-use {NixPath, Result};
-use errno::Errno;
+use crate::{NixPath, Result, errno::Errno};
#[cfg(target_os = "android")]
pub type fsid_t = libc::__fsid_t;
@@ -457,8 +454,8 @@ pub fn fstatfs<T: AsRawFd>(fd: &T) -> Result<Statfs> {
mod test {
use std::fs::File;
- use sys::statfs::*;
- use sys::statvfs::*;
+ use crate::sys::statfs::*;
+ use crate::sys::statvfs::*;
use std::path::Path;
#[test]
diff --git a/src/sys/statvfs.rs b/src/sys/statvfs.rs
index 8e8d367c..9bea9734 100644
--- a/src/sys/statvfs.rs
+++ b/src/sys/statvfs.rs
@@ -7,8 +7,7 @@ use std::os::unix::io::AsRawFd;
use libc::{self, c_ulong};
-use {Result, NixPath};
-use errno::Errno;
+use crate::{Result, NixPath, errno::Errno};
#[cfg(not(target_os = "redox"))]
libc_bitflags!(
@@ -147,7 +146,7 @@ pub fn fstatvfs<T: AsRawFd>(fd: &T) -> Result<Statvfs> {
#[cfg(test)]
mod test {
use std::fs::File;
- use sys::statvfs::*;
+ use crate::sys::statvfs::*;
#[test]
fn statvfs_call() {
diff --git a/src/sys/sysinfo.rs b/src/sys/sysinfo.rs
index 9807b444..f4b82798 100644
--- a/src/sys/sysinfo.rs
+++ b/src/sys/sysinfo.rs
@@ -2,8 +2,8 @@ use libc::{self, SI_LOAD_SHIFT};
use std::{cmp, mem};
use std::time::Duration;
-use Result;
-use errno::Errno;
+use crate::Result;
+use crate::errno::Errno;
/// System info structure returned by `sysinfo`.
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index 0b9bfe90..5af5a158 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
@@ -74,7 +74,6 @@
//! Additionally round-tripping baud rates is consistent across platforms:
//!
//! ```rust
-//! # extern crate nix;
//! # use nix::sys::termios::{BaudRate, cfgetispeed, cfgetospeed, cfsetispeed, cfsetspeed, Termios};
//! # fn main() {
//! # let mut t = unsafe { Termios::default_uninit() };
@@ -93,7 +92,6 @@
#![cfg_attr(not(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios",
target_os = "macos", target_os = "netbsd", target_os = "openbsd")),
doc = " ```rust")]
-//! # extern crate nix;
//! # use nix::sys::termios::{BaudRate, cfgetispeed, cfgetospeed, cfsetspeed, Termios};
//! # fn main() {
//! # let mut t = unsafe { Termios::default_uninit() };
@@ -111,7 +109,6 @@
#![cfg_attr(not(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios",
target_os = "macos", target_os = "netbsd", target_os = "openbsd")),
doc = " ```rust,ignore")]
-//! # extern crate nix;
//! # use nix::sys::termios::{BaudRate, cfgetispeed, cfgetospeed, cfsetspeed, Termios};
//! # fn main() {
//! # let mut t = unsafe { Termios::default_uninit() };
@@ -129,7 +126,6 @@
#![cfg_attr(not(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios",
target_os = "macos", target_os = "netbsd", target_os = "openbsd")),
doc = " ```rust,ignore")]
-//! # extern crate nix;
//! # use nix::sys::termios::{BaudRate, cfgetispeed, cfsetspeed, Termios};
//! # fn main() {
//! # let mut t = unsafe { Termios::default_uninit() };
@@ -148,7 +144,6 @@
#![cfg_attr(not(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios",
target_os = "macos", target_os = "netbsd", target_os = "openbsd")),
doc = " ```rust,ignore")]
-//! # extern crate nix;
//! # use nix::sys::termios::{cfsetispeed, cfsetospeed, cfsetspeed, Termios};
//! # fn main() {
//! # let mut t = unsafe { Termios::default_uninit() };
@@ -157,15 +152,16 @@
//! cfsetspeed(&mut t, 9600u32);
//! # }
//! ```
-use {Error, Result};
-use errno::Errno;
+use cfg_if::cfg_if;
+use crate::{Error, Result};
+use crate::errno::Errno;
use libc::{self, c_int, tcflag_t};
use std::cell::{Ref, RefCell};
use std::convert::{From, TryFrom};
use std::mem;
use std::os::unix::io::RawFd;
-use ::unistd::Pid;
+use crate::unistd::Pid;
/// Stores settings for the termios API
///
@@ -193,8 +189,6 @@ impl Termios {
/// This can be used for interfacing with other FFI functions like:
///
/// ```rust
- /// # extern crate libc;
- /// # extern crate nix;
/// # fn main() {
/// # use nix::sys::termios::Termios;
/// # let mut termios = unsafe { Termios::default_uninit() };
diff --git a/src/sys/uio.rs b/src/sys/uio.rs
index 7dfeff77..65334227 100644
--- a/src/sys/uio.rs
+++ b/src/sys/uio.rs
@@ -1,8 +1,8 @@
// Silence invalid warnings due to rust-lang/rust#16719
#![allow(improper_ctypes)]
-use Result;
-use errno::Errno;
+use crate::Result;
+use crate::errno::Errno;
use libc::{self, c_int, c_void, size_t, off_t};
use std::marker::PhantomData;
use std::os::unix::io::RawFd;
@@ -117,7 +117,11 @@ pub struct RemoteIoVec {
/// [`IoVec`]: struct.IoVec.html
/// [`RemoteIoVec`]: struct.RemoteIoVec.html
#[cfg(target_os = "linux")]
-pub fn process_vm_writev(pid: ::unistd::Pid, local_iov: &[IoVec<&[u8]>], remote_iov: &[RemoteIoVec]) -> Result<usize> {
+pub fn process_vm_writev(
+ pid: crate::unistd::Pid,
+ local_iov: &[IoVec<&[u8]>],
+ remote_iov: &[RemoteIoVec]) -> Result<usize>
+{
let res = unsafe {
libc::process_vm_writev(pid.into(),
local_iov.as_ptr() as *const libc::iovec, local_iov.len() as libc::c_ulong,
@@ -148,7 +152,11 @@ pub fn process_vm_writev(pid: ::unistd::Pid, local_iov: &[IoVec<&[u8]>], remote_
/// [`IoVec`]: struct.IoVec.html
/// [`RemoteIoVec`]: struct.RemoteIoVec.html
#[cfg(any(target_os = "linux"))]
-pub fn process_vm_readv(pid: ::unistd::Pid, local_iov: &[IoVec<&mut [u8]>], remote_iov: &[RemoteIoVec]) -> Result<usize> {
+pub fn process_vm_readv(
+ pid: crate::unistd::Pid,
+ local_iov: &[IoVec<&mut [u8]>],
+ remote_iov: &[RemoteIoVec]) -> Result<usize>
+{
let res = unsafe {
libc::process_vm_readv(pid.into(),
local_iov.as_ptr() as *const libc::iovec, local_iov.len() as libc::c_ulong,
diff --git a/src/sys/wait.rs b/src/sys/wait.rs
index 252ef28d..9825102c 100644
--- a/src/sys/wait.rs
+++ b/src/sys/wait.rs
@@ -1,10 +1,10 @@
+use cfg_if::cfg_if;
use libc::{self, c_int};
-use Result;
-use errno::Errno;
+use crate::Result;
+use crate::errno::Errno;
+use crate::unistd::Pid;
+use crate::sys::signal::Signal;
use std::convert::TryFrom;
-use unistd::Pid;
-
-use sys::signal::Signal;
libc_bitflags!(
pub struct WaitPidFlag: c_int {