summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONVENTIONS.md2
-rw-r--r--Cargo.toml2
-rw-r--r--src/fcntl.rs24
-rw-r--r--src/macros.rs2
-rw-r--r--src/mount.rs4
-rw-r--r--src/mqueue.rs4
-rw-r--r--src/poll.rs2
-rw-r--r--src/sched.rs2
-rw-r--r--src/sys/epoll.rs4
-rw-r--r--src/sys/event.rs4
-rw-r--r--src/sys/eventfd.rs2
-rw-r--r--src/sys/memfd.rs2
-rw-r--r--src/sys/mman.rs14
-rw-r--r--src/sys/quota.rs2
-rw-r--r--src/sys/signal.rs2
-rw-r--r--src/sys/signalfd.rs2
-rw-r--r--src/sys/socket/consts.rs6
-rw-r--r--src/sys/socket/mod.rs2
-rw-r--r--src/sys/stat.rs4
-rw-r--r--src/sys/statvfs.rs2
-rw-r--r--src/sys/termios.rs16
-rw-r--r--src/sys/wait.rs29
22 files changed, 78 insertions, 55 deletions
diff --git a/CONVENTIONS.md b/CONVENTIONS.md
index 8abec905..d62e56ad 100644
--- a/CONVENTIONS.md
+++ b/CONVENTIONS.md
@@ -52,7 +52,7 @@ For example,
```rust
libc_bitflags!{
- flags ProtFlags: libc::c_int {
+ pub flags ProtFlags: libc::c_int {
PROT_NONE,
PROT_READ,
PROT_WRITE,
diff --git a/Cargo.toml b/Cargo.toml
index 43b074ee..8ac4fa50 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,7 +23,7 @@ signalfd = []
[dependencies]
libc = { git = "https://github.com/rust-lang/libc" }
-bitflags = "0.4"
+bitflags = "0.7"
cfg-if = "0.1.0"
void = "1.0.2"
diff --git a/src/fcntl.rs b/src/fcntl.rs
index 1d9ba499..29889b3d 100644
--- a/src/fcntl.rs
+++ b/src/fcntl.rs
@@ -138,7 +138,7 @@ mod consts {
use libc::{self, c_int, c_uint};
bitflags! {
- flags SpliceFFlags: c_uint {
+ pub flags SpliceFFlags: c_uint {
const SPLICE_F_MOVE = libc::SPLICE_F_MOVE,
const SPLICE_F_NONBLOCK = libc::SPLICE_F_NONBLOCK,
const SPLICE_F_MORE = libc::SPLICE_F_MORE,
@@ -147,7 +147,7 @@ mod consts {
}
bitflags!(
- flags OFlag: c_int {
+ pub flags OFlag: c_int {
const O_ACCMODE = 0o00000003,
const O_RDONLY = 0o00000000,
const O_WRONLY = 0o00000001,
@@ -173,13 +173,13 @@ mod consts {
);
bitflags!(
- flags FdFlag: c_int {
+ pub flags FdFlag: c_int {
const FD_CLOEXEC = 1
}
);
bitflags!(
- flags SealFlag: c_int {
+ pub flags SealFlag: c_int {
const F_SEAL_SEAL = 1,
const F_SEAL_SHRINK = 2,
const F_SEAL_GROW = 4,
@@ -194,7 +194,7 @@ mod consts {
use libc::c_int;
bitflags!(
- flags OFlag: c_int {
+ pub flags OFlag: c_int {
const O_ACCMODE = 0x0000003,
const O_RDONLY = 0x0000000,
const O_WRONLY = 0x0000001,
@@ -216,7 +216,7 @@ mod consts {
);
bitflags!(
- flags FdFlag: c_int {
+ pub flags FdFlag: c_int {
const FD_CLOEXEC = 1
}
);
@@ -227,7 +227,7 @@ mod consts {
use libc::c_int;
bitflags!(
- flags OFlag: c_int {
+ pub flags OFlag: c_int {
const O_ACCMODE = 0x0000003,
const O_RDONLY = 0x0000000,
const O_WRONLY = 0x0000001,
@@ -253,7 +253,7 @@ mod consts {
);
bitflags!(
- flags FdFlag: c_int {
+ pub flags FdFlag: c_int {
const FD_CLOEXEC = 1
}
);
@@ -264,7 +264,7 @@ mod consts {
use libc::c_int;
bitflags!(
- flags OFlag: c_int {
+ pub flags OFlag: c_int {
const O_ACCMODE = 0x0000003,
const O_RDONLY = 0x0000000,
const O_WRONLY = 0x0000001,
@@ -294,7 +294,7 @@ mod consts {
);
bitflags!(
- flags FdFlag: c_int {
+ pub flags FdFlag: c_int {
const FD_CLOEXEC = 1
}
);
@@ -305,7 +305,7 @@ mod consts {
use libc::c_int;
bitflags!(
- flags OFlag: c_int {
+ pub flags OFlag: c_int {
const O_ACCMODE = 0x0000003,
const O_RDONLY = 0x0000000,
const O_WRONLY = 0x0000001,
@@ -329,7 +329,7 @@ mod consts {
);
bitflags!(
- flags FdFlag: c_int {
+ pub flags FdFlag: c_int {
const FD_CLOEXEC = 1
}
);
diff --git a/src/macros.rs b/src/macros.rs
index 4954bed6..9d0613ad 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -7,7 +7,7 @@
/// # Example
/// ```
/// libc_bitflags!{
-/// flags ProtFlags: libc::c_int {
+/// pub flags ProtFlags: libc::c_int {
/// PROT_NONE,
/// PROT_READ,
/// PROT_WRITE,
diff --git a/src/mount.rs b/src/mount.rs
index 6cef3fb5..c784d737 100644
--- a/src/mount.rs
+++ b/src/mount.rs
@@ -3,7 +3,7 @@ use libc;
use {Errno, Result, NixPath};
bitflags!(
- flags MsFlags: c_ulong {
+ pub flags MsFlags: c_ulong {
const MS_RDONLY = 1 << 0, // Mount read-only
const MS_NOSUID = 1 << 1, // Ignore suid and sgid bits
const MS_NODEV = 1 << 2, // Disallow access to device special files
@@ -42,7 +42,7 @@ bitflags!(
);
bitflags!(
- flags MntFlags: c_int {
+ pub flags MntFlags: c_int {
const MNT_FORCE = 1 << 0,
const MNT_DETACH = 1 << 1,
const MNT_EXPIRE = 1 << 2
diff --git a/src/mqueue.rs b/src/mqueue.rs
index 9bf6e77e..2c127502 100644
--- a/src/mqueue.rs
+++ b/src/mqueue.rs
@@ -10,7 +10,7 @@ use sys::stat::Mode;
use std::mem;
libc_bitflags!{
- flags MQ_OFlag: libc::c_int {
+ pub flags MQ_OFlag: libc::c_int {
O_RDONLY,
O_WRONLY,
O_RDWR,
@@ -22,7 +22,7 @@ libc_bitflags!{
}
libc_bitflags!{
- flags FdFlag: libc::c_int {
+ pub flags FdFlag: libc::c_int {
FD_CLOEXEC,
}
}
diff --git a/src/poll.rs b/src/poll.rs
index 6ba9f5e4..72988d8c 100644
--- a/src/poll.rs
+++ b/src/poll.rs
@@ -24,7 +24,7 @@ impl PollFd {
}
libc_bitflags! {
- flags EventFlags: libc::c_short {
+ pub flags EventFlags: libc::c_short {
POLLIN,
POLLPRI,
POLLOUT,
diff --git a/src/sched.rs b/src/sched.rs
index 66b4ed4f..dee3107e 100644
--- a/src/sched.rs
+++ b/src/sched.rs
@@ -7,7 +7,7 @@ use {Errno, Error, Result};
// For some functions taking with a parameter of type CloneFlags,
// only a subset of these flags have an effect.
libc_bitflags!{
- flags CloneFlags: libc::c_int {
+ pub flags CloneFlags: libc::c_int {
CLONE_VM,
CLONE_FS,
CLONE_FILES,
diff --git a/src/sys/epoll.rs b/src/sys/epoll.rs
index eb28ffb9..62ad4319 100644
--- a/src/sys/epoll.rs
+++ b/src/sys/epoll.rs
@@ -7,7 +7,7 @@ use ::Error;
bitflags!(
#[repr(C)]
- flags EpollFlags: u32 {
+ pub flags EpollFlags: u32 {
const EPOLLIN = 0x001,
const EPOLLPRI = 0x002,
const EPOLLOUT = 0x004,
@@ -35,7 +35,7 @@ pub enum EpollOp {
}
libc_bitflags!{
- flags EpollCreateFlags: c_int {
+ pub flags EpollCreateFlags: c_int {
EPOLL_CLOEXEC,
}
}
diff --git a/src/sys/event.rs b/src/sys/event.rs
index 405f38fc..f1ba1f4c 100644
--- a/src/sys/event.rs
+++ b/src/sys/event.rs
@@ -78,7 +78,7 @@ pub type type_of_event_flag = u16;
#[cfg(any(target_os = "netbsd", target_os = "openbsd"))]
pub type type_of_event_flag = u32;
libc_bitflags!{
- flags EventFlag: type_of_event_flag {
+ pub flags EventFlag: type_of_event_flag {
EV_ADD,
EV_CLEAR,
EV_DELETE,
@@ -106,7 +106,7 @@ libc_bitflags!{
}
bitflags!(
- flags FilterFlag: u32 {
+ pub flags FilterFlag: u32 {
#[cfg(any(target_os = "macos", target_os = "ios"))]
const NOTE_ABSOLUTE = libc::NOTE_ABSOLUTE,
const NOTE_ATTRIB = libc::NOTE_ATTRIB,
diff --git a/src/sys/eventfd.rs b/src/sys/eventfd.rs
index 8058e207..ad23dec7 100644
--- a/src/sys/eventfd.rs
+++ b/src/sys/eventfd.rs
@@ -3,7 +3,7 @@ use std::os::unix::io::RawFd;
use {Errno, Result};
libc_bitflags! {
- flags EfdFlags: libc::c_int {
+ pub flags EfdFlags: libc::c_int {
EFD_CLOEXEC, // Since Linux 2.6.27
EFD_NONBLOCK, // Since Linux 2.6.27
EFD_SEMAPHORE, // Since Linux 2.6.30
diff --git a/src/sys/memfd.rs b/src/sys/memfd.rs
index 1cd94150..b0735009 100644
--- a/src/sys/memfd.rs
+++ b/src/sys/memfd.rs
@@ -4,7 +4,7 @@ use {Errno, Result};
use std::ffi::CStr;
bitflags!(
- flags MemFdCreateFlag: libc::c_uint {
+ pub flags MemFdCreateFlag: libc::c_uint {
const MFD_CLOEXEC = 0x0001,
const MFD_ALLOW_SEALING = 0x0002,
}
diff --git a/src/sys/mman.rs b/src/sys/mman.rs
index a1bf6134..d0099541 100644
--- a/src/sys/mman.rs
+++ b/src/sys/mman.rs
@@ -7,7 +7,7 @@ use std::os::unix::io::RawFd;
pub use self::consts::*;
libc_bitflags!{
- flags ProtFlags: libc::c_int {
+ pub flags ProtFlags: libc::c_int {
PROT_NONE,
PROT_READ,
PROT_WRITE,
@@ -24,7 +24,7 @@ mod consts {
use libc::{self, c_int};
bitflags!{
- flags MapFlags: c_int {
+ pub flags MapFlags: c_int {
const MAP_FILE = libc::MAP_FILE,
const MAP_SHARED = libc::MAP_SHARED,
const MAP_PRIVATE = libc::MAP_PRIVATE,
@@ -65,7 +65,7 @@ mod consts {
bitflags!{
- flags MsFlags: c_int {
+ pub flags MsFlags: c_int {
const MS_ASYNC = libc::MS_ASYNC,
const MS_INVALIDATE = libc::MS_INVALIDATE,
const MS_SYNC = libc::MS_SYNC,
@@ -81,7 +81,7 @@ mod consts {
use libc::{self, c_int};
bitflags!{
- flags MapFlags: c_int {
+ pub flags MapFlags: c_int {
const MAP_FILE = libc::MAP_FILE,
const MAP_SHARED = libc::MAP_SHARED,
const MAP_PRIVATE = libc::MAP_PRIVATE,
@@ -106,7 +106,7 @@ mod consts {
pub const MADV_CAN_REUSE : MmapAdvise = 9;
bitflags!{
- flags MsFlags: c_int {
+ pub flags MsFlags: c_int {
const MS_ASYNC = libc::MS_ASYNC, /* [MF|SIO] return immediately */
const MS_INVALIDATE = libc::MS_INVALIDATE, /* [MF|SIO] invalidate all cached data */
const MS_KILLPAGES = libc::MS_KILLPAGES, /* invalidate pages, leave mapped */
@@ -123,7 +123,7 @@ mod consts {
use libc::{self, c_int};
bitflags!{
- flags MapFlags: c_int {
+ pub flags MapFlags: c_int {
const MAP_FILE = libc::MAP_FILE,
const MAP_SHARED = libc::MAP_SHARED,
const MAP_PRIVATE = libc::MAP_PRIVATE,
@@ -161,7 +161,7 @@ mod consts {
pub const MADV_SETMAP : MmapAdvise = 11; /* set page table directory page for map */
bitflags!{
- flags MsFlags: c_int {
+ pub flags MsFlags: c_int {
const MS_ASYNC = libc::MS_ASYNC, /* [MF|SIO] return immediately */
const MS_INVALIDATE = libc::MS_INVALIDATE, /* [MF|SIO] invalidate all cached data */
#[cfg(not(target_os = "dragonfly"))]
diff --git a/src/sys/quota.rs b/src/sys/quota.rs
index a6a1b9b0..321156ec 100644
--- a/src/sys/quota.rs
+++ b/src/sys/quota.rs
@@ -41,7 +41,7 @@ pub mod quota {
bitflags!(
#[derive(Default)]
- flags QuotaValidFlags: u32 {
+ pub flags QuotaValidFlags: u32 {
const QIF_BLIMITS = 1,
const QIF_SPACE = 2,
const QIF_ILIMITS = 4,
diff --git a/src/sys/signal.rs b/src/sys/signal.rs
index 26cf51fd..2f1baefa 100644
--- a/src/sys/signal.rs
+++ b/src/sys/signal.rs
@@ -197,7 +197,7 @@ pub const SIGPOLL : Signal = SIGIO;
pub const SIGUNUSED : Signal = SIGSYS;
bitflags!{
- flags SaFlags: libc::c_int {
+ pub flags SaFlags: libc::c_int {
const SA_NOCLDSTOP = libc::SA_NOCLDSTOP,
const SA_NOCLDWAIT = libc::SA_NOCLDWAIT,
const SA_NODEFER = libc::SA_NODEFER,
diff --git a/src/sys/signalfd.rs b/src/sys/signalfd.rs
index f178ec75..e11a0b9a 100644
--- a/src/sys/signalfd.rs
+++ b/src/sys/signalfd.rs
@@ -26,7 +26,7 @@ use std::mem;
bitflags!{
- flags SfdFlags: libc::c_int {
+ pub flags SfdFlags: libc::c_int {
const SFD_NONBLOCK = libc::SFD_NONBLOCK,
const SFD_CLOEXEC = libc::SFD_CLOEXEC,
}
diff --git a/src/sys/socket/consts.rs b/src/sys/socket/consts.rs
index 3c5efdf7..9a1861fa 100644
--- a/src/sys/socket/consts.rs
+++ b/src/sys/socket/consts.rs
@@ -90,7 +90,7 @@ mod os {
// Flags for send/recv and their relatives
bitflags!{
- flags MsgFlags : libc::c_int {
+ pub flags MsgFlags: libc::c_int {
const MSG_OOB = 0x0001,
const MSG_PEEK = 0x0002,
const MSG_CTRUNC = 0x0008,
@@ -232,7 +232,7 @@ mod os {
// Flags for send/recv and their relatives
bitflags!{
- flags MsgFlags : libc::c_int {
+ pub flags MsgFlags: libc::c_int {
const MSG_OOB = 0x01,
const MSG_PEEK = 0x02,
const MSG_EOR = 0x08,
@@ -318,7 +318,7 @@ mod os {
// Flags for send/recv and their relatives
bitflags!{
- flags MsgFlags : libc::c_int {
+ pub flags MsgFlags: libc::c_int {
const MSG_OOB = 0x01,
const MSG_PEEK = 0x02,
const MSG_DONTWAIT = 0x80,
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index 645dfe41..69b05d71 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -64,7 +64,7 @@ pub enum SockType {
// Extra flags - Supported by Linux 2.6.27, normalized on other platforms
bitflags!(
- flags SockFlag: c_int {
+ pub flags SockFlag: c_int {
const SOCK_NONBLOCK = 0o0004000,
const SOCK_CLOEXEC = 0o2000000
}
diff --git a/src/sys/stat.rs b/src/sys/stat.rs
index 076fe933..1beb349e 100644
--- a/src/sys/stat.rs
+++ b/src/sys/stat.rs
@@ -17,7 +17,7 @@ mod ffi {
}
bitflags!(
- flags SFlag: mode_t {
+ pub flags SFlag: mode_t {
const S_IFIFO = libc::S_IFIFO,
const S_IFCHR = libc::S_IFCHR,
const S_IFDIR = libc::S_IFDIR,
@@ -30,7 +30,7 @@ bitflags!(
);
bitflags! {
- flags Mode: mode_t {
+ pub flags Mode: mode_t {
const S_IRWXU = libc::S_IRWXU,
const S_IRUSR = libc::S_IRUSR,
const S_IWUSR = libc::S_IWUSR,
diff --git a/src/sys/statvfs.rs b/src/sys/statvfs.rs
index 5b72a16b..21067bd6 100644
--- a/src/sys/statvfs.rs
+++ b/src/sys/statvfs.rs
@@ -21,7 +21,7 @@ pub mod vfs {
/// Mount Flags
#[repr(C)]
#[derive(Default)]
- flags FsFlags: c_ulong {
+ pub flags FsFlags: c_ulong {
/// Read Only
const RDONLY = 1,
/// Do not allow the set-uid bits to have an effect
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index 41aae186..9622f392 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
@@ -146,7 +146,7 @@ mod ffi {
pub const NCCS: usize = 20;
bitflags! {
- flags InputFlags: tcflag_t {
+ pub flags InputFlags: tcflag_t {
const IGNBRK = 0x00000001,
const BRKINT = 0x00000002,
const IGNPAR = 0x00000004,
@@ -166,7 +166,7 @@ mod ffi {
}
bitflags! {
- flags OutputFlags: tcflag_t {
+ pub flags OutputFlags: tcflag_t {
const OPOST = 0x00000001,
const ONLCR = 0x00000002,
const OXTABS = 0x00000004,
@@ -175,7 +175,7 @@ mod ffi {
}
bitflags! {
- flags ControlFlags: tcflag_t {
+ pub flags ControlFlags: tcflag_t {
const CIGNORE = 0x00000001,
const CSIZE = 0x00000300,
const CS5 = 0x00000000,
@@ -199,7 +199,7 @@ mod ffi {
}
bitflags! {
- flags LocalFlags: tcflag_t {
+ pub flags LocalFlags: tcflag_t {
const ECHOKE = 0x00000001,
const ECHOE = 0x00000002,
const ECHOK = 0x00000004,
@@ -312,7 +312,7 @@ mod ffi {
pub const NCCS: usize = 32;
bitflags! {
- flags InputFlags: tcflag_t {
+ pub flags InputFlags: tcflag_t {
const IGNBRK = 0x00000001,
const BRKINT = 0x00000002,
const IGNPAR = 0x00000004,
@@ -331,14 +331,14 @@ mod ffi {
}
bitflags! {
- flags OutputFlags: tcflag_t {
+ pub flags OutputFlags: tcflag_t {
const OPOST = 0x00000001,
const ONLCR = 0x00000004,
}
}
bitflags! {
- flags ControlFlags: tcflag_t {
+ pub flags ControlFlags: tcflag_t {
const CSIZE = 0x00000030,
const CS5 = 0x00000000,
const CS6 = 0x00000010,
@@ -357,7 +357,7 @@ mod ffi {
}
bitflags! {
- flags LocalFlags: tcflag_t {
+ pub flags LocalFlags: tcflag_t {
const ECHOKE = 0x00000800,
const ECHOE = 0x00000010,
const ECHOK = 0x00000020,
diff --git a/src/sys/wait.rs b/src/sys/wait.rs
index 259efb70..bd3e6187 100644
--- a/src/sys/wait.rs
+++ b/src/sys/wait.rs
@@ -14,7 +14,7 @@ mod ffi {
#[cfg(not(any(target_os = "linux",
target_os = "android")))]
bitflags!(
- flags WaitPidFlag: c_int {
+ pub flags WaitPidFlag: c_int {
const WNOHANG = libc::WNOHANG,
const WUNTRACED = libc::WUNTRACED,
}
@@ -23,7 +23,7 @@ bitflags!(
#[cfg(any(target_os = "linux",
target_os = "android"))]
bitflags!(
- flags WaitPidFlag: c_int {
+ pub flags WaitPidFlag: c_int {
const WNOHANG = libc::WNOHANG,
const WUNTRACED = libc::WUNTRACED,
const WEXITED = libc::WEXITED,
@@ -44,6 +44,8 @@ pub enum WaitStatus {
Exited(pid_t, i8),
Signaled(pid_t, Signal, bool),
Stopped(pid_t, Signal),
+ #[cfg(any(target_os = "linux", target_os = "android"))]
+ PtraceEvent(pid_t, Signal, c_int),
Continued(pid_t),
StillAlive
}
@@ -52,6 +54,7 @@ pub enum WaitStatus {
target_os = "android"))]
mod status {
use sys::signal::Signal;
+ use libc::c_int;
pub fn exited(status: i32) -> bool {
(status & 0x7F) == 0
@@ -81,6 +84,10 @@ mod status {
Signal::from_c_int((status & 0xFF00) >> 8).unwrap()
}
+ pub fn stop_additional(status: i32) -> c_int {
+ (status >> 16) as c_int
+ }
+
pub fn continued(status: i32) -> bool {
status == 0xFFFF
}
@@ -184,7 +191,23 @@ fn decode(pid : pid_t, status: i32) -> WaitStatus {
} else if status::signaled(status) {
WaitStatus::Signaled(pid, status::term_signal(status), status::dumped_core(status))
} else if status::stopped(status) {
- WaitStatus::Stopped(pid, status::stop_signal(status))
+ cfg_if! {
+ if #[cfg(any(target_os = "linux", target_os = "android"))] {
+ fn decode_stopped(pid: pid_t, status: i32) -> WaitStatus {
+ let status_additional = status::stop_additional(status);
+ if status_additional == 0 {
+ WaitStatus::Stopped(pid, status::stop_signal(status))
+ } else {
+ WaitStatus::PtraceEvent(pid, status::stop_signal(status), status::stop_additional(status))
+ }
+ }
+ } else {
+ fn decode_stopped(pid: pid_t, status: i32) -> WaitStatus {
+ WaitStatus::Stopped(pid, status::stop_signal(status))
+ }
+ }
+ }
+ decode_stopped(pid, status)
} else {
assert!(status::continued(status));
WaitStatus::Continued(pid)