Allow overlay to merge Directories and SepcialDirectories.

Needed to mount inside /proc or /sys.

PiperOrigin-RevId: 235936529
Change-Id: Iee6f2671721b1b9b58a3989705ea901322ec9206
This commit is contained in:
Nicolas Lacasse
2019-02-27 09:45:45 -08:00
committed by Shentubot
parent cff2c57192
commit d516ee3312
+12 -3
View File
@@ -131,11 +131,20 @@ func overlayLookup(ctx context.Context, parent *overlayEntry, inode *Inode, name
}
if child != nil {
if !child.IsNegative() {
// Did we find something in the upper filesystem? We can
// only use it if the types match.
if upperInode == nil || upperInode.StableAttr.Type == child.Inode.StableAttr.Type {
if upperInode == nil {
// If nothing was in the upper, use what we found in the lower.
lowerInode = child.Inode
lowerInode.IncRef()
} else {
// If we have something from the upper, we can only use it if the types
// match.
// NOTE: Allow SpecialDirectories and Directories to merge.
// This is needed to allow submounts in /proc and /sys.
if upperInode.StableAttr.Type == child.Inode.StableAttr.Type ||
(IsDir(upperInode.StableAttr) && IsDir(child.Inode.StableAttr)) {
lowerInode = child.Inode
lowerInode.IncRef()
}
}
}
child.DecRef()