Skip to main content

btrfs_cli/quota/
disable.rs

1use crate::{Format, Runnable};
2use anyhow::{Context, Result};
3use clap::Parser;
4use std::{fs::File, 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, _format: Format, _dry_run: bool) -> Result<()> {
15        let file = File::open(&self.path).with_context(|| {
16            format!("failed to open '{}'", self.path.display())
17        })?;
18
19        btrfs_uapi::quota::quota_disable(file.as_fd()).with_context(|| {
20            format!("failed to disable quota on '{}'", self.path.display())
21        })?;
22
23        println!("quota disabled on '{}'", self.path.display());
24
25        Ok(())
26    }
27}