mirror of
https://github.com/golang/sys.git
synced 2026-02-08 19:56:04 +03:00
unix: add CloseRange
The close_range(2) syscall is available since Linux kernel v5.9, with additional functionality of CLOSE_RANGE_CLOEXEC since v5.11. No tests are required since this is a bare syscall. Change-Id: I410470e3713e2005cc7acf24d1347938fe05ef63 Reviewed-on: https://go-review.googlesource.com/c/sys/+/301409 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
This commit is contained in:
committed by
Emmanuel Odeke
parent
68d13333fa
commit
8e9fff1a3a
@@ -84,6 +84,7 @@ struct termios2 {
|
||||
#include <linux/can/raw.h>
|
||||
#include <linux/capability.h>
|
||||
#include <linux/cgroupstats.h>
|
||||
#include <linux/close_range.h>
|
||||
#include <linux/cryptouser.h>
|
||||
#include <linux/devlink.h>
|
||||
#include <linux/dm-ioctl.h>
|
||||
@@ -3648,3 +3649,9 @@ type (
|
||||
HIDRawReportDescriptor C.struct_hidraw_report_descriptor
|
||||
HIDRawDevInfo C.struct_hidraw_devinfo
|
||||
)
|
||||
|
||||
// close_range
|
||||
const (
|
||||
CLOSE_RANGE_UNSHARE = C.CLOSE_RANGE_UNSHARE
|
||||
CLOSE_RANGE_CLOEXEC = C.CLOSE_RANGE_CLOEXEC
|
||||
)
|
||||
|
||||
@@ -1877,6 +1877,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
||||
//sys ClockGettime(clockid int32, time *Timespec) (err error)
|
||||
//sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error)
|
||||
//sys Close(fd int) (err error)
|
||||
//sys CloseRange(first uint, last uint, flags uint) (err error)
|
||||
//sys CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
|
||||
//sys DeleteModule(name string, flags int) (err error)
|
||||
//sys Dup(oldfd int) (fd int, err error)
|
||||
|
||||
@@ -532,6 +532,16 @@ func Close(fd int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func CloseRange(first uint, last uint, flags uint) (err error) {
|
||||
_, _, e1 := Syscall(SYS_CLOSE_RANGE, uintptr(first), uintptr(last), uintptr(flags))
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
|
||||
n = int(r0)
|
||||
|
||||
@@ -3709,3 +3709,8 @@ type (
|
||||
Product int16
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
CLOSE_RANGE_UNSHARE = 0x2
|
||||
CLOSE_RANGE_CLOEXEC = 0x4
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user