add scoutfs move_blocks

This commit is contained in:
Ben McClelland
2021-01-15 11:53:40 -07:00
parent bd2ba82da4
commit c19fddb618
4 changed files with 93 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
// Copyright (c) 2021 Versity Software, Inc.
//
// Use of this source code is governed by a BSD-3-Clause license
// that can be found in the LICENSE file in the root of the source
// tree.
package main
import (
"fmt"
"os"
scoutfs "github.com/versity/scoutfs-go"
)
func main() {
if len(os.Args) != 3 || os.Args[1] == "-h" {
fmt.Fprintln(os.Stderr, "usage:", os.Args[0], "<file_to_move_blocks_from> <file_to_append_blocks_to>")
os.Exit(1)
}
ffrom, err := os.OpenFile(os.Args[1], os.O_RDWR, 0666)
if err != nil {
fmt.Fprintf(os.Stderr, "open %v: %v\n", os.Args[1], err)
os.Exit(1)
}
defer ffrom.Close()
fto, err := os.OpenFile(os.Args[2], os.O_RDWR, 0666)
if err != nil {
fmt.Fprintf(os.Stderr, "open %v: %v\n", os.Args[2], err)
os.Exit(1)
}
defer fto.Close()
err = scoutfs.MoveData(ffrom, fto)
if err != nil {
fmt.Fprintf(os.Stderr, "move blocks: %v\n", err)
os.Exit(1)
}
}