Commit 801e5561 authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher Committed by Han-Wen Nienhuys

loopback example: add "-l" flag for enabling hard links

This simplifies testing hard links support (aka ClientInodes)
with external tools like fsstress.
parent 1628b026
...@@ -21,11 +21,14 @@ func main() { ...@@ -21,11 +21,14 @@ func main() {
// Scans the arg list and sets up flags // Scans the arg list and sets up flags
debug := flag.Bool("debug", false, "print debugging messages.") debug := flag.Bool("debug", false, "print debugging messages.")
other := flag.Bool("allow-other", false, "mount with -o allowother.") other := flag.Bool("allow-other", false, "mount with -o allowother.")
enableLinks := flag.Bool("l", false, "Enable hard link support")
cpuprofile := flag.String("cpuprofile", "", "write cpu profile to this file") cpuprofile := flag.String("cpuprofile", "", "write cpu profile to this file")
memprofile := flag.String("memprofile", "", "write memory profile to this file") memprofile := flag.String("memprofile", "", "write memory profile to this file")
flag.Parse() flag.Parse()
if flag.NArg() < 2 { if flag.NArg() < 2 {
fmt.Printf("usage: %s MOUNTPOINT ORIGINAL\n", path.Base(os.Args[0])) fmt.Printf("usage: %s MOUNTPOINT ORIGINAL\n", path.Base(os.Args[0]))
fmt.Printf("\noptions:\n")
flag.PrintDefaults()
os.Exit(2) os.Exit(2)
} }
if *cpuprofile != "" { if *cpuprofile != "" {
...@@ -67,7 +70,9 @@ func main() { ...@@ -67,7 +70,9 @@ func main() {
AttrTimeout: time.Second, AttrTimeout: time.Second,
EntryTimeout: time.Second, EntryTimeout: time.Second,
} }
pathFs := pathfs.NewPathNodeFs(finalFs, nil) // Enable ClientInodes so hard links work
pathFsOpts := &pathfs.PathNodeFsOptions{ClientInodes: *enableLinks}
pathFs := pathfs.NewPathNodeFs(finalFs, pathFsOpts)
conn := nodefs.NewFileSystemConnector(pathFs.Root(), opts) conn := nodefs.NewFileSystemConnector(pathFs.Root(), opts)
mountPoint := flag.Arg(0) mountPoint := flag.Arg(0)
origAbs, _ := filepath.Abs(orig) origAbs, _ := filepath.Abs(orig)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment