Make directory open flags checks consistent in tmpfs and kernfs.

Overlayfs and goferfs seem to be up to date.
Updated syscall tests.

PiperOrigin-RevId: 503521750
This commit is contained in:
Ayush Ranjan
2023-01-20 14:22:38 -08:00
committed by gVisor bot
parent 492d7a9811
commit a58df80df3
3 changed files with 29 additions and 4 deletions
+7
View File
@@ -483,10 +483,17 @@ func (d *dentry) open(ctx context.Context, rp *vfs.ResolvingPath, opts *vfs.Open
}
return &fd.vfsfd, nil
case *directory:
// Can't open directories with O_CREAT.
if opts.Flags&linux.O_CREAT != 0 {
return nil, linuxerr.EISDIR
}
// Can't open directories writably.
if ats&vfs.MayWrite != 0 {
return nil, linuxerr.EISDIR
}
if opts.Flags&linux.O_DIRECT != 0 {
return nil, linuxerr.EINVAL
}
var fd directoryFD
fd.LockFD.Init(&d.inode.locks)
if err := fd.vfsfd.Init(&fd, opts.Flags, rp.Mount(), &d.vfsd, &vfs.FileDescriptionOptions{AllowDirectIO: true}); err != nil {