mirror of https://github.com/perkeep/perkeep.git
cammount: start with hanwen's example loopback fuse program.
This commit is contained in:
parent
d630a0e9a3
commit
7332f1aa71
|
@ -8,3 +8,4 @@ _obj
|
||||||
[68].out
|
[68].out
|
||||||
_test
|
_test
|
||||||
_testmain.go
|
_testmain.go
|
||||||
|
_go_.[568]
|
||||||
|
|
1
build.pl
1
build.pl
|
@ -352,6 +352,7 @@ __DATA__
|
||||||
|
|
||||||
TARGET: clients/go/camget
|
TARGET: clients/go/camget
|
||||||
TARGET: clients/go/camput
|
TARGET: clients/go/camput
|
||||||
|
TARGET: clients/go/cammount
|
||||||
TARGET: clients/go/camsync
|
TARGET: clients/go/camsync
|
||||||
TARGET: lib/go/camli/auth
|
TARGET: lib/go/camli/auth
|
||||||
TARGET: lib/go/camli/blobref
|
TARGET: lib/go/camli/blobref
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
cammount
|
||||||
|
_go_.[568]
|
|
@ -0,0 +1,94 @@
|
||||||
|
/*
|
||||||
|
Copyright 2011 Google Inc.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"sort"
|
||||||
|
|
||||||
|
"camli/third_party/github.com/hanwen/go-fuse/fuse"
|
||||||
|
)
|
||||||
|
|
||||||
|
func PrintMap(m map[string]float64) {
|
||||||
|
keys := make([]string, len(m))
|
||||||
|
for k, _ := range m {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.SortStrings(keys)
|
||||||
|
for _, k := range keys {
|
||||||
|
if m[k] > 0 {
|
||||||
|
fmt.Println(k, m[k])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Scans the arg list and sets up flags
|
||||||
|
debug := flag.Bool("debug", false, "print debugging messages.")
|
||||||
|
threaded := flag.Bool("threaded", true, "switch off threading; print debugging messages.")
|
||||||
|
flag.Parse()
|
||||||
|
if flag.NArg() < 2 {
|
||||||
|
// TODO - where to get program name?
|
||||||
|
fmt.Println("usage: main ORIGINAL MOUNTPOINT")
|
||||||
|
os.Exit(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
orig := flag.Arg(0)
|
||||||
|
fs := fuse.NewLoopbackFileSystem(orig)
|
||||||
|
timing := fuse.NewTimingPathFilesystem(fs)
|
||||||
|
|
||||||
|
var opts fuse.PathFileSystemConnectorOptions
|
||||||
|
|
||||||
|
opts.AttrTimeout = 1.0
|
||||||
|
opts.EntryTimeout = 1.0
|
||||||
|
opts.NegativeTimeout = 1.0
|
||||||
|
|
||||||
|
fs.SetOptions(&opts)
|
||||||
|
|
||||||
|
conn := fuse.NewPathFileSystemConnector(timing)
|
||||||
|
rawTiming := fuse.NewTimingRawFilesystem(conn)
|
||||||
|
|
||||||
|
state := fuse.NewMountState(rawTiming)
|
||||||
|
state.Debug = *debug
|
||||||
|
|
||||||
|
mountPoint := flag.Arg(1)
|
||||||
|
err := state.Mount(mountPoint)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("MountFuse fail: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Mounted %s on %s (threaded=%v, debug=%v)\n", orig, mountPoint, *threaded, *debug)
|
||||||
|
state.Loop(*threaded)
|
||||||
|
fmt.Println("Finished", state.Stats())
|
||||||
|
|
||||||
|
counts := state.OperationCounts()
|
||||||
|
fmt.Println("Counts: ", counts)
|
||||||
|
|
||||||
|
latency := state.Latencies()
|
||||||
|
fmt.Println("MountState latency (ms):")
|
||||||
|
PrintMap(latency)
|
||||||
|
|
||||||
|
latency = timing.Latencies()
|
||||||
|
fmt.Println("Path ops (ms):", latency)
|
||||||
|
|
||||||
|
latency = rawTiming.Latencies()
|
||||||
|
fmt.Println("Raw FS (ms):", latency)
|
||||||
|
}
|
Loading…
Reference in New Issue