Skip to main content

btrfs_cli/
inspect.rs

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