ext: wrap close_range syscall
All checks were successful
Test / Create distribution (push) Successful in 1m3s
Test / Sandbox (push) Successful in 2m48s
Test / Hakurei (push) Successful in 3m38s
Test / ShareFS (push) Successful in 3m41s
Test / Sandbox (race detector) (push) Successful in 5m6s
Test / Hakurei (race detector) (push) Successful in 6m10s
Test / Flake checks (push) Successful in 1m17s
All checks were successful
Test / Create distribution (push) Successful in 1m3s
Test / Sandbox (push) Successful in 2m48s
Test / Hakurei (push) Successful in 3m38s
Test / ShareFS (push) Successful in 3m41s
Test / Sandbox (race detector) (push) Successful in 5m6s
Test / Hakurei (race detector) (push) Successful in 6m10s
Test / Flake checks (push) Successful in 1m17s
This is useful for container when called with CLOSE_RANGE_CLOEXEC. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -7,6 +7,26 @@ import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// include/uapi/linux/close_range.h
|
||||
const (
|
||||
CLOSE_RANGE_UNSHARE = 1 << (iota + 1)
|
||||
CLOSE_RANGE_CLOEXEC
|
||||
)
|
||||
|
||||
// CloseRange close all file descriptors in a given range.
|
||||
func CloseRange(first, last Uint, flags Int) error {
|
||||
_, _, errno := syscall.Syscall(
|
||||
SYS_CLOSE_RANGE,
|
||||
uintptr(first),
|
||||
uintptr(last),
|
||||
uintptr(flags),
|
||||
)
|
||||
if errno != 0 {
|
||||
return errno
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SchedPolicy denotes a scheduling policy defined in include/uapi/linux/sched.h.
|
||||
type SchedPolicy int
|
||||
|
||||
|
||||
Reference in New Issue
Block a user