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:02:22 -07:00 committed by gVisor bot
parent b941e35761
commit f24c3188b5
1 changed files with 6 additions and 0 deletions

View File

@ -15,6 +15,7 @@
package fs package fs
import ( import (
"fmt"
"strings" "strings"
"gvisor.dev/gvisor/pkg/abi/linux" "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) { 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. // Dirent.Create takes renameMu if the Inode is an overlay Inode.
if err := copyUpLockedForRename(ctx, parent); err != nil { if err := copyUpLockedForRename(ctx, parent); err != nil {
return nil, err return nil, err