SHA256
Trying to figure out blkid thing. Add --probe flag.
This commit is contained in:
@@ -115,6 +115,7 @@ pub fn exec_command(cmd: &str, args: &Vec<&str>) -> Result<(), ExecCommandError>
|
||||
pub fn find_partlabel(partlabel: &str) -> Result<String, ExecCommandError> {
|
||||
let out = Command::new("/usr/bin/blkid")
|
||||
.args([
|
||||
"--probe",
|
||||
"-s",
|
||||
"PARTLABEL",
|
||||
"--match-token",
|
||||
@@ -138,6 +139,19 @@ pub fn find_partlabel(partlabel: &str) -> Result<String, ExecCommandError> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn list_partlabel() -> Result<String, ExecCommandError> {
|
||||
let out = Command::new("/usr/bin/blkid")
|
||||
.args(["--probe", "-s", "PARTLABEL"])
|
||||
.output()?;
|
||||
if out.status.success() {
|
||||
let out_text = String::from_utf8(out.stdout)?;
|
||||
Ok(out_text)
|
||||
} else {
|
||||
Err(ExecCommandError::Other("Oh no".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
/// exec given command with arguments, returning stdout parsed to UTF-8 string
|
||||
/// capturing stderr in case or failure
|
||||
// pub fn exec_command_out(cmd: &str, args: &Vec<&str>) -> Result<String, ExecCommandError> {
|
||||
|
||||
Reference in New Issue
Block a user