1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-28 05:29:48 +00:00
freebsd-ports/sysutils/rsfetch/files/patch-src_memory.rs
Mikael Urankar 865ff6c103 sysutils/rsfetch: fix memory reporting and add DragonFlyBSD support
Import upstream fix [1] to fix fix memory reporting and add DragonFlyBSD support.

[1] 2bd3ef9eaf

PR:		244861
Approved by:	Lewis Cook (maintainer), manu (mentor, implicit)
2020-03-18 08:34:36 +00:00

21 lines
890 B
Rust

--- src/memory.rs.orig 2020-03-16 13:12:22 UTC
+++ src/memory.rs
@@ -74,12 +74,15 @@ impl RAMInfo {
self.used = Some(used / 1024_f64 / 1024_f64);
self.total = Some(total / 1024_f64 / 1024_f64);
return Ok(());
- } else if os == &OS::FreeBSD || os == &OS::Other {
+ } else if os == &OS::FreeBSD || os == &OS::DragonflyBSD {
let mut buffer = String::new();
Command::new("sysctl").arg("-n").arg("hw.physmem")
.output().context(RAMErr)?.stdout.iter()
.for_each(|b| buffer.push(*b as char));
- total = buffer.parse::<f64>().unwrap();
+
+ // remove non-integer chars from buffer
+ buffer = buffer.trim().replace("\n", "");
+ total = buffer.parse::<u64>().unwrap() as f64;
let pagesize: f64;
let inactive: f64;