blob: f44b1f7354c6a7017b9d6ca0c912a8b9ac03a43d (
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
32
33
34
35
36
37
38
|
// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later
package main
import (
"fmt"
"os"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsrepair"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsutil"
)
func main() {
if err := Main(os.Args[1:]...); err != nil {
fmt.Fprintf(os.Stderr, "%v: error: %v\n", os.Args[0], err)
os.Exit(1)
}
}
func Main(imgfilenames ...string) (err error) {
maybeSetErr := func(_err error) {
if _err != nil && err == nil {
err = _err
}
}
fs, err := btrfsutil.Open(os.O_RDWR, imgfilenames...)
if err != nil {
return err
}
defer func() {
maybeSetErr(fs.Close())
}()
return btrfsrepair.ClearBadNodes(os.Stdout, os.Stderr, fs)
}
|