-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from navidys/develop
added /proc/cmdline
- Loading branch information
Showing
4 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
Supported Features | ||
* ✅ `/proc/buddyinfo` | ||
|
||
* ✅ `/proc/cmdline` | ||
|
||
* ✅ `/proc/cpuinfo` | ||
|
||
* ✅ `/proc/loadavg` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use procsys::cmdline; | ||
|
||
fn main() { | ||
let sys_cmdline = cmdline::collect().expect("system boot cmdline"); | ||
println!("{:?}", sys_cmdline); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::path::Path; | ||
|
||
use crate::{error::CollectResult, utils}; | ||
|
||
/// collects information about system boot cmdline | ||
/// # Example | ||
/// ``` | ||
/// use procsys::cmdline; | ||
/// | ||
/// let sys_cmdline = cmdline::collect().expect("system boot cmdline"); | ||
/// println!("{:?}", sys_cmdline); | ||
/// | ||
pub fn collect() -> CollectResult<Vec<String>> { | ||
let mut boot_cmdline: Vec<String> = Vec::new(); | ||
|
||
let bootcmd = utils::collect_info_string("cmdline", Path::new("/proc"))?; | ||
|
||
if bootcmd.is_some() { | ||
boot_cmdline = bootcmd | ||
.unwrap() | ||
.split_whitespace() | ||
.map(str::to_string) | ||
.collect(); | ||
} | ||
|
||
Ok(boot_cmdline) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn sys_bootcmd() { | ||
let bootcmd = collect().expect("system boot cmdline"); | ||
assert!(!bootcmd.is_empty()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters