cammount: update to use rsc's fuse library; pkg/fs: butcher it up to make it compile.

doesn't work again yet.

Change-Id: I462320918026944716638588d08ba76c67c72a73
This commit is contained in:
Brad Fitzpatrick 2012-03-18 23:54:20 -07:00
parent 6ac0b8c027
commit 685189ca4c
2 changed files with 28 additions and 38 deletions

View File

@ -20,6 +20,7 @@ import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"sort"
@ -28,7 +29,8 @@ import (
"camlistore.org/pkg/cacher"
"camlistore.org/pkg/client"
"camlistore.org/pkg/fs"
"camlistore.org/third_party/github.com/hanwen/go-fuse/fuse"
"camlistore.org/third_party/code.google.com/p/rsc/fuse"
)
func PrintMap(m map[string]float64) {
@ -48,7 +50,6 @@ func PrintMap(m map[string]float64) {
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.")
client.AddFlags()
flag.Parse()
@ -79,35 +80,19 @@ func main() {
fetcher := cacher.NewCachingFetcher(diskcache, client)
fs := fs.NewCamliFileSystem(fetcher, root)
timing := fuse.NewTimingPathFilesystem(fs)
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)
if *debug {
// TODO: set fs's logger
}
fmt.Printf("Mounted %s on %s (threaded=%v, debug=%v)\n", root.String(), mountPoint, *threaded, *debug)
state.Loop(*threaded)
fmt.Println("Finished", state.Stats())
mountPoint := flag.Arg(1)
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)
conn, err := fuse.Mount(mountPoint)
if err != nil {
log.Fatalf("Mount: %v", err)
}
err = conn.Serve(fs)
if err != nil {
log.Fatalf("Serve: %", err)
}
log.Printf("fuse process ending.")
}

View File

@ -36,6 +36,7 @@ import (
var _ = fmt.Println
var _ = log.Println
var _ = bytes.NewReader
var errNotDir = fuse.Errno(syscall.ENOTDIR)
@ -48,6 +49,15 @@ type CamliFileSystem struct {
nameToAttr *lru.Cache // ~map[string]*fuse.Attr
}
type CamliFile struct {
fs *CamliFileSystem
blob *blobref.BlobRef
ss *schema.Superset
size uint64 // memoized
}
var _ fuse.FS = (*CamliFileSystem)(nil)
func NewCamliFileSystem(fetcher blobref.SeekFetcher, root *blobref.BlobRef) *CamliFileSystem {
@ -206,6 +216,7 @@ func (fs *CamliFileSystem) blobRefFromName(name string) (retbr *blobref.BlobRef,
return nil, fuse.ENOENT
}
/*
func (fs *CamliFileSystem) GetAttr(name string) (*fuse.Attr, fuse.Error) {
if attr, ok := fs.nameToAttr.Get(name); ok {
return attr.(*fuse.Attr), nil
@ -384,14 +395,6 @@ func (fs *CamliFileSystem) Readlink(name string) (target string, status fuse.Err
return ss.SymlinkTargetString(), nil
}
type CamliFile struct {
fs *CamliFileSystem
blob *blobref.BlobRef
ss *schema.Superset
size uint64 // memoized
}
func (f *CamliFile) Size() uint64 {
if f.size == 0 {
f.size = f.ss.SumPartsSize()
@ -429,6 +432,8 @@ func (file *CamliFile) Read(ri *fuse.ReadIn, bp *fuse.BufferPool) (retbuf []byte
return
}
*/
func (file *CamliFile) GetReader() (io.ReadCloser, error) {
return file.ss.NewFileReader(file.fs.fetcher)
}