Skip to main content

btrfs_cli/
inspect.rs

1use crate::{Format, Runnable};
2use anyhow::Result;
3use clap::Parser;
4
5pub mod dump_super;
6pub mod dump_tree;
7pub mod inode_resolve;
8pub mod list_chunks;
9pub mod logical_resolve;
10pub mod map_swapfile;
11pub mod min_dev_size;
12pub mod rootid;
13pub mod subvolid_resolve;
14pub mod tree_stats;
15
16use dump_super::DumpSuperCommand;
17use dump_tree::DumpTreeCommand;
18use inode_resolve::InodeResolveCommand;
19use list_chunks::ListChunksCommand;
20use logical_resolve::LogicalResolveCommand;
21use map_swapfile::MapSwapfileCommand;
22use min_dev_size::MinDevSizeCommand;
23use rootid::RootidCommand;
24use subvolid_resolve::SubvolidResolveCommand;
25use tree_stats::TreeStatsCommand;
26
27/// Query various internal filesystem information.
28///
29/// Access advanced information about filesystem internals including inode
30/// resolution, logical extent to physical block mapping, subvolume IDs,
31/// chunk layout, and other diagnostic data. These commands are primarily
32/// useful for debugging, analysis, and recovery operations. Most operations
33/// require CAP_SYS_ADMIN.
34#[derive(Parser, Debug)]
35pub struct InspectCommand {
36    #[clap(subcommand)]
37    pub subcommand: InspectSubcommand,
38}
39
40#[derive(Parser, Debug)]
41pub enum InspectSubcommand {
42    Rootid(RootidCommand),
43    InodeResolve(InodeResolveCommand),
44    LogicalResolve(LogicalResolveCommand),
45    SubvolidResolve(SubvolidResolveCommand),
46    MapSwapfile(MapSwapfileCommand),
47    MinDevSize(MinDevSizeCommand),
48    DumpTree(DumpTreeCommand),
49    DumpSuper(DumpSuperCommand),
50    TreeStats(TreeStatsCommand),
51    ListChunks(ListChunksCommand),
52}
53
54impl Runnable for InspectCommand {
55    fn run(&self, format: Format, dry_run: bool) -> Result<()> {
56        match &self.subcommand {
57            InspectSubcommand::Rootid(cmd) => cmd.run(format, dry_run),
58            InspectSubcommand::InodeResolve(cmd) => cmd.run(format, dry_run),
59            InspectSubcommand::LogicalResolve(cmd) => cmd.run(format, dry_run),
60            InspectSubcommand::SubvolidResolve(cmd) => cmd.run(format, dry_run),
61            InspectSubcommand::MapSwapfile(cmd) => cmd.run(format, dry_run),
62            InspectSubcommand::MinDevSize(cmd) => cmd.run(format, dry_run),
63            InspectSubcommand::DumpTree(cmd) => cmd.run(format, dry_run),
64            InspectSubcommand::DumpSuper(cmd) => cmd.run(format, dry_run),
65            InspectSubcommand::TreeStats(cmd) => cmd.run(format, dry_run),
66            InspectSubcommand::ListChunks(cmd) => cmd.run(format, dry_run),
67        }
68    }
69}