blob: 27708492d9ff42893a3ca394ce6095188da3a9b2 (
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
39
40
41
|
// 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/btrfsinspect"
"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)
}
}
const version = "5.18.1"
func Main(imgfilename string) (err error) {
maybeSetErr := func(_err error) {
if _err != nil && err == nil {
err = _err
}
}
fs, err := btrfsutil.Open(os.O_RDONLY, imgfilename)
if err != nil {
return err
}
defer func() {
maybeSetErr(fs.Close())
}()
fmt.Printf("btrfs-progs v%v\n", version)
return btrfsinspect.DumpTrees(os.Stdout, os.Stderr, fs)
}
|