Skip to main content

btrfs_cli/
quota.rs

1use crate::{Format, Runnable};
2use anyhow::Result;
3use clap::Parser;
4
5mod disable;
6mod enable;
7mod rescan;
8mod status;
9
10pub use self::{disable::*, enable::*, rescan::*, status::*};
11
12/// Manage filesystem quota settings.
13///
14/// Enable or disable quotas, configure quota rescan operations, and view
15/// quota status. Quotas allow enforcing limits on filesystem usage by
16/// subvolume or quota group. Quota operations require CAP_SYS_ADMIN.
17#[derive(Parser, Debug)]
18pub struct QuotaCommand {
19    #[clap(subcommand)]
20    pub subcommand: QuotaSubcommand,
21}
22
23impl Runnable for QuotaCommand {
24    fn run(&self, format: Format, dry_run: bool) -> Result<()> {
25        match &self.subcommand {
26            QuotaSubcommand::Enable(cmd) => cmd.run(format, dry_run),
27            QuotaSubcommand::Disable(cmd) => cmd.run(format, dry_run),
28            QuotaSubcommand::Rescan(cmd) => cmd.run(format, dry_run),
29            QuotaSubcommand::Status(cmd) => cmd.run(format, dry_run),
30        }
31    }
32}
33
34#[derive(Parser, Debug)]
35pub enum QuotaSubcommand {
36    Enable(QuotaEnableCommand),
37    Disable(QuotaDisableCommand),
38    Rescan(QuotaRescanCommand),
39    Status(QuotaStatusCommand),
40}