//go:build ceph && cgo package main import ( "CephMig/internal/cephfsnative" "CephMig/internal/storage" "encoding/json" "flag" "fmt" "io" "os" ) func main() { config := flag.String("config", "/lab/migration.example.json", "config") root := flag.String("root", "/", "path to stat, or snapshot root") rel := flag.String("rel", ".", "relative snapshot path") a := flag.String("from", "", "previous snapshot") b := flag.String("to", "", "current snapshot") flag.Parse() data, err := os.ReadFile(*config) if err != nil { panic(err) } var c struct{ Source storage.Options } if err = json.Unmarshal(data, &c); err != nil { panic(err) } fs, err := cephfsnative.Open(c.Source) if err != nil { panic(err) } defer fs.Close() n, err := fs.Stat(*root) if err != nil { panic(err) } json.NewEncoder(os.Stdout).Encode(n) if *a != "" { d, err := fs.SnapDiff(*root, *rel, *a, *b) if err != nil { panic(err) } defer d.Close() for { name, err := d.Next() if err == io.EOF { break } if err != nil { panic(err) } fmt.Printf("diff: %q\n", name) } } }