Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nix to 0.23 #360

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion heim-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ uom = { version = "0.31.1", default-features = false, features = ["autoconvert",
backtrace = { version = "^0.3", optional = true }

[target.'cfg(unix)'.dependencies]
nix = "^0.20"
nix = "^0.23"
lazy_static = "1.3.0"

[target.'cfg(target_os = "windows")'.dependencies]
Expand Down
9 changes: 1 addition & 8 deletions heim-common/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,6 @@ impl From<convert::Infallible> for Error {
#[cfg(unix)]
impl From<nix::Error> for Error {
fn from(e: nix::Error) -> Self {
let inner = match e {
nix::Error::Sys(errno) => io::Error::from_raw_os_error(errno as i32),
nix::Error::InvalidPath => io::Error::new(io::ErrorKind::InvalidInput, e),
nix::Error::InvalidUtf8 => io::Error::new(io::ErrorKind::InvalidData, e),
nix::Error::UnsupportedOperation => io::Error::new(io::ErrorKind::Other, e),
};

Error::from(inner)
Error::from(io::Error::from(e))
}
}
4 changes: 2 additions & 2 deletions heim-host/src/os/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::net::IpAddr;
use crate::Pid;

cfg_if::cfg_if! {
// aarch64-unknown-linux-gnu has different type
if #[cfg(all(target_arch = "aarch64", not(target_family = "musl")))] {
// aarch64-unknown-linux-gnu and s390x-unknown-linux-gnu has different type
if #[cfg(any(target_arch = "s390x",all(target_arch = "aarch64", not(target_family = "musl"))))] {
/// User session ID.
pub type SessionId = i64;
} else {
Expand Down
7 changes: 7 additions & 0 deletions heim-memory/src/os/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ pub trait MemoryExt {
///
/// This is memory that has not been recently used and can be reclaimed for other purposes.
fn inactive(&self) -> Information;

/// Memory which is waiting to get written back to the disk.
fn dirty(&self) -> Information;
}

#[cfg(target_os = "linux")]
Expand Down Expand Up @@ -68,4 +71,8 @@ impl MemoryExt for Memory {
fn inactive(&self) -> Information {
self.as_ref().inactive()
}

fn dirty(&self) -> Information {
self.as_ref().dirty()
}
}
8 changes: 7 additions & 1 deletion heim-memory/src/sys/linux/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct Memory {
active: Information, // Active
inactive: Information, // Inactive
shared: Information, // Shmem
dirty: Information, // Dirty
}

impl Memory {
Expand Down Expand Up @@ -42,6 +43,10 @@ impl Memory {
pub fn shared(&self) -> Information {
self.shared
}

pub fn dirty(&self) -> Information {
self.dirty
}
}

impl FromStr for Memory {
Expand All @@ -56,7 +61,7 @@ impl FromStr for Memory {
// we do not need that key at all
let first_bytes = &line.as_bytes()[..2];
match first_bytes {
b"Me" | b"Ac" | b"In" | b"Bu" | b"Ca" | b"Sh" => {}
b"Me" | b"Ac" | b"In" | b"Bu" | b"Ca" | b"Sh" | b"Di" => {}
_ => continue,
};

Expand All @@ -70,6 +75,7 @@ impl FromStr for Memory {
Some("Active") => &mut memory.active,
Some("Inactive") => &mut memory.inactive,
Some("Shmem") => &mut memory.shared,
Some("Dirty") => &mut memory.dirty,
_ => continue,
};

Expand Down
1 change: 1 addition & 0 deletions heim-memory/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async fn smoke_memory() {
let _ = mem.shared();
let _ = mem.active();
let _ = mem.inactive();
let _ = mem.dirty();
}

#[cfg(target_os = "macos")]
Expand Down
2 changes: 1 addition & 1 deletion heim-net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ macaddr = "1.0"
libc = "^0.2"

[target.'cfg(unix)'.dependencies]
nix = "^0.20"
nix = "^0.23"

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["iphlpapi"]}
Expand Down