Skip to main content

btrfs_cli/
inspect.rs

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