From 774c0a757f12855b1e0192022fe042bd0ec17b4d Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Fri, 28 Jan 2022 15:34:13 -0800 Subject: [PATCH 1/4] Update nix to 0.21 Signed-off-by: Jesse Szwedko --- heim-common/Cargo.toml | 2 +- heim-net/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/heim-common/Cargo.toml b/heim-common/Cargo.toml index 3ab0f923..cf2cf984 100644 --- a/heim-common/Cargo.toml +++ b/heim-common/Cargo.toml @@ -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.21" lazy_static = "1.3.0" [target.'cfg(target_os = "windows")'.dependencies] diff --git a/heim-net/Cargo.toml b/heim-net/Cargo.toml index 577b2d77..94d5e4d1 100644 --- a/heim-net/Cargo.toml +++ b/heim-net/Cargo.toml @@ -19,7 +19,7 @@ macaddr = "1.0" libc = "^0.2" [target.'cfg(unix)'.dependencies] -nix = "^0.20" +nix = "^0.21" [target.'cfg(windows)'.dependencies] winapi = { version = "0.3", features = ["iphlpapi"]} From 90ea4b3224020305e98939c0648cc7e43c96297e Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Fri, 28 Jan 2022 15:43:37 -0800 Subject: [PATCH 2/4] Update to nix 0.22 Signed-off-by: Jesse Szwedko --- heim-common/Cargo.toml | 2 +- heim-common/src/errors.rs | 9 +-------- heim-net/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/heim-common/Cargo.toml b/heim-common/Cargo.toml index cf2cf984..e69d9576 100644 --- a/heim-common/Cargo.toml +++ b/heim-common/Cargo.toml @@ -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.21" +nix = "^0.22" lazy_static = "1.3.0" [target.'cfg(target_os = "windows")'.dependencies] diff --git a/heim-common/src/errors.rs b/heim-common/src/errors.rs index e4cc1af6..09aee1fb 100644 --- a/heim-common/src/errors.rs +++ b/heim-common/src/errors.rs @@ -362,13 +362,6 @@ impl From for Error { #[cfg(unix)] impl From 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)) } } diff --git a/heim-net/Cargo.toml b/heim-net/Cargo.toml index 94d5e4d1..fec36caf 100644 --- a/heim-net/Cargo.toml +++ b/heim-net/Cargo.toml @@ -19,7 +19,7 @@ macaddr = "1.0" libc = "^0.2" [target.'cfg(unix)'.dependencies] -nix = "^0.21" +nix = "^0.22" [target.'cfg(windows)'.dependencies] winapi = { version = "0.3", features = ["iphlpapi"]} From 76fa765c7ed7fbe43d1465bf52da6b8d19f2d2a9 Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Fri, 28 Jan 2022 15:44:22 -0800 Subject: [PATCH 3/4] Update to nix 0.23 Signed-off-by: Jesse Szwedko --- heim-common/Cargo.toml | 2 +- heim-net/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/heim-common/Cargo.toml b/heim-common/Cargo.toml index e69d9576..e6b440ff 100644 --- a/heim-common/Cargo.toml +++ b/heim-common/Cargo.toml @@ -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.22" +nix = "^0.23" lazy_static = "1.3.0" [target.'cfg(target_os = "windows")'.dependencies] diff --git a/heim-net/Cargo.toml b/heim-net/Cargo.toml index fec36caf..4412fde8 100644 --- a/heim-net/Cargo.toml +++ b/heim-net/Cargo.toml @@ -19,7 +19,7 @@ macaddr = "1.0" libc = "^0.2" [target.'cfg(unix)'.dependencies] -nix = "^0.22" +nix = "^0.23" [target.'cfg(windows)'.dependencies] winapi = { version = "0.3", features = ["iphlpapi"]} From a66c44074fb214e2b9355d7c407315f720664b18 Mon Sep 17 00:00:00 2001 From: Hugo Tavares Reis Date: Thu, 8 Feb 2024 17:36:32 +0100 Subject: [PATCH 4/4] heim-memory: expose Linux "dirty" memory value (#3) --- heim-memory/src/os/linux.rs | 7 +++++++ heim-memory/src/sys/linux/memory.rs | 8 +++++++- heim-memory/tests/smoke.rs | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/heim-memory/src/os/linux.rs b/heim-memory/src/os/linux.rs index 2b7318a3..b34de111 100644 --- a/heim-memory/src/os/linux.rs +++ b/heim-memory/src/os/linux.rs @@ -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")] @@ -68,4 +71,8 @@ impl MemoryExt for Memory { fn inactive(&self) -> Information { self.as_ref().inactive() } + + fn dirty(&self) -> Information { + self.as_ref().dirty() + } } diff --git a/heim-memory/src/sys/linux/memory.rs b/heim-memory/src/sys/linux/memory.rs index 3a1a473f..30a20e49 100644 --- a/heim-memory/src/sys/linux/memory.rs +++ b/heim-memory/src/sys/linux/memory.rs @@ -15,6 +15,7 @@ pub struct Memory { active: Information, // Active inactive: Information, // Inactive shared: Information, // Shmem + dirty: Information, // Dirty } impl Memory { @@ -42,6 +43,10 @@ impl Memory { pub fn shared(&self) -> Information { self.shared } + + pub fn dirty(&self) -> Information { + self.dirty + } } impl FromStr for Memory { @@ -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, }; @@ -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, }; diff --git a/heim-memory/tests/smoke.rs b/heim-memory/tests/smoke.rs index 212a3aaf..71220b07 100644 --- a/heim-memory/tests/smoke.rs +++ b/heim-memory/tests/smoke.rs @@ -22,6 +22,7 @@ async fn smoke_memory() { let _ = mem.shared(); let _ = mem.active(); let _ = mem.inactive(); + let _ = mem.dirty(); } #[cfg(target_os = "macos")]