summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBryant Mairs <bryantmairs@google.com>2017-11-21 22:27:15 -0800
committerBryant Mairs <bryantmairs@google.com>2017-12-02 10:46:34 -0800
commite1baab9dc132f18e13f446df0271a5e46723848d (patch)
tree3e4e6714d843edc493dfc3cf879d659bbd264e65 /src
parentd374a1ecd3f69027a2ce28e87806f459ef3f9105 (diff)
downloadnix-e1baab9dc132f18e13f446df0271a5e46723848d.zip
Upgrade to Bitflags 1.0
The libc_bitflags! macro was replaced with a non-recursive one supporting only public structs. I could not figure out how to make the old macro work with the upgrade, so I reworked part of the bitflags! macro directly to suit our needs, much as the original recursive macro was made. There are no uses of this macro for non-public structs, so this is not a problem for internal code.
Diffstat (limited to 'src')
-rw-r--r--src/macros.rs211
-rw-r--r--src/mqueue.rs2
-rw-r--r--src/pty.rs10
-rw-r--r--src/sys/event.rs4
-rw-r--r--src/sys/quota.rs20
-rw-r--r--src/sys/signal.rs10
-rw-r--r--src/sys/signalfd.rs6
-rw-r--r--src/sys/socket/mod.rs34
-rw-r--r--src/sys/termios.rs6
-rw-r--r--src/unistd.rs26
10 files changed, 75 insertions, 254 deletions
diff --git a/src/macros.rs b/src/macros.rs
index 39bc466d..15f7505c 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -1,6 +1,6 @@
-/// The `libc_bitflags!` macro helps with a common use case of defining bitflags with values from
-/// the libc crate. It is used the same way as the `bitflags!` macro, except that only the name of
-/// the flag value has to be given.
+/// The `libc_bitflags!` macro helps with a common use case of defining a public bitflags type
+/// with values from the libc crate. It is used the same way as the `bitflags!` macro, except
+/// that only the name of the flag value has to be given.
///
/// The `libc` crate must be in scope with the name `libc`.
///
@@ -10,6 +10,7 @@
/// pub struct ProtFlags: libc::c_int {
/// PROT_NONE;
/// PROT_READ;
+/// /// PROT_WRITE enables write protect
/// PROT_WRITE;
/// PROT_EXEC;
/// #[cfg(any(target_os = "linux", target_os = "android"))]
@@ -38,205 +39,25 @@
/// }
/// ```
macro_rules! libc_bitflags {
- // (non-pub) Exit rule.
- (@call_bitflags
- {
- name: $BitFlags:ident,
- type: $T:ty,
- attrs: [$($attrs:tt)*],
- flags: [$($flags:tt)*],
- }
- ) => {
- bitflags! {
- $($attrs)*
- struct $BitFlags: $T {
- $($flags)*
- }
- }
- };
-
- // (pub) Exit rule.
- (@call_bitflags
- {
- pub,
- name: $BitFlags:ident,
- type: $T:ty,
- attrs: [$($attrs:tt)*],
- flags: [$($flags:tt)*],
+ (
+ $(#[$outer:meta])*
+ pub struct $BitFlags:ident: $T:ty {
+ $(
+ $(#[$inner:ident $($args:tt)*])*
+ $Flag:ident $(as $cast:ty)*;
+ )+
}
) => {
bitflags! {
- $($attrs)*
+ $(#[$outer])*
pub struct $BitFlags: $T {
- $($flags)*
- }
- }
- };
-
- // (non-pub) Done accumulating.
- (@accumulate_flags
- {
- name: $BitFlags:ident,
- type: $T:ty,
- attrs: $attrs:tt,
- },
- $flags:tt;
- ) => {
- libc_bitflags! {
- @call_bitflags
- {
- name: $BitFlags,
- type: $T,
- attrs: $attrs,
- flags: $flags,
+ $(
+ $(#[$inner $($args)*])*
+ const $Flag = libc::$Flag $(as $cast)*;
+ )+
}
}
};
-
- // (pub) Done accumulating.
- (@accumulate_flags
- {
- pub,
- name: $BitFlags:ident,
- type: $T:ty,
- attrs: $attrs:tt,
- },
- $flags:tt;
- ) => {
- libc_bitflags! {
- @call_bitflags
- {
- pub,
- name: $BitFlags,
- type: $T,
- attrs: $attrs,
- flags: $flags,
- }
- }
- };
-
- // Munch an attr.
- (@accumulate_flags
- $prefix:tt,
- [$($flags:tt)*];
- #[$attr:meta] $($tail:tt)*
- ) => {
- libc_bitflags! {
- @accumulate_flags
- $prefix,
- [
- $($flags)*
- #[$attr]
- ];
- $($tail)*
- }
- };
-
- // Munch last ident if not followed by a semicolon.
- (@accumulate_flags
- $prefix:tt,
- [$($flags:tt)*];
- $flag:ident
- ) => {
- libc_bitflags! {
- @accumulate_flags
- $prefix,
- [
- $($flags)*
- const $flag = libc::$flag;
- ];
- }
- };
-
- // Munch last ident and cast it to the given type.
- (@accumulate_flags
- $prefix:tt,
- [$($flags:tt)*];
- $flag:ident as $ty:ty
- ) => {
- libc_bitflags! {
- @accumulate_flags
- $prefix,
- [
- $($flags)*
- const $flag = libc::$flag as $ty;
- ];
- }
- };
-
- // Munch an ident; covers terminating semicolon case.
- (@accumulate_flags
- $prefix:tt,
- [$($flags:tt)*];
- $flag:ident; $($tail:tt)*
- ) => {
- libc_bitflags! {
- @accumulate_flags
- $prefix,
- [
- $($flags)*
- const $flag = libc::$flag;
- ];
- $($tail)*
- }
- };
-
- // Munch an ident and cast it to the given type; covers terminating semicolon
- // case.
- (@accumulate_flags
- $prefix:tt,
- [$($flags:tt)*];
- $flag:ident as $ty:ty; $($tail:tt)*
- ) => {
- libc_bitflags! {
- @accumulate_flags
- $prefix,
- [
- $($flags)*
- const $flag = libc::$flag as $ty;
- ];
- $($tail)*
- }
- };
-
- // (non-pub) Entry rule.
- (
- $(#[$attr:meta])*
- struct $BitFlags:ident: $T:ty {
- $($vals:tt)*
- }
- ) => {
- libc_bitflags! {
- @accumulate_flags
- {
- name: $BitFlags,
- type: $T,
- attrs: [$(#[$attr])*],
- },
- [];
- $($vals)*
- }
- };
-
- // (pub) Entry rule.
- (
- $(#[$attr:meta])*
- pub struct $BitFlags:ident: $T:ty {
- $($vals:tt)*
- }
- ) => {
- libc_bitflags! {
- @accumulate_flags
- {
- pub,
- name: $BitFlags,
- type: $T,
- attrs: [$(#[$attr])*],
- },
- [];
- $($vals)*
- }
- };
}
/// The `libc_enum!` macro helps with a common use case of defining an enum exclusively using
diff --git a/src/mqueue.rs b/src/mqueue.rs
index b4a791c9..4c88045c 100644
--- a/src/mqueue.rs
+++ b/src/mqueue.rs
@@ -151,7 +151,7 @@ pub fn mq_setattr(mqd: mqd_t, newattr: &MqAttr) -> Result<MqAttr> {
/// Returns the old attributes
pub fn mq_set_nonblock(mqd: mqd_t) -> Result<(MqAttr)> {
let oldattr = try!(mq_getattr(mqd));
- let newattr = MqAttr::new(O_NONBLOCK.bits() as c_long,
+ let newattr = MqAttr::new(MQ_OFlag::O_NONBLOCK.bits() as c_long,
oldattr.mq_attr.mq_maxmsg,
oldattr.mq_attr.mq_msgsize,
oldattr.mq_attr.mq_curmsgs);
diff --git a/src/pty.rs b/src/pty.rs
index 98443d61..dbf34208 100644
--- a/src/pty.rs
+++ b/src/pty.rs
@@ -86,14 +86,14 @@ pub fn grantpt(fd: &PtyMaster) -> Result<()> {
///
/// ```
/// use std::path::Path;
-/// use nix::fcntl::{O_RDWR, open};
-/// use nix::pty::*;
-/// use nix::sys::stat;
+/// use nix::fcntl::{OFlag, open};
+/// use nix::pty::{grantpt, posix_openpt, ptsname, unlockpt};
+/// use nix::sys::stat::Mode;
///
/// # #[allow(dead_code)]
/// # fn run() -> nix::Result<()> {
/// // Open a new PTY master
-/// let master_fd = posix_openpt(O_RDWR)?;
+/// let master_fd = posix_openpt(OFlag::O_RDWR)?;
///
/// // Allow a slave to be generated for it
/// grantpt(&master_fd)?;
@@ -104,7 +104,7 @@ pub fn grantpt(fd: &PtyMaster) -> Result<()> {
///
/// // Try to open the slave
/// # #[allow(unused_variables)]
-/// let slave_fd = open(Path::new(&slave_name), O_RDWR, stat::Mode::empty())?;
+/// let slave_fd = open(Path::new(&slave_name), OFlag::O_RDWR, Mode::empty())?;
/// # Ok(())
/// # }
/// ```
diff --git a/src/sys/event.rs b/src/sys/event.rs
index 189f8239..e63fe502 100644
--- a/src/sys/event.rs
+++ b/src/sys/event.rs
@@ -320,8 +320,8 @@ fn test_struct_kevent() {
udata: udata as type_of_udata};
let actual = KEvent::new(0xdeadbeef,
EventFilter::EVFILT_READ,
- EV_ONESHOT | EV_ADD,
- NOTE_CHILD | NOTE_EXIT,
+ EventFlag::EV_ONESHOT | EventFlag::EV_ADD,
+ FilterFlag::NOTE_CHILD | FilterFlag::NOTE_EXIT,
0x1337,
udata);
assert!(expected.ident == actual.ident());
diff --git a/src/sys/quota.rs b/src/sys/quota.rs
index 77b13335..4a8fdf5e 100644
--- a/src/sys/quota.rs
+++ b/src/sys/quota.rs
@@ -5,12 +5,12 @@
//! Enabling and setting a quota:
//!
//! ```rust,no_run
-//! # use nix::sys::quota::*;
+//! # use nix::sys::quota::{Dqblk, quotactl_on, quotactl_set, QuotaFmt, QuotaType, QuotaValidFlags};
//! quotactl_on(QuotaType::USRQUOTA, "/dev/sda1", QuotaFmt::QFMT_VFS_V1, "aquota.user");
//! let mut dqblk: Dqblk = Default::default();
//! dqblk.set_blocks_hard_limit(10000);
//! dqblk.set_blocks_soft_limit(8000);
-//! quotactl_set(QuotaType::USRQUOTA, "/dev/sda1", 50, &dqblk, QIF_BLIMITS);
+//! quotactl_set(QuotaType::USRQUOTA, "/dev/sda1", 50, &dqblk, QuotaValidFlags::QIF_BLIMITS);
//! ```
use std::default::Default;
use std::{mem, ptr};
@@ -121,7 +121,7 @@ impl Dqblk {
/// The absolute limit on disk quota blocks allocated.
pub fn blocks_hard_limit(&self) -> Option<u64> {
let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid);
- if valid_fields.contains(QIF_BLIMITS) {
+ if valid_fields.contains(QuotaValidFlags::QIF_BLIMITS) {
Some(self.0.dqb_bhardlimit)
} else {
None
@@ -136,7 +136,7 @@ impl Dqblk {
/// Preferred limit on disk quota blocks
pub fn blocks_soft_limit(&self) -> Option<u64> {
let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid);
- if valid_fields.contains(QIF_BLIMITS) {
+ if valid_fields.contains(QuotaValidFlags::QIF_BLIMITS) {
Some(self.0.dqb_bsoftlimit)
} else {
None
@@ -151,7 +151,7 @@ impl Dqblk {
/// Current occupied space (bytes).
pub fn occupied_space(&self) -> Option<u64> {
let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid);
- if valid_fields.contains(QIF_SPACE) {
+ if valid_fields.contains(QuotaValidFlags::QIF_SPACE) {
Some(self.0.dqb_curspace)
} else {
None
@@ -161,7 +161,7 @@ impl Dqblk {
/// Maximum number of allocated inodes.
pub fn inodes_hard_limit(&self) -> Option<u64> {
let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid);
- if valid_fields.contains(QIF_ILIMITS) {
+ if valid_fields.contains(QuotaValidFlags::QIF_ILIMITS) {
Some(self.0.dqb_ihardlimit)
} else {
None
@@ -176,7 +176,7 @@ impl Dqblk {
/// Preferred inode limit
pub fn inodes_soft_limit(&self) -> Option<u64> {
let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid);
- if valid_fields.contains(QIF_ILIMITS) {
+ if valid_fields.contains(QuotaValidFlags::QIF_ILIMITS) {
Some(self.0.dqb_isoftlimit)
} else {
None
@@ -191,7 +191,7 @@ impl Dqblk {
/// Current number of allocated inodes.
pub fn allocated_inodes(&self) -> Option<u64> {
let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid);
- if valid_fields.contains(QIF_INODES) {
+ if valid_fields.contains(QuotaValidFlags::QIF_INODES) {
Some(self.0.dqb_curinodes)
} else {
None
@@ -201,7 +201,7 @@ impl Dqblk {
/// Time limit for excessive disk use.
pub fn block_time_limit(&self) -> Option<u64> {
let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid);
- if valid_fields.contains(QIF_BTIME) {
+ if valid_fields.contains(QuotaValidFlags::QIF_BTIME) {
Some(self.0.dqb_btime)
} else {
None
@@ -216,7 +216,7 @@ impl Dqblk {
/// Time limit for excessive files.
pub fn inode_time_limit(&self) -> Option<u64> {
let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid);
- if valid_fields.contains(QIF_ITIME) {
+ if valid_fields.contains(QuotaValidFlags::QIF_ITIME) {
Some(self.0.dqb_itime)
} else {
None
diff --git a/src/sys/signal.rs b/src/sys/signal.rs
index 093fdb8e..967c6416 100644
--- a/src/sys/signal.rs
+++ b/src/sys/signal.rs
@@ -373,8 +373,8 @@ impl SigAction {
SigHandler::SigAction(f) => f as *const extern fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void) as usize,
};
s.sa_flags = match handler {
- SigHandler::SigAction(_) => (flags | SA_SIGINFO).bits(),
- _ => (flags - SA_SIGINFO).bits(),
+ SigHandler::SigAction(_) => (flags | SaFlags::SA_SIGINFO).bits(),
+ _ => (flags - SaFlags::SA_SIGINFO).bits(),
};
s.sa_mask = mask.sigset;
@@ -393,7 +393,7 @@ impl SigAction {
match self.sigaction.sa_sigaction {
libc::SIG_DFL => SigHandler::SigDfl,
libc::SIG_IGN => SigHandler::SigIgn,
- f if self.flags().contains(SA_SIGINFO) =>
+ f if self.flags().contains(SaFlags::SA_SIGINFO) =>
SigHandler::SigAction( unsafe { mem::transmute(f) } ),
f => SigHandler::Handler( unsafe { mem::transmute(f) } ),
}
@@ -713,14 +713,14 @@ mod tests {
let handler_sig = SigHandler::Handler(test_sigaction_handler);
- let flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO;
+ let flags = SaFlags::SA_ONSTACK | SaFlags::SA_RESTART | SaFlags::SA_SIGINFO;
let mut mask = SigSet::empty();
mask.add(SIGUSR1);
let action_sig = SigAction::new(handler_sig, flags, mask);
- assert_eq!(action_sig.flags(), SA_ONSTACK | SA_RESTART);
+ assert_eq!(action_sig.flags(), SaFlags::SA_ONSTACK | SaFlags::SA_RESTART);
assert_eq!(action_sig.handler(), handler_sig);
mask = action_sig.mask();
diff --git a/src/sys/signalfd.rs b/src/sys/signalfd.rs
index abc96b8c..bbd38b23 100644
--- a/src/sys/signalfd.rs
+++ b/src/sys/signalfd.rs
@@ -67,7 +67,7 @@ pub fn signalfd(fd: RawFd, mask: &SigSet, flags: SfdFlags) -> Result<RawFd> {
/// mask.thread_block().unwrap();
///
/// // Signals are queued up on the file descriptor
-/// let mut sfd = SignalFd::with_flags(&mask, SFD_NONBLOCK).unwrap();
+/// let mut sfd = SignalFd::with_flags(&mask, SfdFlags::SFD_NONBLOCK).unwrap();
///
/// match sfd.read_signal() {
/// // we caught a signal
@@ -155,14 +155,14 @@ mod tests {
#[test]
fn create_signalfd_with_opts() {
let mask = SigSet::empty();
- let fd = SignalFd::with_flags(&mask, SFD_CLOEXEC | SFD_NONBLOCK);
+ let fd = SignalFd::with_flags(&mask, SfdFlags::SFD_CLOEXEC | SfdFlags::SFD_NONBLOCK);
assert!(fd.is_ok());
}
#[test]
fn read_empty_signalfd() {
let mask = SigSet::empty();
- let mut fd = SignalFd::with_flags(&mask, SFD_NONBLOCK).unwrap();
+ let mut fd = SignalFd::with_flags(&mask, SfdFlags::SFD_NONBLOCK).unwrap();
let res = fd.read_signal();
assert!(res.unwrap().is_none());
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index e333f005..cdb8b4b3 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -571,16 +571,16 @@ pub fn socket<T: Into<Option<SockProtocol>>>(domain: AddressFamily, ty: SockType
target_os = "netbsd",
target_os = "openbsd"))]
{
- use fcntl::{fcntl, FD_CLOEXEC, O_NONBLOCK};
+ use fcntl::{fcntl, FdFlag, OFlag};
use fcntl::FcntlArg::{F_SETFD, F_SETFL};
if !feat_atomic {
- if flags.contains(SOCK_CLOEXEC) {
- try!(fcntl(res, F_SETFD(FD_CLOEXEC)));
+ if flags.contains(SockFlag::SOCK_CLOEXEC) {
+ try!(fcntl(res, F_SETFD(FdFlag::FD_CLOEXEC)));
}
- if flags.contains(SOCK_NONBLOCK) {
- try!(fcntl(res, F_SETFL(O_NONBLOCK)));
+ if flags.contains(SockFlag::SOCK_NONBLOCK) {
+ try!(fcntl(res, F_SETFL(OFlag::O_NONBLOCK)));
}
}
}
@@ -616,18 +616,18 @@ pub fn socketpair<T: Into<Option<SockProtocol>>>(domain: AddressFamily, ty: Sock
target_os = "netbsd",
target_os = "openbsd"))]
{
- use fcntl::{fcntl, FD_CLOEXEC, O_NONBLOCK};
+ use fcntl::{fcntl, FdFlag, OFlag};
use fcntl::FcntlArg::{F_SETFD, F_SETFL};
if !feat_atomic {
- if flags.contains(SOCK_CLOEXEC) {
- try!(fcntl(fds[0], F_SETFD(FD_CLOEXEC)));
- try!(fcntl(fds[1], F_SETFD(FD_CLOEXEC)));
+ if flags.contains(SockFlag::SOCK_CLOEXEC) {
+ try!(fcntl(fds[0], F_SETFD(FdFlag::FD_CLOEXEC)));
+ try!(fcntl(fds[1], F_SETFD(FdFlag::FD_CLOEXEC)));
}
- if flags.contains(SOCK_NONBLOCK) {
- try!(fcntl(fds[0], F_SETFL(O_NONBLOCK)));
- try!(fcntl(fds[1], F_SETFL(O_NONBLOCK)));
+ if flags.contains(SockFlag::SOCK_NONBLOCK) {
+ try!(fcntl(fds[0], F_SETFL(OFlag::O_NONBLOCK)));
+ try!(fcntl(fds[1], F_SETFL(OFlag::O_NONBLOCK)));
}
}
}
@@ -698,15 +698,15 @@ fn accept4_polyfill(sockfd: RawFd, flags: SockFlag) -> Result<RawFd> {
target_os = "netbsd",
target_os = "openbsd"))]
{
- use fcntl::{fcntl, FD_CLOEXEC, O_NONBLOCK};
+ use fcntl::{fcntl, FdFlag, OFlag};
use fcntl::FcntlArg::{F_SETFD, F_SETFL};
- if flags.contains(SOCK_CLOEXEC) {
- try!(fcntl(res, F_SETFD(FD_CLOEXEC)));
+ if flags.contains(SockFlag::SOCK_CLOEXEC) {
+ try!(fcntl(res, F_SETFD(FdFlag::FD_CLOEXEC)));
}
- if flags.contains(SOCK_NONBLOCK) {
- try!(fcntl(res, F_SETFL(O_NONBLOCK)));
+ if flags.contains(SockFlag::SOCK_NONBLOCK) {
+ try!(fcntl(res, F_SETFL(OFlag::O_NONBLOCK)));
}
}
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index 89f18ee1..34d960ff 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
@@ -37,10 +37,10 @@
//! An example showing some of the basic operations for interacting with the control flags:
//!
//! ```
-//! # use self::nix::sys::termios::{CS5, CSIZE, Termios};
+//! # use self::nix::sys::termios::{ControlFlags, Termios};
//! # let mut termios = unsafe { Termios::default_uninit() };
-//! termios.control_flags & CSIZE == CS5;
-//! termios.control_flags |= CS5;
+//! termios.control_flags & ControlFlags::CSIZE == ControlFlags::CS5;
+//! termios.control_flags |= ControlFlags::CS5;
//! ```
use {Errno, Result};
diff --git a/src/unistd.rs b/src/unistd.rs
index 52dfbb70..4e27d675 100644
--- a/src/unistd.rs
+++ b/src/unistd.rs
@@ -2,7 +2,7 @@
use errno;
use {Errno, Error, Result, NixPath};
-use fcntl::{fcntl, OFlag, O_CLOEXEC, FD_CLOEXEC};
+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,
uid_t, gid_t, mode_t};
@@ -322,7 +322,7 @@ pub fn gettid() -> Pid {
/// underlying resource, offset, and file status flags. The actual index used
/// for the file descriptor will be the lowest fd index that is available.
///
-/// The two file descriptors do not share file descriptor flags (e.g. `FD_CLOEXEC`).
+/// The two file descriptors do not share file descriptor flags (e.g. `OFlag::FD_CLOEXEC`).
#[inline]
pub fn dup(oldfd: RawFd) -> Result<RawFd> {
let res = unsafe { libc::dup(oldfd) };
@@ -360,8 +360,8 @@ fn dup3_polyfill(oldfd: RawFd, newfd: RawFd, flags: OFlag) -> Result<RawFd> {
let fd = try!(dup2(oldfd, newfd));
- if flags.contains(O_CLOEXEC) {
- if let Err(e) = fcntl(fd, F_SETFD(FD_CLOEXEC)) {
+ if flags.contains(OFlag::O_CLOEXEC) {
+ if let Err(e) = fcntl(fd, F_SETFD(FdFlag::FD_CLOEXEC)) {
let _ = close(fd);
return Err(e);
}
@@ -422,7 +422,7 @@ pub fn fchdir(dirfd: RawFd) -> Result<()> {
/// let tmp_dir2 = tmp_dir1.path().join("new_dir");
///
/// // create new directory and give read, write and execute rights to the owner
-/// match unistd::mkdir(&tmp_dir2, stat::S_IRWXU) {
+/// match unistd::mkdir(&tmp_dir2, stat::Mode::S_IRWXU) {
/// Ok(_) => println!("created {:?}", tmp_dir2),
/// Err(err) => println!("Error creating directory: {}", err),
/// }
@@ -465,7 +465,7 @@ pub fn mkdir<P: ?Sized + NixPath>(path: &P, mode: Mode) -> Result<()> {
/// let fifo_path = tmp_dir.path().join("foo.pipe");
///
/// // create new fifo and give read, write and execute rights to the owner
-/// match unistd::mkfifo(&fifo_path, stat::S_IRWXU) {
+/// match unistd::mkfifo(&fifo_path, stat::Mode::S_IRWXU) {
/// Ok(_) => println!("created {:?}", fifo_path),
/// Err(err) => println!("Error creating fifo: {}", err),
/// }
@@ -909,21 +909,21 @@ pub fn pipe2(flags: OFlag) -> Result<(RawFd, RawFd)> {
target_os = "android",
target_os = "emscripten")))]
fn pipe2_setflags(fd1: RawFd, fd2: RawFd, flags: OFlag) -> Result<()> {
- use fcntl::O_NONBLOCK;
+ use fcntl::FdFlag;
use fcntl::FcntlArg::F_SETFL;
let mut res = Ok(0);
- if flags.contains(O_CLOEXEC) {
+ if flags.contains(OFlag::O_CLOEXEC) {
res = res
- .and_then(|_| fcntl(fd1, F_SETFD(FD_CLOEXEC)))
- .and_then(|_| fcntl(fd2, F_SETFD(FD_CLOEXEC)));
+ .and_then(|_| fcntl(fd1, F_SETFD(FdFlag::FD_CLOEXEC)))
+ .and_then(|_| fcntl(fd2, F_SETFD(FdFlag::FD_CLOEXEC)));
}
- if flags.contains(O_NONBLOCK) {
+ if flags.contains(OFlag::O_NONBLOCK) {
res = res
- .and_then(|_| fcntl(fd1, F_SETFL(O_NONBLOCK)))
- .and_then(|_| fcntl(fd2, F_SETFL(O_NONBLOCK)));
+ .and_then(|_| fcntl(fd1, F_SETFL(OFlag::O_NONBLOCK)))
+ .and_then(|_| fcntl(fd2, F_SETFL(OFlag::O_NONBLOCK)));
}
match res {