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