Skip to content

Commit

Permalink
Implemented example for /dev/crypto parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Bury committed Aug 5, 2024
1 parent 784dd2c commit e0dec8b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions procfs/examples/crypto.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use std::env::args;

use procfs::crypto;

pub fn main() {
let crypto = crypto().expect("Was not able to access current crypto");
let name_arg = args().nth(1);
for (name, entries) in crypto.crypto_blocks {
if let Some(ref name_find) = name_arg {
if !name.contains(name_find) {
continue;
}
}
println!("Type: {name}");
for block in entries {
println!("{:>14}: {}", "Name", block.name);
println!("{:>14}: {}", "Driver", block.driver);
println!("{:>14}: {}", "Module", block.module);
println!("{:>14}: {}", "Priority", block.priority);
println!("{:>14}: {}", "Ref Count", block.ref_count);
println!("{:>14}: {:?}", "Self Test", block.self_test);
println!("{:>14}: {}", "Internal", block.internal);
println!("{:>14}: {}", "fips enabled", block.fips_enabled);
println!("{:>14}: {:?}", "Type Details", block.crypto_type);
println!();
}
}
}

0 comments on commit e0dec8b

Please sign in to comment.