summaryrefslogtreecommitdiff
path: root/cmd/btrfs-rec/inspect_dumptrees.go
blob: 431a3022887f1e8c0aefb7d2ae8df76f83f2911a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (C) 2022-2023  Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later

package main

import (
	"os"

	"github.com/datawire/ocibuild/pkg/cliutil"
	"github.com/spf13/cobra"

	"git.lukeshu.com/btrfs-progs-ng/cmd/btrfs-rec/inspect/dumptrees"
	"git.lukeshu.com/btrfs-progs-ng/lib/btrfs"
	"git.lukeshu.com/btrfs-progs-ng/lib/textui"
)

func init() {
	inspectors.AddCommand(&cobra.Command{
		Use:   "dump-trees",
		Short: "A clone of `btrfs inspect-internal dump-tree`",
		Args:  cliutil.WrapPositionalArgs(cobra.NoArgs),
		RunE: runWithReadableFS(func(fs btrfs.ReadableFS, cmd *cobra.Command, _ []string) error {
			const version = "6.1.3"
			out := os.Stdout
			textui.Fprintf(out, "btrfs-progs v%v\n", version)
			dumptrees.DumpTrees(cmd.Context(), out, fs)
			return nil
		}),
	})
}