btrfs_cli/scrub/
cancel.rs1use crate::{Format, Runnable, util::open_path};
2use anyhow::{Context, Result};
3use btrfs_uapi::scrub::scrub_cancel;
4use clap::Parser;
5use std::{os::unix::io::AsFd, path::PathBuf};
6
7#[derive(Parser, Debug)]
9pub struct ScrubCancelCommand {
10 pub path: PathBuf,
12}
13
14impl Runnable for ScrubCancelCommand {
15 fn run(&self, _format: Format, _dry_run: bool) -> Result<()> {
16 let file = open_path(&self.path)?;
17
18 scrub_cancel(file.as_fd()).with_context(|| {
19 format!("failed to cancel scrub on '{}'", self.path.display())
20 })?;
21
22 println!("scrub cancelled on '{}'", self.path.display());
23 Ok(())
24 }
25}