diff options
author | Michael Pratt <mpratt@google.com> | 2018-10-01 14:15:52 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-10-01 14:16:53 -0700 |
commit | 0400e5459288592768af12ab71609c6df6afe3d7 (patch) | |
tree | b8c522749a19aa467b62d097a6b58042d0f971d2 /pkg/sentry/syscalls | |
parent | d185552e79e19bd25cdcf64c123712086c48ae58 (diff) |
Add itimer types to linux package, strace
PiperOrigin-RevId: 215278262
Change-Id: Icd10384c99802be6097be938196044386441e282
Diffstat (limited to 'pkg/sentry/syscalls')
-rw-r--r-- | pkg/sentry/syscalls/linux/sys_timer.go | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/pkg/sentry/syscalls/linux/sys_timer.go b/pkg/sentry/syscalls/linux/sys_timer.go index aaed75c81..a12d12d9d 100644 --- a/pkg/sentry/syscalls/linux/sys_timer.go +++ b/pkg/sentry/syscalls/linux/sys_timer.go @@ -25,19 +25,6 @@ import ( "gvisor.googlesource.com/gvisor/pkg/sentry/usermem" ) -// ItimerType denotes the type of interval timer. -type ItimerType int - -// Interval timer types from <sys/time.h>. -const ( - // ItimerReal equals to ITIMER_REAL. - ItimerReal ItimerType = iota - // ItimerVirtual equals to ITIMER_VIRTUAL. - ItimerVirtual - // ItimerProf equals to ITIMER_PROF. - ItimerProf -) - const nsecPerSec = int64(time.Second) // copyItimerValIn copies an ItimerVal from the untrusted app range to the @@ -83,13 +70,13 @@ func copyItimerValOut(t *kernel.Task, addr usermem.Addr, itv *linux.ItimerVal) e } } -func findTimer(t *kernel.Task, w ItimerType) (*ktime.Timer, error) { - switch w { - case ItimerReal: +func findTimer(t *kernel.Task, which int32) (*ktime.Timer, error) { + switch which { + case linux.ITIMER_REAL: return t.ThreadGroup().Timer().RealTimer, nil - case ItimerVirtual: + case linux.ITIMER_VIRTUAL: return t.ThreadGroup().Timer().VirtualTimer, nil - case ItimerProf: + case linux.ITIMER_PROF: return t.ThreadGroup().Timer().ProfTimer, nil default: return nil, syscall.EINVAL @@ -98,7 +85,7 @@ func findTimer(t *kernel.Task, w ItimerType) (*ktime.Timer, error) { // Getitimer implements linux syscall getitimer(2). func Getitimer(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) { - timerID := ItimerType(args[0].Int()) + timerID := args[0].Int() val := args[1].Pointer() timer, err := findTimer(t, timerID) @@ -116,7 +103,7 @@ func Getitimer(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sys // Setitimer implements linux syscall setitimer(2). func Setitimer(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) { - timerID := ItimerType(args[0].Int()) + timerID := args[0].Int() newVal := args[1].Pointer() oldVal := args[2].Pointer() |