diff options
Diffstat (limited to 'cmd/btrfs-rec')
-rw-r--r-- | cmd/btrfs-rec/inspect_rebuildmappings.go | 2 | ||||
-rw-r--r-- | cmd/btrfs-rec/inspect_rebuildnodes.go | 2 | ||||
-rw-r--r-- | cmd/btrfs-rec/inspect_scandevices.go | 2 | ||||
-rw-r--r-- | cmd/btrfs-rec/util.go | 5 |
4 files changed, 5 insertions, 6 deletions
diff --git a/cmd/btrfs-rec/inspect_rebuildmappings.go b/cmd/btrfs-rec/inspect_rebuildmappings.go index e1f273c..51f0327 100644 --- a/cmd/btrfs-rec/inspect_rebuildmappings.go +++ b/cmd/btrfs-rec/inspect_rebuildmappings.go @@ -47,7 +47,7 @@ func init() { } dlog.Infof(ctx, "Writing reconstructed mappings to stdout...") - if err := writeJSONFile(os.Stdout, fs.LV.Mappings(), lowmemjson.ReEncoder{ + if err := writeJSONFile(os.Stdout, fs.LV.Mappings(), lowmemjson.ReEncoderConfig{ Indent: "\t", ForceTrailingNewlines: true, CompactIfUnder: 120, //nolint:gomnd // This is what looks nice. diff --git a/cmd/btrfs-rec/inspect_rebuildnodes.go b/cmd/btrfs-rec/inspect_rebuildnodes.go index d813f36..e8f9ada 100644 --- a/cmd/btrfs-rec/inspect_rebuildnodes.go +++ b/cmd/btrfs-rec/inspect_rebuildnodes.go @@ -57,7 +57,7 @@ func init() { dlog.Errorf(ctx, "rebuild error: %v", rebuildErr) } dlog.Infof(ctx, "Writing re-built nodes to %s...", dst.Name()) - if err := writeJSONFile(dst, rebuilder.ListRoots(), lowmemjson.ReEncoder{ + if err := writeJSONFile(dst, rebuilder.ListRoots(), lowmemjson.ReEncoderConfig{ Indent: "\t", ForceTrailingNewlines: true, }); err != nil { diff --git a/cmd/btrfs-rec/inspect_scandevices.go b/cmd/btrfs-rec/inspect_scandevices.go index ade9d74..3de35d0 100644 --- a/cmd/btrfs-rec/inspect_scandevices.go +++ b/cmd/btrfs-rec/inspect_scandevices.go @@ -31,7 +31,7 @@ func init() { } dlog.Info(ctx, "Writing scan results to stdout...") - if err := writeJSONFile(os.Stdout, results, lowmemjson.ReEncoder{ + if err := writeJSONFile(os.Stdout, results, lowmemjson.ReEncoderConfig{ Indent: "\t", ForceTrailingNewlines: true, CompactIfUnder: 16, //nolint:gomnd // This is what looks nice. diff --git a/cmd/btrfs-rec/util.go b/cmd/btrfs-rec/util.go index 3c72cae..3d751a6 100644 --- a/cmd/btrfs-rec/util.go +++ b/cmd/btrfs-rec/util.go @@ -38,13 +38,12 @@ func readJSONFile[T any](ctx context.Context, filename string) (T, error) { return ret, nil } -func writeJSONFile(w io.Writer, obj any, cfg lowmemjson.ReEncoder) (err error) { +func writeJSONFile(w io.Writer, obj any, cfg lowmemjson.ReEncoderConfig) (err error) { buffer := bufio.NewWriter(w) defer func() { if _err := buffer.Flush(); err == nil && _err != nil { err = _err } }() - cfg.Out = buffer - return lowmemjson.NewEncoder(&cfg).Encode(obj) + return lowmemjson.NewEncoder(lowmemjson.NewReEncoder(buffer, cfg)).Encode(obj) } |