manager: Implement format_device

This commit is contained in:
Vicki Pfau 2024-03-28 16:57:47 -07:00
parent 69e6477053
commit fd14514d6c

View file

@ -252,16 +252,22 @@ impl SteamOSManager {
} }
} }
async fn format_sdcard(&self) -> bool { async fn format_device(&self, device: &str, label: &str, validate: bool) -> Result<(), zbus::fdo::Error> {
// Run steamos-format-sdcard script let mut args = vec!["--label", label, "--device", device];
// return true on success, false otherwise if !validate {
run_script( args.push("--skip-validation");
"format sdcard", }
"/usr/bin/steamos-polkit-helpers/steamos-format-sdcard", let res = run_script(
&[""], "format device",
"/usr/lib/hwsupport/format-device.sh",
args.as_ref()
) )
.await .await;
.unwrap_or(false)
match res {
Ok(_) => Ok(()),
Err(e) => Err(zbus::fdo::Error::Failed(e.to_string())),
}
} }
#[zbus(property)] #[zbus(property)]