Add sanity check that overlayCreate is called with an overlay parent inode.

PiperOrigin-RevId: 272987037
This commit is contained in:
Nicolas Lacasse
2019-10-04 17:03:50 -07:00
committed by gVisor bot
parent b941e35761
commit f24c3188b5
+6
View File
@@ -15,6 +15,7 @@
package fs
import (
"fmt"
"strings"
"gvisor.dev/gvisor/pkg/abi/linux"
@@ -207,6 +208,11 @@ func overlayLookup(ctx context.Context, parent *overlayEntry, inode *Inode, name
}
func overlayCreate(ctx context.Context, o *overlayEntry, parent *Dirent, name string, flags FileFlags, perm FilePermissions) (*File, error) {
// Sanity check.
if parent.Inode.overlay == nil {
panic(fmt.Sprintf("overlayCreate called with non-overlay parent inode (parent InodeOperations type is %T)", parent.Inode.InodeOperations))
}
// Dirent.Create takes renameMu if the Inode is an overlay Inode.
if err := copyUpLockedForRename(ctx, parent); err != nil {
return nil, err