diff options
author | gVisor bot <gvisor-bot@google.com> | 2019-09-24 20:32:02 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-09-24 20:32:02 +0000 |
commit | b98250cb102ab2d1f5a87945f7b70a0d24e61d3d (patch) | |
tree | 0cec88f3acd67272353563499b96a08ba7ba457a /pkg/sentry/syscalls/linux/sys_read.go | |
parent | 1a6f7f078a132c93b7edbfe285e583732ba462e9 (diff) | |
parent | 502f8f238ea58c4828e528e563d8dbd419faeea7 (diff) |
Merge release-20190806.1-178-g502f8f2 (automated)
Diffstat (limited to 'pkg/sentry/syscalls/linux/sys_read.go')
-rw-r--r-- | pkg/sentry/syscalls/linux/sys_read.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/pkg/sentry/syscalls/linux/sys_read.go b/pkg/sentry/syscalls/linux/sys_read.go index 3ab54271c..cd31e0649 100644 --- a/pkg/sentry/syscalls/linux/sys_read.go +++ b/pkg/sentry/syscalls/linux/sys_read.go @@ -72,6 +72,39 @@ func Read(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.SyscallC return uintptr(n), nil, handleIOError(t, n != 0, err, kernel.ERESTARTSYS, "read", file) } +// Readahead implements readahead(2). +func Readahead(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) { + fd := args[0].Int() + offset := args[1].Int64() + size := args[2].SizeT() + + file := t.GetFile(fd) + if file == nil { + return 0, nil, syserror.EBADF + } + defer file.DecRef() + + // Check that the file is readable. + if !file.Flags().Read { + return 0, nil, syserror.EBADF + } + + // Check that the size is valid. + if int(size) < 0 { + return 0, nil, syserror.EINVAL + } + + // Check that the offset is legitimate. + if offset < 0 { + return 0, nil, syserror.EINVAL + } + + // Return EINVAL; if the underlying file type does not support readahead, + // then Linux will return EINVAL to indicate as much. In the future, we + // may extend this function to actually support readahead hints. + return 0, nil, syserror.EINVAL +} + // Pread64 implements linux syscall pread64(2). func Pread64(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) { fd := args[0].Int() |