summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/errno.rs4
-rw-r--r--src/fcntl.rs3
-rw-r--r--src/lib.rs12
-rw-r--r--src/mount.rs3
-rw-r--r--src/mqueue.rs3
-rw-r--r--src/poll.rs3
-rw-r--r--src/pty.rs3
-rw-r--r--src/sched.rs3
-rw-r--r--src/sys/aio.rs3
-rw-r--r--src/sys/epoll.rs3
-rw-r--r--src/sys/eventfd.rs3
-rw-r--r--src/sys/ioctl/mod.rs8
-rw-r--r--src/sys/memfd.rs3
-rw-r--r--src/sys/mman.rs3
-rw-r--r--src/sys/ptrace.rs3
-rw-r--r--src/sys/quota.rs3
-rw-r--r--src/sys/reboot.rs3
-rw-r--r--src/sys/select.rs3
-rw-r--r--src/sys/sendfile.rs3
-rw-r--r--src/sys/signal.rs3
-rw-r--r--src/sys/signalfd.rs3
-rw-r--r--src/sys/socket/addr.rs3
-rw-r--r--src/sys/socket/mod.rs3
-rw-r--r--src/sys/socket/sockopt.rs3
-rw-r--r--src/sys/stat.rs3
-rw-r--r--src/sys/statfs.rs3
-rw-r--r--src/sys/statvfs.rs3
-rw-r--r--src/sys/termios.rs3
-rw-r--r--src/sys/uio.rs3
-rw-r--r--src/sys/wait.rs3
-rw-r--r--src/ucontext.rs4
-rw-r--r--src/unistd.rs10
32 files changed, 76 insertions, 43 deletions
diff --git a/src/errno.rs b/src/errno.rs
index e7486c8e..cbbf8380 100644
--- a/src/errno.rs
+++ b/src/errno.rs
@@ -3,7 +3,6 @@ use std::{fmt, io, error};
use {Error, Result};
pub use self::consts::*;
-pub use self::consts::Errno::*;
cfg_if! {
if #[cfg(any(target_os = "freebsd",
@@ -113,6 +112,7 @@ fn last() -> Errno {
}
fn desc(errno: Errno) -> &'static str {
+ use self::Errno::*;
match errno {
UnknownErrno => "Unknown errno",
EPERM => "Operation not permitted",
@@ -1898,7 +1898,7 @@ mod consts {
#[cfg(test)]
mod test {
- use super::*;
+ use super::Errno::*;
use nixtest::assert_const_eq;
use libc::c_int;
diff --git a/src/fcntl.rs b/src/fcntl.rs
index f99036d6..86375e4a 100644
--- a/src/fcntl.rs
+++ b/src/fcntl.rs
@@ -1,4 +1,5 @@
-use {Error, Errno, Result, NixPath};
+use {Error, Result, NixPath};
+use errno::Errno;
use libc::{self, c_int, c_uint, c_char, size_t, ssize_t};
use sys::stat::Mode;
use std::os::unix::io::RawFd;
diff --git a/src/lib.rs b/src/lib.rs
index cadc7fb4..a51c5aa4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -25,7 +25,7 @@ extern crate nix_test as nixtest;
pub extern crate libc;
-pub use errno::Errno;
+use errno::Errno;
pub mod errno;
pub mod features;
@@ -96,24 +96,24 @@ pub enum Error {
impl Error {
/// Create a nix Error from a given errno
- pub fn from_errno(errno: errno::Errno) -> Error {
+ pub fn from_errno(errno: Errno) -> Error {
Error::Sys(errno)
}
/// Get the current errno and convert it to a nix Error
pub fn last() -> Error {
- Error::Sys(errno::Errno::last())
+ Error::Sys(Errno::last())
}
/// Create a new invalid argument error (`EINVAL`)
pub fn invalid_argument() -> Error {
- Error::Sys(errno::EINVAL)
+ Error::Sys(Errno::EINVAL)
}
}
-impl From<errno::Errno> for Error {
- fn from(errno: errno::Errno) -> Error { Error::from_errno(errno) }
+impl From<Errno> for Error {
+ fn from(errno: Errno) -> Error { Error::from_errno(errno) }
}
impl From<std::string::FromUtf8Error> for Error {
diff --git a/src/mount.rs b/src/mount.rs
index ccfd5427..fb43e24c 100644
--- a/src/mount.rs
+++ b/src/mount.rs
@@ -1,6 +1,7 @@
use libc::{c_ulong, c_int};
use libc;
-use {Errno, Result, NixPath};
+use {Result, NixPath};
+use errno::Errno;
bitflags!(
pub struct MsFlags: c_ulong {
diff --git a/src/mqueue.rs b/src/mqueue.rs
index 4c88045c..89bb2784 100644
--- a/src/mqueue.rs
+++ b/src/mqueue.rs
@@ -2,7 +2,8 @@
//!
//! [Further reading and details on the C API](http://man7.org/linux/man-pages/man7/mq_overview.7.html)
-use {Errno, Result};
+use Result;
+use errno::Errno;
use libc::{self, c_char, c_long, mode_t, mqd_t, size_t};
use std::ffi::CString;
diff --git a/src/poll.rs b/src/poll.rs
index 30a46688..78229a5b 100644
--- a/src/poll.rs
+++ b/src/poll.rs
@@ -5,7 +5,8 @@ use sys::signal::SigSet;
use std::os::unix::io::RawFd;
use libc;
-use {Errno, Result};
+use Result;
+use errno::Errno;
/// This is a wrapper around `libc::pollfd`.
///
diff --git a/src/pty.rs b/src/pty.rs
index dbf34208..d526ed17 100644
--- a/src/pty.rs
+++ b/src/pty.rs
@@ -10,7 +10,8 @@ use std::mem;
use std::os::unix::prelude::*;
use sys::termios::Termios;
-use {Errno, Result, Error, fcntl};
+use {Result, Error, fcntl};
+use errno::Errno;
/// Representation of a master/slave pty pair
///
diff --git a/src/sched.rs b/src/sched.rs
index 74c23072..9de1bd10 100644
--- a/src/sched.rs
+++ b/src/sched.rs
@@ -2,7 +2,8 @@ use std::mem;
use std::os::unix::io::RawFd;
use std::option::Option;
use libc::{self, c_int, c_void};
-use {Errno, Error, Result};
+use {Error, Result};
+use errno::Errno;
use ::unistd::Pid;
// For some functions taking with a parameter of type CloneFlags,
diff --git a/src/sys/aio.rs b/src/sys/aio.rs
index 6166467c..fbae4443 100644
--- a/src/sys/aio.rs
+++ b/src/sys/aio.rs
@@ -1,4 +1,5 @@
-use {Error, Errno, Result};
+use {Error, Result};
+use errno::Errno;
use std::os::unix::io::RawFd;
use libc::{c_void, off_t, size_t};
use libc;
diff --git a/src/sys/epoll.rs b/src/sys/epoll.rs
index 5d63e82f..43a543ab 100644
--- a/src/sys/epoll.rs
+++ b/src/sys/epoll.rs
@@ -1,4 +1,5 @@
-use {Errno, Result};
+use Result;
+use errno::Errno;
use libc::{self, c_int};
use std::os::unix::io::RawFd;
use std::ptr;
diff --git a/src/sys/eventfd.rs b/src/sys/eventfd.rs
index 51091478..c5a54e46 100644
--- a/src/sys/eventfd.rs
+++ b/src/sys/eventfd.rs
@@ -1,6 +1,7 @@
use libc;
use std::os::unix::io::RawFd;
-use {Errno, Result};
+use Result;
+use errno::Errno;
libc_bitflags! {
pub struct EfdFlags: libc::c_int {
diff --git a/src/sys/ioctl/mod.rs b/src/sys/ioctl/mod.rs
index b29c8b42..4169920b 100644
--- a/src/sys/ioctl/mod.rs
+++ b/src/sys/ioctl/mod.rs
@@ -66,7 +66,8 @@
//! ```
//! # #[macro_use] extern crate nix;
//! # use std::mem;
-//! # use nix::{Errno, libc, Result};
+//! # use nix::{libc, Result};
+//! # use nix::errno::Errno;
//! # use nix::libc::c_int as c_int;
//! # const SPI_IOC_MAGIC: u8 = b'k'; // Defined in linux/spi/spidev.h
//! # const SPI_IOC_TYPE_MODE: u8 = 1;
@@ -176,7 +177,8 @@
//! ```
//! # #[macro_use] extern crate nix;
//! # use std::mem;
-//! # use nix::{Errno, libc, Result};
+//! # use nix::{libc, Result};
+//! # use nix::errno::Errno;
//! # use nix::libc::c_int as c_int;
//! # const SPI_IOC_MAGIC: u8 = b'k';
//! # const SPI_IOC_TYPE_MESSAGE: u8 = 0;
@@ -248,7 +250,7 @@ pub use self::platform::*;
macro_rules! convert_ioctl_res {
($w:expr) => (
{
- $crate::Errno::result($w)
+ $crate::errno::Errno::result($w)
}
);
}
diff --git a/src/sys/memfd.rs b/src/sys/memfd.rs
index 88c1dac9..9672429b 100644
--- a/src/sys/memfd.rs
+++ b/src/sys/memfd.rs
@@ -1,6 +1,7 @@
use libc;
use std::os::unix::io::RawFd;
-use {Errno, Result};
+use Result;
+use errno::Errno;
use std::ffi::CStr;
libc_bitflags!(
diff --git a/src/sys/mman.rs b/src/sys/mman.rs
index dc21899b..a32cd54a 100644
--- a/src/sys/mman.rs
+++ b/src/sys/mman.rs
@@ -1,4 +1,5 @@
-use {Errno, Error, Result, NixPath};
+use {Error, Result, NixPath};
+use errno::Errno;
use fcntl::OFlag;
use libc::{self, c_int, c_void, size_t, off_t};
use sys::stat::Mode;
diff --git a/src/sys/ptrace.rs b/src/sys/ptrace.rs
index 43a78862..e2b153d8 100644
--- a/src/sys/ptrace.rs
+++ b/src/sys/ptrace.rs
@@ -1,7 +1,8 @@
//! For detailed description of the ptrace requests, consult `man ptrace`.
use std::{mem, ptr};
-use {Errno, Error, Result};
+use {Error, Result};
+use errno::Errno;
use libc::{self, c_void, c_long, siginfo_t};
use ::unistd::Pid;
use sys::signal::Signal;
diff --git a/src/sys/quota.rs b/src/sys/quota.rs
index 4a8fdf5e..abe114f0 100644
--- a/src/sys/quota.rs
+++ b/src/sys/quota.rs
@@ -15,7 +15,8 @@
use std::default::Default;
use std::{mem, ptr};
use libc::{self, c_int, c_char};
-use {Errno, Result, NixPath};
+use {Result, NixPath};
+use errno::Errno;
struct QuotaCmd(QuotaSubCmd, QuotaType);
diff --git a/src/sys/reboot.rs b/src/sys/reboot.rs
index 5b340e32..bafa8fc1 100644
--- a/src/sys/reboot.rs
+++ b/src/sys/reboot.rs
@@ -1,6 +1,7 @@
//! Reboot/shutdown or enable/disable Ctrl-Alt-Delete.
-use {Errno, Error, Result};
+use {Error, Result};
+use errno::Errno;
use libc;
use void::Void;
use std::mem::drop;
diff --git a/src/sys/select.rs b/src/sys/select.rs
index 252fa6bc..9a429103 100644
--- a/src/sys/select.rs
+++ b/src/sys/select.rs
@@ -2,7 +2,8 @@ use std::mem;
use std::os::unix::io::RawFd;
use std::ptr::null_mut;
use libc::{self, c_int};
-use {Errno, Result};
+use Result;
+use errno::Errno;
use sys::time::TimeVal;
pub use libc::FD_SETSIZE;
diff --git a/src/sys/sendfile.rs b/src/sys/sendfile.rs
index 2c39ea90..7f7a7751 100644
--- a/src/sys/sendfile.rs
+++ b/src/sys/sendfile.rs
@@ -3,7 +3,8 @@ use std::ptr;
use libc::{self, off_t};
-use {Errno, Result};
+use Result;
+use errno::Errno;
pub fn sendfile(out_fd: RawFd, in_fd: RawFd, offset: Option<&mut off_t>, count: usize) -> Result<usize> {
let offset = offset.map(|offset| offset as *mut _).unwrap_or(ptr::null_mut());
diff --git a/src/sys/signal.rs b/src/sys/signal.rs
index 967c6416..f82e4502 100644
--- a/src/sys/signal.rs
+++ b/src/sys/signal.rs
@@ -2,7 +2,8 @@
// See http://rust-lang.org/COPYRIGHT.
use libc;
-use {Errno, Error, Result};
+use {Error, Result};
+use errno::Errno;
use std::mem;
#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
use std::os::unix::io::RawFd;
diff --git a/src/sys/signalfd.rs b/src/sys/signalfd.rs
index bbd38b23..7ea09ee3 100644
--- a/src/sys/signalfd.rs
+++ b/src/sys/signalfd.rs
@@ -17,7 +17,8 @@
//! signal handlers.
use libc;
use unistd;
-use {Error, Errno, Result};
+use {Error, Result};
+use errno::Errno;
pub use sys::signal::{self, SigSet};
pub use libc::signalfd_siginfo as siginfo;
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs
index 29832b37..9917fdfd 100644
--- a/src/sys/socket/addr.rs
+++ b/src/sys/socket/addr.rs
@@ -1,5 +1,6 @@
use super::sa_family_t;
-use {Errno, Error, Result, NixPath};
+use {Error, Result, NixPath};
+use errno::Errno;
use libc;
use std::{fmt, hash, mem, net, ptr, slice};
use std::ffi::OsStr;
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index cdb8b4b3..c7d6d581 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -1,7 +1,8 @@
//! Socket interface functions
//!
//! [Further reading](http://man7.org/linux/man-pages/man7/socket.7.html)
-use {Error, Errno, Result};
+use {Error, Result};
+use errno::Errno;
use features;
use libc::{self, c_void, c_int, socklen_t, size_t, pid_t, uid_t, gid_t};
use std::{mem, ptr, slice};
diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs
index 98a4eeac..4741ec66 100644
--- a/src/sys/socket/sockopt.rs
+++ b/src/sys/socket/sockopt.rs
@@ -1,5 +1,6 @@
use super::{GetSockOpt, SetSockOpt};
-use {Errno, Result};
+use Result;
+use errno::Errno;
use sys::time::TimeVal;
use libc::{self, c_int, uint8_t, c_void, socklen_t};
use std::mem;
diff --git a/src/sys/stat.rs b/src/sys/stat.rs
index 7a0b3970..9c0129f5 100644
--- a/src/sys/stat.rs
+++ b/src/sys/stat.rs
@@ -1,7 +1,8 @@
pub use libc::dev_t;
pub use libc::stat as FileStat;
-use {Errno, Result, NixPath};
+use {Result, NixPath};
+use errno::Errno;
use fcntl::AtFlags;
use libc::{self, mode_t};
use std::mem;
diff --git a/src/sys/statfs.rs b/src/sys/statfs.rs
index afa61468..6d4fafe9 100644
--- a/src/sys/statfs.rs
+++ b/src/sys/statfs.rs
@@ -1,4 +1,5 @@
-use {Errno, Result, NixPath};
+use {Result, NixPath};
+use errno::Errno;
use std::os::unix::io::AsRawFd;
use libc;
diff --git a/src/sys/statvfs.rs b/src/sys/statvfs.rs
index 2cfc61af..0a0dab7f 100644
--- a/src/sys/statvfs.rs
+++ b/src/sys/statvfs.rs
@@ -7,7 +7,8 @@ use std::os::unix::io::AsRawFd;
use libc::{self, c_ulong};
-use {Errno, Result, NixPath};
+use {Result, NixPath};
+use errno::Errno;
bitflags!(
/// File system mount Flags
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index 34d960ff..e27cee40 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
@@ -43,7 +43,8 @@
//! termios.control_flags |= ControlFlags::CS5;
//! ```
-use {Errno, Result};
+use Result;
+use errno::Errno;
use libc::{self, c_int, tcflag_t};
use std::cell::{Ref, RefCell};
use std::convert::From;
diff --git a/src/sys/uio.rs b/src/sys/uio.rs
index 16426ab9..cd161423 100644
--- a/src/sys/uio.rs
+++ b/src/sys/uio.rs
@@ -1,7 +1,8 @@
// Silence invalid warnings due to rust-lang/rust#16719
#![allow(improper_ctypes)]
-use {Errno, Result};
+use Result;
+use errno::Errno;
use libc::{self, c_int, c_void, size_t, off_t};
use std::marker::PhantomData;
use std::os::unix::io::RawFd;
diff --git a/src/sys/wait.rs b/src/sys/wait.rs
index 019b751f..6243634f 100644
--- a/src/sys/wait.rs
+++ b/src/sys/wait.rs
@@ -1,5 +1,6 @@
use libc::{self, c_int};
-use {Errno, Result};
+use Result;
+use errno::Errno;
use unistd::Pid;
use sys::signal::Signal;
diff --git a/src/ucontext.rs b/src/ucontext.rs
index 6886dd41..da5a5b13 100644
--- a/src/ucontext.rs
+++ b/src/ucontext.rs
@@ -1,6 +1,8 @@
use libc;
#[cfg(not(target_env = "musl"))]
-use {Errno, Result};
+use Result;
+#[cfg(not(target_env = "musl"))]
+use errno::Errno;
use std::mem;
use sys::signal::SigSet;
diff --git a/src/unistd.rs b/src/unistd.rs
index 4e27d675..c3c78414 100644
--- a/src/unistd.rs
+++ b/src/unistd.rs
@@ -1,7 +1,7 @@
//! Safe wrappers around functions found in libc "unistd.h" header
-use errno;
-use {Errno, Error, Result, NixPath};
+use errno::{self, Errno};
+use {Error, Result, NixPath};
use fcntl::{fcntl, FdFlag, OFlag};
use fcntl::FcntlArg::F_SETFD;
use libc::{self, c_char, c_void, c_int, c_long, c_uint, size_t, pid_t, off_t,
@@ -1942,7 +1942,8 @@ pub fn sysconf(var: SysconfVar) -> Result<Option<c_long>> {
#[cfg(any(target_os = "android", target_os = "linux"))]
mod pivot_root {
use libc;
- use {Errno, Result, NixPath};
+ use {Result, NixPath};
+ use errno::Errno;
pub fn pivot_root<P1: ?Sized + NixPath, P2: ?Sized + NixPath>(
new_root: &P1, put_old: &P2) -> Result<()> {
@@ -1962,7 +1963,8 @@ mod pivot_root {
target_os = "linux", target_os = "openbsd"))]
mod setres {
use libc;
- use {Errno, Result};
+ use Result;
+ use errno::Errno;
use super::{Uid, Gid};
/// Sets the real, effective, and saved uid.