| 1 |
// |
| 2 |
// Print physical location of system RAM |
| 3 |
// This requires CAP_SYS_ADMIN privilege, or root, otherwise physical memory addresses will be zero |
| 4 |
// |
| 5 |
|
| 6 |
fn main() { |
| 7 |
if !rustix::process::geteuid().is_root() { |
| 8 |
println!("WARNING: Access to /proc/iomem requires root, re-run with sudo"); |
| 9 |
} |
| 10 |
|
| 11 |
let iomem = procfs::iomem().expect("Can't read /proc/iomem"); |
| 12 |
|
| 13 |
for (_indent, map) in iomem.iter() { |
| 14 |
if map.name == "System RAM" { |
| 15 |
println!("Found RAM here: 0x{:x}-0x{:x}", map.address.0, map.address.1); |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
if !rustix::process::geteuid().is_root() { |
| 20 |
println!("\n\nWARNING: Access to /proc/iomem requires root, re-run with sudo"); |
| 21 |
} |
| 22 |
} |