btrfs_cli/quota/
enable.rs1use crate::{Format, Runnable, util::open_path};
2use anyhow::{Context, Result};
3use clap::Parser;
4use std::{os::unix::io::AsFd, path::PathBuf};
5
6#[derive(Parser, Debug)]
8pub struct QuotaEnableCommand {
9 pub path: PathBuf,
11
12 #[clap(short = 's', long)]
14 pub simple: bool,
15}
16
17impl Runnable for QuotaEnableCommand {
18 fn run(&self, _format: Format, _dry_run: bool) -> Result<()> {
19 let file = open_path(&self.path)?;
20
21 btrfs_uapi::quota::quota_enable(file.as_fd(), self.simple)
22 .with_context(|| {
23 format!("failed to enable quota on '{}'", self.path.display())
24 })?;
25
26 if self.simple {
27 println!(
28 "quota enabled (simple mode) on '{}'",
29 self.path.display()
30 );
31 } else {
32 println!("quota enabled on '{}'", self.path.display());
33 }
34
35 Ok(())
36 }
37}