diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-16 02:55:58 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-16 02:55:58 -0600 |
commit | 1145f9a47c8e368dd7f83ce19e9f06b9eba7b0ad (patch) | |
tree | 422158f2f2a108879e79565ecc154d653fa35def /cmd | |
parent | 42d7bab041ea3556872f10d653281c9c48533bed (diff) |
store sums in a big ol slice
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/btrfs-rec/inspect_dumpsums.go | 35 | ||||
-rw-r--r-- | cmd/btrfs-rec/inspect_scanforextents.go | 13 |
2 files changed, 45 insertions, 3 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) + }, + }) +} diff --git a/cmd/btrfs-rec/inspect_scanforextents.go b/cmd/btrfs-rec/inspect_scanforextents.go index 698b3b6..5f763d9 100644 --- a/cmd/btrfs-rec/inspect_scanforextents.go +++ b/cmd/btrfs-rec/inspect_scanforextents.go @@ -19,8 +19,8 @@ import ( func init() { inspectors = append(inspectors, subcommand{ Command: cobra.Command{ - Use: "scan-for-extents SCAN_RESULT.json", - Args: cliutil.WrapPositionalArgs(cobra.ExactArgs(1)), + Use: "scan-for-extents NODESCAN.json DUMPSUMS.gob", + Args: cliutil.WrapPositionalArgs(cobra.ExactArgs(2)), }, RunE: func(fs *btrfs.FS, cmd *cobra.Command, args []string) error { ctx := cmd.Context() @@ -33,7 +33,14 @@ func init() { runtime.GC() dlog.Infof(ctx, "... done reading %q", args[0]) - if err := scanforextents.ScanForExtents(ctx, fs, bgs); err != nil { + dlog.Infof(ctx, "Reading %q...", args[1]) + sums, err := scanforextents.ReadAllSums(args[1]) + if err != nil { + return err + } + dlog.Infof(ctx, "... done reading %q", args[1]) + + if err := scanforextents.ScanForExtents(ctx, fs, bgs, sums); err != nil { return err } |