Skip to content

Commit b076f18

Browse files
committed
Fix to make comments, types and initialization easier to understand
Signed-off-by: Kohei Tokunaga <[email protected]>
1 parent 25f7e4e commit b076f18

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

crfs.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ func (n *layerDebugRoot) Lookup(ctx context.Context, name string) (fspkg.Node, e
474474
te: root,
475475
sr: r,
476476
f: f,
477-
children: make(map[string]fspkg.Node),
477+
child: make(map[string]*node),
478478
}, nil
479479
}
480480

@@ -776,7 +776,7 @@ func (n *layerHostOwnerImageReference) Lookup(ctx context.Context, name string)
776776
fs: n.fs,
777777
te: root,
778778
sr: r,
779-
children: make(map[string]fspkg.Node),
779+
child: make(map[string]*node),
780780
}, nil
781781
}
782782

@@ -903,7 +903,11 @@ type node struct {
903903
te *stargz.TOCEntry
904904
sr *stargz.Reader
905905
f *os.File // non-nil if root & in debug mode
906-
children map[string]fspkg.Node // Remenber child nodes once looked up.
906+
907+
// children maps from previously-looked up base names (like "foo.txt") to
908+
// the *node that was previously returned. This prevents FUSE inode numbers
909+
// from getting out of sync
910+
child map[string]*node
907911
}
908912

909913
var (
@@ -969,7 +973,7 @@ func (h *nodeHandle) ReadDirAll(ctx context.Context) (ents []fuse.Dirent, err er
969973
//
970974
// See https://godoc.org/bazil.org/fuse/fs#NodeStringLookuper
971975
func (n *node) Lookup(ctx context.Context, name string) (fspkg.Node, error) {
972-
if c, ok := n.children[name] ; ok {
976+
if c, ok := n.child[name] ; ok {
973977
return c, nil
974978
}
975979

@@ -978,8 +982,13 @@ func (n *node) Lookup(ctx context.Context, name string) (fspkg.Node, error) {
978982
return nil, fuse.ENOENT
979983
}
980984

981-
c := &node{n.fs, e, n.sr, nil, make(map[string]fspkg.Node)}
982-
n.children[name] = c
985+
c := &node{
986+
fs: n.fs,
987+
te: e,
988+
sr: n.sr,
989+
child: make(map[string]*node),
990+
}
991+
n.child[name] = c
983992

984993
return c, nil
985994
}

0 commit comments

Comments
 (0)