summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.golangci.yml1
-rw-r--r--cmd/btrfs-rec/inspect_dumptrees.go7
-rw-r--r--cmd/btrfs-rec/inspect_lsfiles.go7
-rw-r--r--cmd/btrfs-rec/inspect_lstrees.go5
-rw-r--r--cmd/btrfs-rec/inspect_spewitems.go6
5 files changed, 15 insertions, 11 deletions
diff --git a/.golangci.yml b/.golangci.yml
index efd6d2c..a6b3ed0 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -6,6 +6,7 @@ linters:
disable:
- structcheck # doesn't support Go 1.18 yet
enable:
+ - forbidigo
- gofmt
linters-settings:
gofmt:
diff --git a/cmd/btrfs-rec/inspect_dumptrees.go b/cmd/btrfs-rec/inspect_dumptrees.go
index 4abeaba..610f502 100644
--- a/cmd/btrfs-rec/inspect_dumptrees.go
+++ b/cmd/btrfs-rec/inspect_dumptrees.go
@@ -5,7 +5,6 @@
package main
import (
- "fmt"
"os"
"github.com/datawire/ocibuild/pkg/cliutil"
@@ -13,6 +12,7 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsinspect"
+ "git.lukeshu.com/btrfs-progs-ng/lib/textui"
)
func init() {
@@ -24,8 +24,9 @@ func init() {
},
RunE: func(fs *btrfs.FS, cmd *cobra.Command, _ []string) error {
const version = "5.18.1"
- fmt.Printf("btrfs-progs v%v\n", version)
- btrfsinspect.DumpTrees(cmd.Context(), os.Stdout, fs)
+ out := os.Stdout
+ textui.Fprintf(out, "btrfs-progs v%v\n", version)
+ btrfsinspect.DumpTrees(cmd.Context(), out, fs)
return nil
},
})
diff --git a/cmd/btrfs-rec/inspect_lsfiles.go b/cmd/btrfs-rec/inspect_lsfiles.go
index 9267f77..801da5d 100644
--- a/cmd/btrfs-rec/inspect_lsfiles.go
+++ b/cmd/btrfs-rec/inspect_lsfiles.go
@@ -22,6 +22,7 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsprim"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsutil"
"git.lukeshu.com/btrfs-progs-ng/lib/maps"
+ "git.lukeshu.com/btrfs-progs-ng/lib/textui"
)
func init() {
@@ -32,20 +33,20 @@ func init() {
Args: cliutil.WrapPositionalArgs(cobra.NoArgs),
},
RunE: func(fs *btrfs.FS, cmd *cobra.Command, _ []string) (err error) {
+ out := bufio.NewWriter(os.Stdout)
+ defer out.Flush()
defer func() {
if r := derror.PanicToError(recover()); r != nil {
- fmt.Printf("\n\n%+v\n", r)
+ textui.Fprintf(out, "\n\n%+v\n", r)
err = fmt.Errorf("panicked")
}
}()
ctx := cmd.Context()
- out := bufio.NewWriter(os.Stdout)
printSubvol(out, "", true, "/", &btrfs.Subvolume{
FS: btrfsutil.NewBrokenTrees(ctx, fs),
TreeID: btrfsprim.FS_TREE_OBJECTID,
})
- out.Flush()
return nil
},
diff --git a/cmd/btrfs-rec/inspect_lstrees.go b/cmd/btrfs-rec/inspect_lstrees.go
index 54c2074..e0dc4e1 100644
--- a/cmd/btrfs-rec/inspect_lstrees.go
+++ b/cmd/btrfs-rec/inspect_lstrees.go
@@ -25,6 +25,7 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/diskio"
"git.lukeshu.com/btrfs-progs-ng/lib/maps"
"git.lukeshu.com/btrfs-progs-ng/lib/slices"
+ "git.lukeshu.com/btrfs-progs-ng/lib/textui"
)
func init() {
@@ -69,7 +70,7 @@ func init() {
PreTree: func(name string, treeID btrfsprim.ObjID) {
treeErrCnt = 0
treeItemCnt = make(map[btrfsitem.Type]int)
- fmt.Printf("tree id=%v name=%q\n", treeID, name)
+ textui.Fprintf(os.Stdout, "tree id=%v name=%q\n", treeID, name)
},
Err: func(_ *btrfsutil.WalkError) {
treeErrCnt++
@@ -98,7 +99,7 @@ func init() {
if scandevicesFilename != "" {
treeErrCnt = 0
treeItemCnt = make(map[btrfsitem.Type]int)
- fmt.Printf("lost+found\n")
+ textui.Fprintf(os.Stdout, "lost+found\n")
sb, _ := fs.Superblock()
for _, devResults := range scanResults {
for laddr := range devResults.FoundNodes {
diff --git a/cmd/btrfs-rec/inspect_spewitems.go b/cmd/btrfs-rec/inspect_spewitems.go
index a4e8d69..8d71797 100644
--- a/cmd/btrfs-rec/inspect_spewitems.go
+++ b/cmd/btrfs-rec/inspect_spewitems.go
@@ -5,7 +5,6 @@
package main
import (
- "fmt"
"os"
"github.com/datawire/dlib/dlog"
@@ -16,6 +15,7 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfstree"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsutil"
+ "git.lukeshu.com/btrfs-progs-ng/lib/textui"
)
func init() {
@@ -37,13 +37,13 @@ func init() {
},
TreeWalkHandler: btrfstree.TreeWalkHandler{
Item: func(path btrfstree.TreePath, item btrfstree.Item) error {
- fmt.Printf("%s = ", path)
+ textui.Fprintf(os.Stdout, "%s = ", path)
spew.Dump(item)
os.Stdout.WriteString("\n")
return nil
},
BadItem: func(path btrfstree.TreePath, item btrfstree.Item) error {
- fmt.Printf("%s = ", path)
+ textui.Fprintf(os.Stdout, "%s = ", path)
spew.Dump(item)
os.Stdout.WriteString("\n")
return nil