diff --git a/svfs/directory.go b/svfs/directory.go index 21cd928..8931f11 100644 --- a/svfs/directory.go +++ b/svfs/directory.go @@ -17,6 +17,7 @@ var ( ) type Directory struct { + apex bool name string path string s *swift.Connection @@ -148,7 +149,7 @@ func (d *Directory) ReadDirAll(ctx context.Context) (entries []fuse.Dirent, err func (d *Directory) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (fs.Node, error) { // Get children if this node was evicted from the kernel cache - if len(d.children) == 0 && d.c != nil { + if len(d.children) == 0 { d.ReadDirAll(ctx) } diff --git a/svfs/fs.go b/svfs/fs.go index 2b3b5e4..5d0eb57 100644 --- a/svfs/fs.go +++ b/svfs/fs.go @@ -41,15 +41,17 @@ func (s *SVFS) Root() (fs.Node, error) { return &Container{ Directory: &Directory{ - s: s.s, - c: &baseC, + apex: true, + s: s.s, + c: &baseC, }, cs: &segC, }, nil } return &Root{ Directory: &Directory{ - s: s.s, + apex: true, + s: s.s, }, }, nil } diff --git a/svfs/object.go b/svfs/object.go index 959f9ef..ab203d7 100644 --- a/svfs/object.go +++ b/svfs/object.go @@ -57,7 +57,6 @@ func (o *Object) open(mode fuse.OpenFlags) (oh *ObjectHandle, err error) { } func (o *Object) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) { - resp.Flags = fuse.OpenDirectIO return o.open(req.Flags) } diff --git a/svfs/root.go b/svfs/root.go index d0cd51b..0fa1d41 100644 --- a/svfs/root.go +++ b/svfs/root.go @@ -91,6 +91,22 @@ func (r *Root) ReadDirAll(ctx context.Context) (entries []fuse.Dirent, err error return entries, nil } +func (r *Root) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (fs.Node, error) { + if len(r.children) == 0 { + r.ReadDirAll(ctx) + } + + for _, item := range r.children { + if item.Name() == req.Name { + if n, ok := item.(*Container); ok { + return n, nil + } + } + } + + return nil, fuse.ENOENT +} + var ( _ Node = (*Root)(nil) _ fs.Node = (*Root)(nil)