Allow O_DIRECT with gofer.specialFileFD that represent regular files.

gofer.specialFileFD can sometimes represent regular files. O_DIRECT
is expected to be supported there.

PiperOrigin-RevId: 476408649
This commit is contained in:
Ayush Ranjan
2022-09-23 10:46:07 -07:00
committed by gVisor bot
parent c895fa2441
commit de7c2164d7
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -1255,7 +1255,7 @@ func (d *dentry) openSocketByConnecting(ctx context.Context, opts *vfs.OpenOptio
func (d *dentry) openSpecialFile(ctx context.Context, mnt *vfs.Mount, opts *vfs.OpenOptions) (*vfs.FileDescription, error) {
ats := vfs.AccessTypesForOpenFlags(opts)
if opts.Flags&linux.O_DIRECT != 0 {
if opts.Flags&linux.O_DIRECT != 0 && !d.isRegularFile() {
return nil, linuxerr.EINVAL
}
// We assume that the server silently inserts O_NONBLOCK in the open flags
+3 -2
View File
@@ -108,8 +108,9 @@ func newSpecialFileFD(h handle, mnt *vfs.Mount, d *dentry, flags uint32) (*speci
}
}
if err := fd.vfsfd.Init(fd, flags, mnt, &d.vfsd, &vfs.FileDescriptionOptions{
DenyPRead: !seekable,
DenyPWrite: !seekable,
AllowDirectIO: true,
DenyPRead: !seekable,
DenyPWrite: !seekable,
}); err != nil {
if haveQueue {
fdnotifier.RemoveFD(h.fd)