diff options
Diffstat (limited to 'cmd/btrfs-rec/inspect_dumpsums.go')
-rw-r--r-- | cmd/btrfs-rec/inspect_dumpsums.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/cmd/btrfs-rec/inspect_dumpsums.go b/cmd/btrfs-rec/inspect_dumpsums.go new file mode 100644 index 0000000..ae159d1 --- /dev/null +++ b/cmd/btrfs-rec/inspect_dumpsums.go @@ -0,0 +1,35 @@ +// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com> +// +// SPDX-License-Identifier: GPL-2.0-or-later + +package main + +import ( + "os" + + "github.com/datawire/dlib/dlog" + "github.com/datawire/ocibuild/pkg/cliutil" + "github.com/spf13/cobra" + + "git.lukeshu.com/btrfs-progs-ng/lib/btrfs" + "git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsinspect/scanforextents" +) + +func init() { + inspectors = append(inspectors, subcommand{ + Command: cobra.Command{ + Use: "dump-sums", + Short: "Dump a buncha checksums as JSON", + Args: cliutil.WrapPositionalArgs(cobra.NoArgs), + }, + RunE: func(fs *btrfs.FS, cmd *cobra.Command, _ []string) error { + ctx := cmd.Context() + sums, err := scanforextents.SumEverything(ctx, fs) + if err != nil { + return err + } + dlog.Info(ctx, "Writing sums as gob to stdout...") + return scanforextents.WriteAllSums(os.Stdout, sums) + }, + }) +} |