New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide same Node instance for same file not to make overlayfs confused. #19
Changes from 1 commit
25f7e4e
b076f18
e18ee07
39ae89f
2a9eb81
c979e09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -474,6 +474,7 @@ func (n *layerDebugRoot) Lookup(ctx context.Context, name string) (fspkg.Node, e | |
te: root, | ||
sr: r, | ||
f: f, | ||
children: make(map[string]fspkg.Node), | ||
}, nil | ||
} | ||
|
||
|
@@ -775,6 +776,7 @@ func (n *layerHostOwnerImageReference) Lookup(ctx context.Context, name string) | |
fs: n.fs, | ||
te: root, | ||
sr: r, | ||
children: make(map[string]fspkg.Node), | ||
}, nil | ||
} | ||
|
||
|
@@ -901,6 +903,7 @@ type node struct { | |
te *stargz.TOCEntry | ||
sr *stargz.Reader | ||
f *os.File // non-nil if root & in debug mode | ||
children map[string]fspkg.Node // Remenber child nodes once looked up. | ||
} | ||
|
||
var ( | ||
|
@@ -966,11 +969,19 @@ func (h *nodeHandle) ReadDirAll(ctx context.Context) (ents []fuse.Dirent, err er | |
// | ||
// See https://godoc.org/bazil.org/fuse/fs#NodeStringLookuper | ||
func (n *node) Lookup(ctx context.Context, name string) (fspkg.Node, error) { | ||
if c, ok := n.children[name] ; ok { | ||
return c, nil | ||
} | ||
|
||
e, ok := n.te.LookupChild(name) | ||
if !ok { | ||
return nil, fuse.ENOENT | ||
} | ||
return &node{n.fs, e, n.sr, nil}, nil | ||
|
||
c := &node{n.fs, e, n.sr, nil, make(map[string]fspkg.Node)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Arguably positional initializing was already overdue before, but now it really is. Switch these to named fields here and drop the nil entry. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your review. I fixed it on b076f18. |
||
n.children[name] = c | ||
|
||
return c, nil | ||
} | ||
|
||
// Readlink reads the target of a symlink. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: remember
But more important is to document what the keys look like. It might make sense to use a before-line comment and spell it all out:
// children maps from previously-looked up base names (like "foo.txt") to
// the *node that was previously returned. This prevents FUSE inode numbers
// from getting out of sync
child map[string]*node
Also, I'd make the value type just be
*node
. It's slightly faster and smaller, but it's also more clear because that's the only type we'll have there, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review. I fixed it on b076f18.