Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Commit

Permalink
Bugfix: lookup fail after mount when no container is specified fixes #18
Browse files Browse the repository at this point in the history


Signed-off-by: Xavier Lucas <xavier.lucas@corp.ovh.com>
  • Loading branch information
Xavier Lucas committed Feb 17, 2016
1 parent 2c8e231 commit 14f17ab
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
3 changes: 2 additions & 1 deletion svfs/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var (
)

type Directory struct {
apex bool
name string
path string
s *swift.Connection
Expand Down Expand Up @@ -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)
}

Expand Down
8 changes: 5 additions & 3 deletions svfs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion svfs/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
16 changes: 16 additions & 0 deletions svfs/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 14f17ab

Please sign in to comment.