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