diff options
Diffstat (limited to 'src/syscall/syscall_linux_386.go')
-rw-r--r-- | src/syscall/syscall_linux_386.go | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/syscall/syscall_linux_386.go b/src/syscall/syscall_linux_386.go index fc7df8496e..e2fade8285 100644 --- a/src/syscall/syscall_linux_386.go +++ b/src/syscall/syscall_linux_386.go @@ -104,9 +104,9 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) { return } -//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT +//sysnb setrlimit1(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT -func Setrlimit(resource int, rlim *Rlimit) (err error) { +func setrlimit(resource int, rlim *Rlimit) (err error) { err = prlimit(0, resource, rlim, nil) if err != ENOSYS { return err @@ -128,7 +128,34 @@ func Setrlimit(resource int, rlim *Rlimit) (err error) { return EINVAL } - return setrlimit(resource, &rl) + return setrlimit1(resource, &rl) +} + +//go:nosplit +func rawSetrlimit(resource int, rlim *Rlimit) Errno { + _, _, errno := RawSyscall6(SYS_PRLIMIT64, 0, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0, 0, 0) + if errno != ENOSYS { + return errno + } + + rl := rlimit32{} + if rlim.Cur == rlimInf64 { + rl.Cur = rlimInf32 + } else if rlim.Cur < uint64(rlimInf32) { + rl.Cur = uint32(rlim.Cur) + } else { + return EINVAL + } + if rlim.Max == rlimInf64 { + rl.Max = rlimInf32 + } else if rlim.Max < uint64(rlimInf32) { + rl.Max = uint32(rlim.Max) + } else { + return EINVAL + } + + _, _, errno = RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + return errno } // Underlying system call writes to newoffset via pointer. |