Commit 3c0c2f7e authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Fix zipfs and unionfs for pathfs.NewDefaultFileSystem() API change.

parent 5c9096d6
......@@ -11,7 +11,7 @@ import (
)
type HelloFs struct {
pathfs.DefaultFileSystem
pathfs.FileSystem
}
func (me *HelloFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) {
......@@ -51,7 +51,7 @@ func main() {
if len(flag.Args()) < 1 {
log.Fatal("Usage:\n hello MOUNTPOINT")
}
nfs := pathfs.NewPathNodeFs(&HelloFs{}, nil)
nfs := pathfs.NewPathNodeFs(&HelloFs{FileSystem: pathfs.NewDefaultFileSystem()}, nil)
state, _, err := fuse.MountNodeFileSystem(flag.Arg(0), nfs, nil)
if err != nil {
log.Fatal("Mount fail: %v\n", err)
......
......@@ -20,7 +20,6 @@ var _ = log.Printf
func main() {
// Scans the arg list and sets up flags
debug := flag.Bool("debug", false, "print debugging messages.")
latencies := flag.Bool("latencies", false, "record operation latencies.")
profile := flag.String("profile", "", "record cpu profile.")
mem_profile := flag.String("mem-profile", "", "record memory profile.")
command := flag.String("run", "", "run this command after mounting.")
......@@ -63,7 +62,6 @@ func main() {
os.Exit(1)
}
state.SetRecordStatistics(*latencies)
state.SetDebug(*debug)
runtime.GC()
if profFile != nil {
......
......@@ -26,7 +26,7 @@ type knownFs struct {
//
// A union for A/B/C will placed under directory A-B-C.
type AutoUnionFs struct {
pathfs.DefaultFileSystem
pathfs.FileSystem
debug bool
lock sync.RWMutex
......@@ -68,10 +68,13 @@ func NewAutoUnionFs(directory string, options AutoUnionFsOptions) *AutoUnionFs {
if options.HideReadonly {
options.HiddenFiles = append(options.HiddenFiles, _READONLY)
}
a := new(AutoUnionFs)
a.knownFileSystems = make(map[string]knownFs)
a.nameRootMap = make(map[string]string)
a.options = &options
a := &AutoUnionFs{
knownFileSystems: make(map[string]knownFs),
nameRootMap: make(map[string]string),
options: &options,
FileSystem: pathfs.NewDefaultFileSystem(),
}
directory, err := filepath.Abs(directory)
if err != nil {
panic("filepath.Abs returned err")
......
......@@ -57,7 +57,7 @@ func filePathHash(path string) string {
*/
type UnionFs struct {
pathfs.DefaultFileSystem
pathfs.FileSystem
// The same, but as interfaces.
fileSystems []pathfs.FileSystem
......@@ -87,9 +87,11 @@ const (
)
func NewUnionFs(fileSystems []pathfs.FileSystem, options UnionFsOptions) *UnionFs {
g := new(UnionFs)
g.options = &options
g.fileSystems = fileSystems
g := &UnionFs{
options: &options,
fileSystems: fileSystems,
FileSystem: pathfs.NewDefaultFileSystem(),
}
writable := g.fileSystems[0]
code := g.createDeletionStore()
......
......@@ -1135,8 +1135,9 @@ func TestUnionFsDisappearing(t *testing.T) {
}
state.ThreadSanitizerSync()
oldRoot := wrFs.Root
wrFs.Root = "/dev/null"
// TODO - this is racy. Instead, have a custom FS that will
// switch based on input from a channel
fses[0] = pathfs.NewLoopbackFileSystem("/dev/null")
state.ThreadSanitizerSync()
time.Sleep((3 * entryTtl) / 2)
......@@ -1153,7 +1154,7 @@ func TestUnionFsDisappearing(t *testing.T) {
log.Println("expected write failure:", err)
// Restore, and wait for caches to catch up.
wrFs.Root = oldRoot
fses[0] = pathfs.NewLoopbackFileSystem(wd + "/rw")
state.ThreadSanitizerSync()
time.Sleep((3 * entryTtl) / 2)
......
......@@ -35,13 +35,15 @@ type MultiZipFs struct {
dirZipFileMap map[string]string
nodeFs *pathfs.PathNodeFs
pathfs.DefaultFileSystem
pathfs.FileSystem
}
func NewMultiZipFs() *MultiZipFs {
m := new(MultiZipFs)
m.zips = make(map[string]*MemTreeFs)
m.dirZipFileMap = make(map[string]string)
m := &MultiZipFs{
zips: make(map[string]*MemTreeFs),
dirZipFileMap: make(map[string]string),
FileSystem: pathfs.NewDefaultFileSystem(),
}
return m
}
......
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