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 (
func main() {
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.")
branchcache_ttl := flag.Float64("branchcache_ttl", 5.0, "Branch cache TTL in seconds.")
deldirname := flag.String(
"deletion_dirname", "GOUNIONFS_DELETIONS", "Directory name to use for deletions.")
flag.Parse()
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)
}
ufsOptions := unionfs.UnionFsOptions{
DeletionCacheTTLSecs: *delcache_ttl,
BranchCacheTTLSecs: *branchcache_ttl,
DeletionDirName: *deldirname,
}
var nodeFs fuse.NodeFileSystem
if *mem {
nodeFs = unionfs.NewMemUnionFs(
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)
if err != nil {
log.Fatal("Cannot create UnionFs", err)
os.Exit(1)
ufs, err := unionfs.NewUnionFsFromRoots(flag.Args()[1:], &ufsOptions, true)
if err != nil {
log.Fatal("Cannot create UnionFs", err)
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 {
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