Files
CephfsMig/cmd/nativeprobe/main_ceph.go
T
Sebastian UnterschützandClaude Opus 5.5 8fe60a4f8f refactor!: rename module and move CLI to cmd/cephmig
Use the repository path git.zb-server.de/Sebi/CephfsMig as module
path instead of the non-importable name CephMig, and move the cephmig
entry point from the repository root to cmd/cephmig next to
cmd/nativeprobe. Makefile and Dockerfile.native build the new path.

BREAKING CHANGE: import paths change from CephMig/... to
git.zb-server.de/Sebi/CephfsMig/..., and the binary is now built from
./cmd/cephmig instead of the module root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 18:06:09 +01:00

58 lines
1.1 KiB
Go

//go:build ceph && cgo
package main
import (
"encoding/json"
"flag"
"fmt"
"git.zb-server.de/Sebi/CephfsMig/internal/cephfsnative"
"git.zb-server.de/Sebi/CephfsMig/internal/storage"
"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)
}
}
}