diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-01-29 01:07:21 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-01-29 01:07:21 +0000 |
commit | 3c4a7fb34fca7c949d3b6fdb47306f53a1531f75 (patch) | |
tree | f241b8efbaa4cadc07af331d09d462e6aed80c47 /pkg/sentry/syscalls/linux/vfs2/sys_read.go | |
parent | 0ff8f6cdad988e02ebee3cda89492038360b0173 (diff) | |
parent | 3d046fef06ece6ba20770fa62e0a21569226adaa (diff) |
Merge release-20200115.0-127-g3d046fe (automated)
Diffstat (limited to 'pkg/sentry/syscalls/linux/vfs2/sys_read.go')
-rwxr-xr-x | pkg/sentry/syscalls/linux/vfs2/sys_read.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/pkg/sentry/syscalls/linux/vfs2/sys_read.go b/pkg/sentry/syscalls/linux/vfs2/sys_read.go index b9fb58464..7667524c7 100755 --- a/pkg/sentry/syscalls/linux/vfs2/sys_read.go +++ b/pkg/sentry/syscalls/linux/vfs2/sys_read.go @@ -24,6 +24,11 @@ import ( "gvisor.dev/gvisor/pkg/waiter" ) +const ( + // EventMaskRead contains events that can be triggered on reads. + EventMaskRead = waiter.EventIn | waiter.EventHUp | waiter.EventErr +) + // Read implements linux syscall read(2). Note that we try to get a buffer that // is exactly the size requested because some applications like qemu expect // they can do large reads all at once. Bug for bug. Same for other read @@ -39,11 +44,6 @@ func Read(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.SyscallC } defer file.DecRef() - // Check that the file is readable. - if !file.IsReadable() { - return 0, nil, syserror.EBADF - } - // Check that the size is legitimate. si := int(size) if si < 0 { @@ -70,8 +70,8 @@ func read(t *kernel.Task, file *vfs.FileDescription, dst usermem.IOSequence, opt } // Register for notifications. - _, ch := waiter.NewChannelEntry(nil) - // file.EventRegister(&w, EventMaskRead) + w, ch := waiter.NewChannelEntry(nil) + file.EventRegister(&w, EventMaskRead) total := n for { @@ -89,7 +89,7 @@ func read(t *kernel.Task, file *vfs.FileDescription, dst usermem.IOSequence, opt break } } - //file.EventUnregister(&w) + file.EventUnregister(&w) return total, err } |