Skip to content

Commit 3e89f8a

Browse files
committed
blockdev: Use JSON parsing helper
It's shorter and clearer and we get stderr. Signed-off-by: Colin Walters <[email protected]>
1 parent 3d22411 commit 3e89f8a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/src/blockdev.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use fn_error_context::context;
1010
use regex::Regex;
1111
use serde::Deserialize;
1212

13+
use crate::cmdutils::CommandRunExt;
1314
use crate::install::run_in_host_mountns;
1415
use crate::task::Task;
1516

@@ -94,14 +95,10 @@ pub(crate) fn wipefs(dev: &Utf8Path) -> Result<()> {
9495

9596
#[context("Listing device {dev}")]
9697
pub(crate) fn list_dev(dev: &Utf8Path) -> Result<Device> {
97-
let o = Command::new("lsblk")
98+
let mut devs: DevicesOutput = Command::new("lsblk")
9899
.args(["-J", "-b", "-O"])
99100
.arg(dev)
100-
.output()?;
101-
if !o.status.success() {
102-
return Err(anyhow::anyhow!("Failed to list block devices"));
103-
}
104-
let mut devs: DevicesOutput = serde_json::from_reader(&*o.stdout)?;
101+
.run_and_parse_json()?;
105102
for dev in devs.blockdevices.iter_mut() {
106103
dev.backfill_missing()?;
107104
}

0 commit comments

Comments
 (0)