Commit c3e96abe authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Add -mem flag to unionfs example.

parent 3fed732a
...@@ -11,29 +11,36 @@ import ( ...@@ -11,29 +11,36 @@ import (
func main() { func main() {
debug := flag.Bool("debug", false, "debug on") debug := flag.Bool("debug", false, "debug on")
mem := flag.Bool("mem", false, "use in-memory unionfs")
delcache_ttl := flag.Float64("deletion_cache_ttl", 5.0, "Deletion cache TTL in seconds.") delcache_ttl := flag.Float64("deletion_cache_ttl", 5.0, "Deletion cache TTL in seconds.")
branchcache_ttl := flag.Float64("branchcache_ttl", 5.0, "Branch cache TTL in seconds.") branchcache_ttl := flag.Float64("branchcache_ttl", 5.0, "Branch cache TTL in seconds.")
deldirname := flag.String( deldirname := flag.String(
"deletion_dirname", "GOUNIONFS_DELETIONS", "Directory name to use for deletions.") "deletion_dirname", "GOUNIONFS_DELETIONS", "Directory name to use for deletions.")
flag.Parse() flag.Parse()
if len(flag.Args()) < 2 { if len(flag.Args()) < 2 {
fmt.Println("Usage:\n main MOUNTPOINT RW-DIRECTORY RO-DIRECTORY ...") fmt.Println("Usage:\n unionfs MOUNTPOINT RW-DIRECTORY RO-DIRECTORY ...")
os.Exit(2) os.Exit(2)
} }
ufsOptions := unionfs.UnionFsOptions{ var nodeFs fuse.NodeFileSystem
DeletionCacheTTLSecs: *delcache_ttl, if *mem {
BranchCacheTTLSecs: *branchcache_ttl, nodeFs = unionfs.NewMemUnionFs(
DeletionDirName: *deldirname, flag.Arg(1) + "/", &fuse.LoopbackFileSystem{Root: flag.Arg(2)})
} } else {
ufsOptions := unionfs.UnionFsOptions{
DeletionCacheTTLSecs: *delcache_ttl,
BranchCacheTTLSecs: *branchcache_ttl,
DeletionDirName: *deldirname,
}
ufs, err := unionfs.NewUnionFsFromRoots(flag.Args()[1:], &ufsOptions, true) ufs, err := unionfs.NewUnionFsFromRoots(flag.Args()[1:], &ufsOptions, true)
if err != nil { if err != nil {
log.Fatal("Cannot create UnionFs", err) log.Fatal("Cannot create UnionFs", err)
os.Exit(1) os.Exit(1)
}
nodeFs = fuse.NewPathNodeFs(ufs, &fuse.PathNodeFsOptions{ClientInodes: true})
} }
mountState, _, err := fuse.MountPathFileSystem(flag.Arg(0), ufs, nil) mountState, _, err := fuse.MountNodeFileSystem(flag.Arg(0), nodeFs, nil)
if err != nil { if err != nil {
log.Fatal("Mount fail:", err) log.Fatal("Mount fail:", err)
} }
......
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