Skip to main content

btrfs_cli/quota/
disable.rs

1use crate::{RunContext, Runnable, util::open_path};
2use anyhow::{Context, Result};
3use clap::Parser;
4use std::{os::unix::io::AsFd, path::PathBuf};
5
6/// Disable subvolume quota support for a filesystem
7#[derive(Parser, Debug)]
8pub struct QuotaDisableCommand {
9    /// Path to a mounted btrfs filesystem
10    pub path: PathBuf,
11}
12
13impl Runnable for QuotaDisableCommand {
14    fn run(&self, _ctx: &RunContext) -> Result<()> {
15        let file = open_path(&self.path)?;
16
17        btrfs_uapi::quota::quota_disable(file.as_fd()).with_context(|| {
18            format!("failed to disable quota on '{}'", self.path.display())
19        })?;
20
21        println!("quota disabled on '{}'", self.path.display());
22
23        Ok(())
24    }
25}