Skip to content
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

Merged
merged 6 commits into from Oct 6, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion crfs.go
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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.
Copy link
Contributor

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?

Copy link
Contributor Author

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.

}

var (
Expand Down Expand Up @@ -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)}
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

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.

n.children[name] = c

return c, nil
}

// Readlink reads the target of a symlink.
Expand Down