23 Commits
Author SHA1 Message Date
RandyTheSilly 534f6d6ab0 Apply patch 2025-11-09 13:58:29 -05:00
Tobias Klauser 15129aafc3 cpu: also use MRS instruction in getmmfr1
Use the MRS instruction with the corresponding system register instead
of encoding the instructions using a WORD directive. This was missed in
CL 583135.

Change-Id: Ifcbbd81baa903f1da442eae2e49c06284db9c37d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/717681
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-11-04 13:29:36 -08:00
Tobias Klauser ed38ca2d41 unix: add SizeofNhmsg and SizeofNexthopGrp
These were missed in CL 227357.

For golang/go#38249

Change-Id: Iab75145ae77a027e11bc4cad75300af0a510a537
Reviewed-on: https://go-review.googlesource.com/c/sys/+/716780
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
2025-11-04 13:29:33 -08:00
Tobias Klauser 3675c4cc48 cpu: use MRS instruction to read arm64 system registers
Use the MRS instruction with the corresponding system register instead
of encoding the instructions using a WORD directive.

Change-Id: I2995dfa6ad731cb03867160127db84898adfdda5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/583135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2025-10-31 12:39:58 -07:00
Florian Lehner 2a15272850 unix: add consts for ELF handling
This adds a few constants that help to handle ELF files and coredumps.

Change-Id: Ifd4c1bd4c8839065af4233ccbf42964a8e96fdf8
Reviewed-on: https://go-review.googlesource.com/c/sys/+/713980
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-10-29 13:35:45 -07:00
Chongyi Zheng 6239615695 cpu: add HPDS, LOR, PAN detection for arm64
This CL gets ID_AA64MMFR1_EL1, Memory Model Feature Register 1, and
grabs HPDS, LOR, PAN features from its bits.

Fixes golang/go#75472.

Change-Id: Ic04b109d79aceba9b3b1d3a1ea514fcf132007c5
GitHub-Last-Rev: f938ff468bca49cc7863aa26e7a880eec2823bb4
GitHub-Pull-Request: golang/sys#263
Reviewed-on: https://go-review.googlesource.com/c/sys/+/704075
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-10-28 09:43:50 -07:00
database64128 ea436ef09d windows: add iphlpapi routing functions
NotifyRouteChange2 registers to be notified for changes to IP route
entries. Call GetIpForwardEntry2 on received row to retrieve complete
information.

GetIpForwardTable2 retrieves the full routing table.
FreeMibTable frees the buffer allocated by the functions that return
tables of network interfaces, addresses, and routes.

Change-Id: I9fba75f1f728661e45dc3092e35eb9099b0570dd
Reviewed-on: https://go-review.googlesource.com/c/sys/+/695195
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-10-21 11:10:28 -07:00
Kir Kolyshkin 28c5bda5d4 unix: add SetMemPolicy and its mode/flag values
This reuses CPUSet type as it fits perfectly.

No GetMemPolicy support yet.

Change-Id: I549361bc1ed95ee73fd38d00277ec0f9f348a9ba
Reviewed-on: https://go-review.googlesource.com/c/sys/+/706917
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Antti Kervinen <antti.kervinen@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-10-08 14:29:03 -07:00
Kir Kolyshkin b731f782ac unix/linux: switch to ubuntu 25.04, Go 1.25.1
Ubuntu 24.10 is not supported since July 2025 (and some of its apt repos
are apparently removed), and so mkall.sh no longer works (as of today).

Fix this by switching to (currently supported) Ubuntu 25.04.

NOTE that we can't switch to
 - Ubuntu 24.04 LTS release (see CL 618075);
 - Ubuntu 25.10 as it lacks mips support;
 - Debian Stable (13) as it also lacks mips support.

Also, bump Go to 1.25.1.

No changes in generated content after running

	GOOS=linux GOARCH=amd64 ./mkall.sh

Change-Id: I58a4856cda93a85af51f4a519c6e4e25f31a39b4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/706915
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-10-08 14:29:00 -07:00
Kir Kolyshkin 1edeebeea0 unix: mkall.sh: fail if docker build failed
When docker build fails, docker run (in my case podman) tries to find
the generate:linux image from various mirrors, which is very confusing.
We should error out if docker build fails.

Change-Id: I4fd78e9fa339e03029b1bf003b3239ca23a7ed1b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/706916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-10-02 13:28:30 -07:00
Tobias Klauser ecada54126 unix: use slices.{Equal,Sort} in tests
Same as CL 587655 and CL 690475 did for package syscall tests.

Change-Id: Ie3c8726a4e2c859b5d7992ea1baec14083b9fdba
Reviewed-on: https://go-review.googlesource.com/c/sys/+/708558
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
2025-10-02 11:15:31 -07:00
qmuntal 5e63aa5e0f windows: export O_FILE_FLAG_* to be used in os.OpenFile on windows
These file flags are supported by os.OpenFile since CL 699415.

Closes golang/go#73676

Change-Id: Iaf846c9cb98c1458bbc30d05ad8a331ef1f332df
Reviewed-on: https://go-review.googlesource.com/c/sys/+/700975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-09-26 11:36:48 -07:00
Aleksa Sarai 033906b9f0 unix: add (*CPUSet).Fill helper to enable all CPUs
Some programs (such as container runtimes) want to reset their CPU
affinity if they are spawned by processes with a particular CPU
affinity. Container runtimes didn't really have to deal with this issue
until Linux 6.2 when the cpuset cgroup was changed to no longer
auto-reset CPU affinity in this case.

A naive approach to resetting your CPU affinity would be to get the
number of CPUs by looking at "/proc/stat" or "/sys/devices/system/cpu"
(note that runtime.NumCPU() actually returns the CPU affinity of the
process at startup time, which isn't useful for this purpose) and then
asking for all of those CPUs.

However, sched_setaffinity(2) will silently ignore any CPU bits set in
the provided CPUSet if they do not exist or are not enabled in the
cpuset cgroup of the process. This means that you can reset your CPU
affinity by just setting every CPU bit in CPUSet and passing it to
sched_setaffinity(2).

Unfortunately, setting every CPU bit in CPUSet with (*CPUSet).Set() is
very inefficient. If it were possible to just memset(0xFF) the CPUSet
array, users would be able to reset their CPU affinity even more
cheaply. However, Go doesn't have a memset primitive that can be used in
that way.

Obvious solutions like setting the array elements of CPUSet to (^0) do
not work because CPUSet is an array of a private newtype and so the
compiler complains if you try to use a constant like (^0) without a
cast (and we cannot use a cast because the type is private):

    cannot use ^0 (untyped int constant -1) as
    "golang.org/x/sys/unix".cpuMask value in assignment (overflows)

The only real alternative is to do something quite hacky like:

    cpuset := unix.CPUSet{}
    for i := range cpuset {
        cpuset[i]-- // underflow to 0xFF..FF
    }

... which is the solution we use in runc.

It would be much nicer to have a helper that does this memset for us in
a less hacky way, since resetting CPU affinity seems like a fairly
common operation.

Ref: Linux kernel commit da019032819a ("sched: Enforce user requested affinity")
Fixes golang/go#75186

Change-Id: I211ddeafd54ce35079a67493123d28e1bb76966a
GitHub-Last-Rev: 71871db0f339f154dea6ac4d545237f08f70a301
GitHub-Pull-Request: golang/sys#259
Reviewed-on: https://go-review.googlesource.com/c/sys/+/698015
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-09-26 10:17:15 -07:00
Ayman Bagabas 6be6c584a2 windows: add FlushConsoleInputBuffer and GetNumberOfConsoleInputEvents
This adds syscall wrappers for FlushConsoleInputBuffer and GetNumberOfConsoleInputEvents on Windows.

Change-Id: I2365aebc42a57f83cfc951e10520270e1f3e0606
GitHub-Last-Rev: 1f711a5f3c2b09b6bc74160f0fc7c54a0247be14
GitHub-Pull-Request: golang/sys#264
Reviewed-on: https://go-review.googlesource.com/c/sys/+/704715
Reviewed-by: Mark Freeman <markfreeman@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-09-18 15:33:41 -07:00
Kir Kolyshkin 32e203842b unix: use Go 1.21+ clear built-in
Inspired by CL 698495.

Change-Id: Ic6ff68a60d41b6ffb6a28f523597c5d36c1e4d2f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/704915
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Mark Freeman <markfreeman@google.com>
2025-09-18 13:57:09 -07:00
Thomas Klausner 137f2eda35 sys: add support for NetBSD getvfsstat
NetBSD replaced the getfsstat interface with getvfsstat in NetBSD 3.0.

Add a test for it.

With help from Benny Siegert and Ian Lance Taylor.

Change-Id: I115ae48c287cc32181006e9e8f7c15851e7e36c0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/550476
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Benny Siegert <bsiegert@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-09-17 07:50:20 -07:00
Thomas Gibson-Robinson b06ce0514e windows: add FILE_ZERO_DATA_INFORMATION
This is needed for invoking windows.DeviceIoControl with
windows.FSCTL_SET_ZERO_DATA.

Change-Id: I20f93a40a86b92e6bdeeec096ffc0245e8184672
GitHub-Last-Rev: 01d299ab84cb90049cc62b4f1f63f6b1b25f046c
GitHub-Pull-Request: golang/sys#261
Reviewed-on: https://go-review.googlesource.com/c/sys/+/698436
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-09-05 08:44:06 -07:00
Jiwon Na 689cc11b26 unix: fix Listen on solaris
libsocket has __xnet_listen, not __xnet_llisten
which prevents listen from working.

Change-Id: Ia06dc569fcb9950893d91fc1b86257c7742e9e3d
GitHub-Last-Rev: 6f37c4b81409db28f20c2acfbd5ccae9cdb2b510
GitHub-Pull-Request: golang/sys#258
Reviewed-on: https://go-review.googlesource.com/c/sys/+/691735
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Jes Cok <xigua67damn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2025-09-05 08:17:06 -07:00
Tobias Klauser a4712b9054 plan9: drop go version tags for unsupported versions
go.mod specifies go 1.24. Drop code for older, unsupported versions.

Change-Id: I8a1ecd9e5634c1cf9619fbb89b2ecd0bda7eaf21
Reviewed-on: https://go-review.googlesource.com/c/sys/+/579515
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-09-04 07:42:06 -07:00
Juan-Luis de Sousa-Valadas Castaño 0293703b0a unix: add IFAL_* consts and ifaddrlblmsg on linux
Implments consts and structs related to ifaddrlabel

Change-Id: I6dd78e74a8e32a26286b95b0a7a20343cb16a446
GitHub-Last-Rev: 11be45c36dcbd7aa31009dfaf966eaebcbf9bbb0
GitHub-Pull-Request: golang/sys#252
Reviewed-on: https://go-review.googlesource.com/c/sys/+/683775
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2025-09-03 08:33:29 -07:00
Florian Lehner ab85cbbe91 unix/linux: extend rtnetlink constants
Change-Id: Icc356897519c0aa229a948918a253b9e4b367aff
Reviewed-on: https://go-review.googlesource.com/c/sys/+/697795
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2025-08-25 12:31:12 -07:00
Aleksa Sarai 9bd37534d8 unix: switch (*CPUSet).Zero to clear builtin
clear was added to Go 1.21 and is better than the manual loop approach.

Change-Id: I851203714446e21b6329e2bcf308f2571d339e36
GitHub-Last-Rev: 71dc7f073e50a43a11ab10d3d9ef35ebe5b183f5
GitHub-Pull-Request: golang/sys#262
Reviewed-on: https://go-review.googlesource.com/c/sys/+/698495
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Keith Randall <khr@golang.org>
2025-08-25 10:48:03 -07:00
mertakman 899c23279d windows/mkwinsyscall: use syscall.SyscallN instead of syscall.Syscall{6,9,12,15}
Replace syscall.Syscall6, Syscall9, Syscall12, and Syscall15 with
syscall.SyscallN for Go 1.18+. This simplifies system calls by allowing
the exact number of arguments needed, eliminating zero padding and
reducing potential errors.

Updated TestSyscallXGeneration to TestSyscallNGeneration to verify
correct SyscallN generation for different argument counts.

Change-Id: Iaf01c7bddd7ad6a80ee462879e382b0066f35b4d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/691715
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2025-08-22 12:22:44 -07:00
37 changed files with 1344 additions and 621 deletions
+3
View File
@@ -92,6 +92,9 @@ var ARM64 struct {
HasSHA2 bool // SHA2 hardware implementation HasSHA2 bool // SHA2 hardware implementation
HasCRC32 bool // CRC32 hardware implementation HasCRC32 bool // CRC32 hardware implementation
HasATOMICS bool // Atomic memory operation instruction set HasATOMICS bool // Atomic memory operation instruction set
HasHPDS bool // Hierarchical permission disables in translations tables
HasLOR bool // Limited ordering regions
HasPAN bool // Privileged access never
HasFPHP bool // Half precision floating-point instruction set HasFPHP bool // Half precision floating-point instruction set
HasASIMDHP bool // Advanced SIMD half precision instruction set HasASIMDHP bool // Advanced SIMD half precision instruction set
HasCPUID bool // CPUID identification scheme registers HasCPUID bool // CPUID identification scheme registers
+18 -2
View File
@@ -65,10 +65,10 @@ func setMinimalFeatures() {
func readARM64Registers() { func readARM64Registers() {
Initialized = true Initialized = true
parseARM64SystemRegisters(getisar0(), getisar1(), getpfr0()) parseARM64SystemRegisters(getisar0(), getisar1(), getmmfr1(), getpfr0())
} }
func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { func parseARM64SystemRegisters(isar0, isar1, mmfr1, pfr0 uint64) {
// ID_AA64ISAR0_EL1 // ID_AA64ISAR0_EL1
switch extractBits(isar0, 4, 7) { switch extractBits(isar0, 4, 7) {
case 1: case 1:
@@ -152,6 +152,22 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) {
ARM64.HasI8MM = true ARM64.HasI8MM = true
} }
// ID_AA64MMFR1_EL1
switch extractBits(mmfr1, 12, 15) {
case 1, 2:
ARM64.HasHPDS = true
}
switch extractBits(mmfr1, 16, 19) {
case 1:
ARM64.HasLOR = true
}
switch extractBits(mmfr1, 20, 23) {
case 1, 2, 3:
ARM64.HasPAN = true
}
// ID_AA64PFR0_EL1 // ID_AA64PFR0_EL1
switch extractBits(pfr0, 16, 19) { switch extractBits(pfr0, 16, 19) {
case 0: case 0:
+11 -8
View File
@@ -9,31 +9,34 @@
// func getisar0() uint64 // func getisar0() uint64
TEXT ·getisar0(SB),NOSPLIT,$0-8 TEXT ·getisar0(SB),NOSPLIT,$0-8
// get Instruction Set Attributes 0 into x0 // get Instruction Set Attributes 0 into x0
// mrs x0, ID_AA64ISAR0_EL1 = d5380600 MRS ID_AA64ISAR0_EL1, R0
WORD $0xd5380600
MOVD R0, ret+0(FP) MOVD R0, ret+0(FP)
RET RET
// func getisar1() uint64 // func getisar1() uint64
TEXT ·getisar1(SB),NOSPLIT,$0-8 TEXT ·getisar1(SB),NOSPLIT,$0-8
// get Instruction Set Attributes 1 into x0 // get Instruction Set Attributes 1 into x0
// mrs x0, ID_AA64ISAR1_EL1 = d5380620 MRS ID_AA64ISAR1_EL1, R0
WORD $0xd5380620 MOVD R0, ret+0(FP)
RET
// func getmmfr1() uint64
TEXT ·getmmfr1(SB),NOSPLIT,$0-8
// get Memory Model Feature Register 1 into x0
MRS ID_AA64MMFR1_EL1, R0
MOVD R0, ret+0(FP) MOVD R0, ret+0(FP)
RET RET
// func getpfr0() uint64 // func getpfr0() uint64
TEXT ·getpfr0(SB),NOSPLIT,$0-8 TEXT ·getpfr0(SB),NOSPLIT,$0-8
// get Processor Feature Register 0 into x0 // get Processor Feature Register 0 into x0
// mrs x0, ID_AA64PFR0_EL1 = d5380400 MRS ID_AA64PFR0_EL1, R0
WORD $0xd5380400
MOVD R0, ret+0(FP) MOVD R0, ret+0(FP)
RET RET
// func getzfr0() uint64 // func getzfr0() uint64
TEXT ·getzfr0(SB),NOSPLIT,$0-8 TEXT ·getzfr0(SB),NOSPLIT,$0-8
// get SVE Feature Register 0 into x0 // get SVE Feature Register 0 into x0
// mrs x0, ID_AA64ZFR0_EL1 = d5380480 MRS ID_AA64ZFR0_EL1, R0
WORD $0xd5380480
MOVD R0, ret+0(FP) MOVD R0, ret+0(FP)
RET RET
+1
View File
@@ -8,5 +8,6 @@ package cpu
func getisar0() uint64 func getisar0() uint64
func getisar1() uint64 func getisar1() uint64
func getmmfr1() uint64
func getpfr0() uint64 func getpfr0() uint64
func getzfr0() uint64 func getzfr0() uint64
+1
View File
@@ -8,4 +8,5 @@ package cpu
func getisar0() uint64 { return 0 } func getisar0() uint64 { return 0 }
func getisar1() uint64 { return 0 } func getisar1() uint64 { return 0 }
func getmmfr1() uint64 { return 0 }
func getpfr0() uint64 { return 0 } func getpfr0() uint64 { return 0 }
+1 -1
View File
@@ -167,7 +167,7 @@ func doinit() {
setMinimalFeatures() setMinimalFeatures()
return return
} }
parseARM64SystemRegisters(cpuid.aa64isar0, cpuid.aa64isar1, cpuid.aa64pfr0) parseARM64SystemRegisters(cpuid.aa64isar0, cpuid.aa64isar1, cpuid.aa64mmfr1, cpuid.aa64pfr0)
Initialized = true Initialized = true
} }
+1 -1
View File
@@ -59,7 +59,7 @@ func doinit() {
if !ok { if !ok {
return return
} }
parseARM64SystemRegisters(isar0, isar1, 0) parseARM64SystemRegisters(isar0, isar1, 0, 0)
Initialized = true Initialized = true
} }
-21
View File
@@ -1,21 +0,0 @@
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build go1.5
package plan9
import "syscall"
func fixwd() {
syscall.Fixwd()
}
func Getwd() (wd string, err error) {
return syscall.Getwd()
}
func Chdir(path string) error {
return syscall.Chdir(path)
}
+5 -9
View File
@@ -2,22 +2,18 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !go1.5
package plan9 package plan9
import "syscall"
func fixwd() { func fixwd() {
syscall.Fixwd()
} }
func Getwd() (wd string, err error) { func Getwd() (wd string, err error) {
fd, err := open(".", O_RDONLY) return syscall.Getwd()
if err != nil {
return "", err
}
defer Close(fd)
return Fd2path(fd)
} }
func Chdir(path string) error { func Chdir(path string) error {
return chdir(path) return syscall.Chdir(path)
} }
+8 -1
View File
@@ -38,8 +38,15 @@ func SchedSetaffinity(pid int, set *CPUSet) error {
// Zero clears the set s, so that it contains no CPUs. // Zero clears the set s, so that it contains no CPUs.
func (s *CPUSet) Zero() { func (s *CPUSet) Zero() {
clear(s[:])
}
// Fill adds all possible CPU bits to the set s. On Linux, [SchedSetaffinity]
// will silently ignore any invalid CPU bits in [CPUSet] so this is an
// efficient way of resetting the CPU affinity of a process.
func (s *CPUSet) Fill() {
for i := range s { for i := range s {
s[i] = 0 s[i] = ^cpuMask(0)
} }
} }
+5 -5
View File
@@ -12,7 +12,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
"sort" "slices"
"strconv" "strconv"
"strings" "strings"
"testing" "testing"
@@ -72,7 +72,7 @@ func TestDirent(t *testing.T) {
} }
} }
sort.Strings(names) slices.Sort(names)
t.Logf("names: %q", names) t.Logf("names: %q", names)
if len(names) != 10 { if len(names) != 10 {
@@ -145,9 +145,9 @@ func TestDirentRepeat(t *testing.T) {
} }
// Check results // Check results
sort.Strings(files) slices.Sort(files)
sort.Strings(files2) slices.Sort(files2)
if strings.Join(files, "|") != strings.Join(files2, "|") { if !slices.Equal(files, files2) {
t.Errorf("bad file list: want\n%q\ngot\n%q", files, files2) t.Errorf("bad file list: want\n%q\ngot\n%q", files, files2)
} }
} }
+1 -3
View File
@@ -23,7 +23,5 @@ func (fds *FdSet) IsSet(fd int) bool {
// Zero clears the set fds. // Zero clears the set fds.
func (fds *FdSet) Zero() { func (fds *FdSet) Zero() {
for i := range fds.Bits { clear(fds.Bits[:])
fds.Bits[i] = 0
}
} }
+4 -5
View File
@@ -10,8 +10,7 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"sort" "slices"
"strings"
"testing" "testing"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
@@ -71,9 +70,9 @@ func testGetdirentries(t *testing.T, count int) {
} }
} }
sort.Strings(names) slices.Sort(names)
sort.Strings(names2) slices.Sort(names2)
if strings.Join(names, ":") != strings.Join(names2, ":") { if !slices.Equal(names, names2) {
t.Errorf("names don't match\n names: %q\nnames2: %q", names, names2) t.Errorf("names don't match\n names: %q\nnames2: %q", names, names2)
} }
} }
+47
View File
@@ -0,0 +1,47 @@
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build netbsd
package unix_test
import (
"os/exec"
"testing"
"golang.org/x/sys/unix"
)
func TestGetvfsstat(t *testing.T) {
n, err := unix.Getvfsstat(nil, unix.MNT_NOWAIT)
if err != nil {
t.Fatal(err)
}
data := make([]unix.Statvfs_t, n)
n2, err := unix.Getvfsstat(data, unix.MNT_NOWAIT)
if err != nil {
t.Fatal(err)
}
if n != n2 {
t.Errorf("Getvfsstat(nil) = %d, but subsequent Getvfsstat(slice) = %d", n, n2)
}
for i, stat := range data {
if stat == (unix.Statvfs_t{}) {
t.Errorf("index %v is an empty Statvfs_t struct", i)
}
t.Logf("%s on %s", unix.ByteSliceToString(stat.Mntfromname[:]), unix.ByteSliceToString(stat.Mntonname[:]))
}
if t.Failed() {
for i, stat := range data[:n2] {
t.Logf("data[%v] = %+v", i, stat)
}
mount, err := exec.Command("mount").CombinedOutput()
if err != nil {
t.Logf("mount: %v\n%s", err, mount)
} else {
t.Logf("mount: %s", mount)
}
}
}
+1 -3
View File
@@ -111,9 +111,7 @@ func (ifr *Ifreq) SetUint32(v uint32) {
// clear zeroes the ifreq's union field to prevent trailing garbage data from // clear zeroes the ifreq's union field to prevent trailing garbage data from
// being sent to the kernel if an ifreq is reused. // being sent to the kernel if an ifreq is reused.
func (ifr *Ifreq) clear() { func (ifr *Ifreq) clear() {
for i := range ifr.raw.Ifru { clear(ifr.raw.Ifru[:])
ifr.raw.Ifru[i] = 0
}
} }
// TODO(mdlayher): export as IfreqData? For now we can provide helpers such as // TODO(mdlayher): export as IfreqData? For now we can provide helpers such as
+3 -3
View File
@@ -1,4 +1,4 @@
FROM ubuntu:24.10 FROM ubuntu:25.04
# Disable interactive prompts on package installation # Disable interactive prompts on package installation
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
@@ -21,9 +21,9 @@ RUN git clone --branch v6.16 --depth 1 https://kernel.googlesource.com/pub/scm/l
RUN git clone --branch release/2.41/master --depth 1 https://sourceware.org/git/glibc.git RUN git clone --branch release/2.41/master --depth 1 https://sourceware.org/git/glibc.git
# Get Go # Get Go
ENV GOLANG_VERSION=1.24.5 ENV GOLANG_VERSION=1.25.1
ENV GOLANG_DOWNLOAD_URL=https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz ENV GOLANG_DOWNLOAD_URL=https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
ENV GOLANG_DOWNLOAD_SHA256=10ad9e86233e74c0f6590fe5426895de6bf388964210eac34a6d83f38918ecdc ENV GOLANG_DOWNLOAD_SHA256=7716a0d940a0f6ae8e1f3b3f4f36299dc53e31b16840dbd171254312c41ca12e
RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
&& echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \
+72 -1
View File
@@ -121,6 +121,7 @@ struct termios2 {
#include <linux/hidraw.h> #include <linux/hidraw.h>
#include <linux/icmp.h> #include <linux/icmp.h>
#include <linux/icmpv6.h> #include <linux/icmpv6.h>
#include <linux/if_addrlabel.h>
#include <linux/if_alg.h> #include <linux/if_alg.h>
#include <linux/if_bridge.h> #include <linux/if_bridge.h>
#include <linux/if_packet.h> #include <linux/if_packet.h>
@@ -134,6 +135,7 @@ struct termios2 {
#include <linux/landlock.h> #include <linux/landlock.h>
#include <linux/loop.h> #include <linux/loop.h>
#include <linux/lwtunnel.h> #include <linux/lwtunnel.h>
#include <linux/mempolicy.h>
#include <linux/mpls_iptunnel.h> #include <linux/mpls_iptunnel.h>
#include <linux/ncsi.h> #include <linux/ncsi.h>
#include <linux/net_namespace.h> #include <linux/net_namespace.h>
@@ -878,6 +880,8 @@ const (
IFA_FLAGS = C.IFA_FLAGS IFA_FLAGS = C.IFA_FLAGS
IFA_RT_PRIORITY = C.IFA_RT_PRIORITY IFA_RT_PRIORITY = C.IFA_RT_PRIORITY
IFA_TARGET_NETNSID = C.IFA_TARGET_NETNSID IFA_TARGET_NETNSID = C.IFA_TARGET_NETNSID
IFAL_LABEL = C.IFAL_LABEL
IFAL_ADDRESS = C.IFAL_ADDRESS
RT_SCOPE_UNIVERSE = C.RT_SCOPE_UNIVERSE RT_SCOPE_UNIVERSE = C.RT_SCOPE_UNIVERSE
RT_SCOPE_SITE = C.RT_SCOPE_SITE RT_SCOPE_SITE = C.RT_SCOPE_SITE
RT_SCOPE_LINK = C.RT_SCOPE_LINK RT_SCOPE_LINK = C.RT_SCOPE_LINK
@@ -935,6 +939,7 @@ const (
SizeofRtAttr = C.sizeof_struct_rtattr SizeofRtAttr = C.sizeof_struct_rtattr
SizeofIfInfomsg = C.sizeof_struct_ifinfomsg SizeofIfInfomsg = C.sizeof_struct_ifinfomsg
SizeofIfAddrmsg = C.sizeof_struct_ifaddrmsg SizeofIfAddrmsg = C.sizeof_struct_ifaddrmsg
SizeofIfAddrlblmsg = C.sizeof_struct_ifaddrlblmsg
SizeofIfaCacheinfo = C.sizeof_struct_ifa_cacheinfo SizeofIfaCacheinfo = C.sizeof_struct_ifa_cacheinfo
SizeofRtMsg = C.sizeof_struct_rtmsg SizeofRtMsg = C.sizeof_struct_rtmsg
SizeofRtNexthop = C.sizeof_struct_rtnexthop SizeofRtNexthop = C.sizeof_struct_rtnexthop
@@ -956,6 +961,8 @@ type IfInfomsg C.struct_ifinfomsg
type IfAddrmsg C.struct_ifaddrmsg type IfAddrmsg C.struct_ifaddrmsg
type IfAddrlblmsg C.struct_ifaddrlblmsg
type IfaCacheinfo C.struct_ifa_cacheinfo type IfaCacheinfo C.struct_ifa_cacheinfo
type RtMsg C.struct_rtmsg type RtMsg C.struct_rtmsg
@@ -3113,8 +3120,25 @@ const (
) )
// generated by: // generated by:
// perl -nlE '/^\s*(RTNLGRP_\w+)/ && say "$1 = C.$1"' include/uapi/linux/rtnetlink.h // perl -nlE '/^\s*((RTNLGRP_|TCA_)\w+)/ && say "$1 = C.$1"' include/uapi/linux/rtnetlink.h
const ( const (
TCA_UNSPEC = C.TCA_UNSPEC
TCA_KIND = C.TCA_KIND
TCA_OPTIONS = C.TCA_OPTIONS
TCA_STATS = C.TCA_STATS
TCA_XSTATS = C.TCA_XSTATS
TCA_RATE = C.TCA_RATE
TCA_FCNT = C.TCA_FCNT
TCA_STATS2 = C.TCA_STATS2
TCA_STAB = C.TCA_STAB
TCA_PAD = C.TCA_PAD
TCA_DUMP_INVISIBLE = C.TCA_DUMP_INVISIBLE
TCA_CHAIN = C.TCA_CHAIN
TCA_HW_OFFLOAD = C.TCA_HW_OFFLOAD
TCA_INGRESS_BLOCK = C.TCA_INGRESS_BLOCK
TCA_EGRESS_BLOCK = C.TCA_EGRESS_BLOCK
TCA_DUMP_FLAGS = C.TCA_DUMP_FLAGS
TCA_EXT_WARN_MSG = C.TCA_EXT_WARN_MSG
RTNLGRP_NONE = C.RTNLGRP_NONE RTNLGRP_NONE = C.RTNLGRP_NONE
RTNLGRP_LINK = C.RTNLGRP_LINK RTNLGRP_LINK = C.RTNLGRP_LINK
RTNLGRP_NOTIFY = C.RTNLGRP_NOTIFY RTNLGRP_NOTIFY = C.RTNLGRP_NOTIFY
@@ -3149,6 +3173,18 @@ const (
RTNLGRP_IPV6_MROUTE_R = C.RTNLGRP_IPV6_MROUTE_R RTNLGRP_IPV6_MROUTE_R = C.RTNLGRP_IPV6_MROUTE_R
RTNLGRP_NEXTHOP = C.RTNLGRP_NEXTHOP RTNLGRP_NEXTHOP = C.RTNLGRP_NEXTHOP
RTNLGRP_BRVLAN = C.RTNLGRP_BRVLAN RTNLGRP_BRVLAN = C.RTNLGRP_BRVLAN
RTNLGRP_MCTP_IFADDR = C.RTNLGRP_MCTP_IFADDR
RTNLGRP_TUNNEL = C.RTNLGRP_TUNNEL
RTNLGRP_STATS = C.RTNLGRP_STATS
RTNLGRP_IPV4_MCADDR = C.RTNLGRP_IPV4_MCADDR
RTNLGRP_IPV6_MCADDR = C.RTNLGRP_IPV6_MCADDR
RTNLGRP_IPV6_ACADDR = C.RTNLGRP_IPV6_ACADDR
TCA_ROOT_UNSPEC = C.TCA_ROOT_UNSPEC
TCA_ROOT_TAB = C.TCA_ROOT_TAB
TCA_ROOT_FLAGS = C.TCA_ROOT_FLAGS
TCA_ROOT_COUNT = C.TCA_ROOT_COUNT
TCA_ROOT_TIME_DELTA = C.TCA_ROOT_TIME_DELTA
TCA_ROOT_EXT_WARN_MSG = C.TCA_ROOT_EXT_WARN_MSG
) )
// Capabilities // Capabilities
@@ -3564,8 +3600,12 @@ type FsverityEnableArg C.struct_fsverity_enable_arg
type Nhmsg C.struct_nhmsg type Nhmsg C.struct_nhmsg
const SizeofNhmsg = C.sizeof_struct_nhmsg
type NexthopGrp C.struct_nexthop_grp type NexthopGrp C.struct_nexthop_grp
const SizeofNexthopGrp = C.sizeof_struct_nexthop_grp
const ( const (
NHA_UNSPEC = C.NHA_UNSPEC NHA_UNSPEC = C.NHA_UNSPEC
NHA_ID = C.NHA_ID NHA_ID = C.NHA_ID
@@ -6215,3 +6255,34 @@ type SockDiagReq C.struct_sock_diag_req
// Removed in Linux 6.13, kept for backwards compatibility. // Removed in Linux 6.13, kept for backwards compatibility.
const RTM_NEWNVLAN = 0x70 const RTM_NEWNVLAN = 0x70
// Memory policy modes and flags for [SetMemPolicy], as defined in /usr/include/linux/mempolicy.h.
// Not all can be used, see set_mempolicy(2).
// Generated by:
// $ { perl -nlE '/^#define (MPOL_\w+)/ && say "\t$1 = C.$1"' /usr/include/linux/mempolicy.h; perl -nlE '/^\s*(MPOL_\w+)/ && say "\t$1 = C.$1"' /usr/include/linux/mempolicy.h; } | sort | uniq
const (
MPOL_BIND = C.MPOL_BIND
MPOL_DEFAULT = C.MPOL_DEFAULT
MPOL_F_ADDR = C.MPOL_F_ADDR
MPOL_F_MEMS_ALLOWED = C.MPOL_F_MEMS_ALLOWED
MPOL_F_MOF = C.MPOL_F_MOF
MPOL_F_MORON = C.MPOL_F_MORON
MPOL_F_NODE = C.MPOL_F_NODE
MPOL_F_NUMA_BALANCING = C.MPOL_F_NUMA_BALANCING
MPOL_F_RELATIVE_NODES = C.MPOL_F_RELATIVE_NODES
MPOL_F_SHARED = C.MPOL_F_SHARED
MPOL_F_STATIC_NODES = C.MPOL_F_STATIC_NODES
MPOL_INTERLEAVE = C.MPOL_INTERLEAVE
MPOL_LOCAL = C.MPOL_LOCAL
MPOL_MAX = C.MPOL_MAX
MPOL_MF_INTERNAL = C.MPOL_MF_INTERNAL
MPOL_MF_LAZY = C.MPOL_MF_LAZY
MPOL_MF_MOVE_ALL = C.MPOL_MF_MOVE_ALL
MPOL_MF_MOVE = C.MPOL_MF_MOVE
MPOL_MF_STRICT = C.MPOL_MF_STRICT
MPOL_MF_VALID = C.MPOL_MF_VALID
MPOL_MODE_FLAGS = C.MPOL_MODE_FLAGS
MPOL_PREFERRED = C.MPOL_PREFERRED
MPOL_PREFERRED_MANY = C.MPOL_PREFERRED_MANY
MPOL_WEIGHTED_INTERLEAVE = C.MPOL_WEIGHTED_INTERLEAVE
)
+1
View File
@@ -49,6 +49,7 @@ esac
if [[ "$GOOS" = "linux" ]]; then if [[ "$GOOS" = "linux" ]]; then
# Use the Docker-based build system # Use the Docker-based build system
# Files generated through docker (use $cmd so you can Ctl-C the build or run) # Files generated through docker (use $cmd so you can Ctl-C the build or run)
set -e
$cmd docker build --tag generate:$GOOS $GOOS $cmd docker build --tag generate:$GOOS $GOOS
$cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && pwd):/build generate:$GOOS $cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && pwd):/build generate:$GOOS
exit exit
+2
View File
@@ -226,6 +226,7 @@ struct ltchars {
#include <linux/cryptouser.h> #include <linux/cryptouser.h>
#include <linux/devlink.h> #include <linux/devlink.h>
#include <linux/dm-ioctl.h> #include <linux/dm-ioctl.h>
#include <linux/elf.h>
#include <linux/errqueue.h> #include <linux/errqueue.h>
#include <linux/ethtool_netlink.h> #include <linux/ethtool_netlink.h>
#include <linux/falloc.h> #include <linux/falloc.h>
@@ -529,6 +530,7 @@ ccflags="$@"
$2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ || $2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ ||
$2 ~ /^(NL|CR|TAB|BS|VT|FF)DLY$/ || $2 ~ /^(NL|CR|TAB|BS|VT|FF)DLY$/ ||
$2 ~ /^(NL|CR|TAB|BS|VT|FF)[0-9]$/ || $2 ~ /^(NL|CR|TAB|BS|VT|FF)[0-9]$/ ||
$2 ~ /^(DT|EI|ELF|EV|NN|NT|PF|SHF|SHN|SHT|STB|STT|VER)_/ ||
$2 ~ /^O?XTABS$/ || $2 ~ /^O?XTABS$/ ||
$2 ~ /^TC[IO](ON|OFF)$/ || $2 ~ /^TC[IO](ON|OFF)$/ ||
$2 ~ /^IN_/ || $2 ~ /^IN_/ ||
+7 -3
View File
@@ -801,9 +801,7 @@ func (sa *SockaddrPPPoE) sockaddr() (unsafe.Pointer, _Socklen, error) {
// one. The kernel expects SID to be in network byte order. // one. The kernel expects SID to be in network byte order.
binary.BigEndian.PutUint16(sa.raw[6:8], sa.SID) binary.BigEndian.PutUint16(sa.raw[6:8], sa.SID)
copy(sa.raw[8:14], sa.Remote) copy(sa.raw[8:14], sa.Remote)
for i := 14; i < 14+IFNAMSIZ; i++ { clear(sa.raw[14 : 14+IFNAMSIZ])
sa.raw[i] = 0
}
copy(sa.raw[14:], sa.Dev) copy(sa.raw[14:], sa.Dev)
return unsafe.Pointer(&sa.raw), SizeofSockaddrPPPoX, nil return unsafe.Pointer(&sa.raw), SizeofSockaddrPPPoX, nil
} }
@@ -2645,3 +2643,9 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) {
//sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error) //sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error)
//sys Mseal(b []byte, flags uint) (err error) //sys Mseal(b []byte, flags uint) (err error)
//sys setMemPolicy(mode int, mask *CPUSet, size int) (err error) = SYS_SET_MEMPOLICY
func SetMemPolicy(mode int, mask *CPUSet) error {
return setMemPolicy(mode, mask, _CPU_SETSIZE)
}
+17
View File
@@ -248,6 +248,23 @@ func Statvfs(path string, buf *Statvfs_t) (err error) {
return Statvfs1(path, buf, ST_WAIT) return Statvfs1(path, buf, ST_WAIT)
} }
func Getvfsstat(buf []Statvfs_t, flags int) (n int, err error) {
var (
_p0 unsafe.Pointer
bufsize uintptr
)
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
bufsize = unsafe.Sizeof(Statvfs_t{}) * uintptr(len(buf))
}
r0, _, e1 := Syscall(SYS_GETVFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
n = int(r0)
if e1 != 0 {
err = e1
}
return
}
/* /*
* Exposed directly * Exposed directly
*/ */
+1 -1
View File
@@ -629,7 +629,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
//sys Kill(pid int, signum syscall.Signal) (err error) //sys Kill(pid int, signum syscall.Signal) (err error)
//sys Lchown(path string, uid int, gid int) (err error) //sys Lchown(path string, uid int, gid int) (err error)
//sys Link(path string, link string) (err error) //sys Link(path string, link string) (err error)
//sys Listen(s int, backlog int) (err error) = libsocket.__xnet_llisten //sys Listen(s int, backlog int) (err error) = libsocket.__xnet_listen
//sys Lstat(path string, stat *Stat_t) (err error) //sys Lstat(path string, stat *Stat_t) (err error)
//sys Madvise(b []byte, advice int) (err error) //sys Madvise(b []byte, advice int) (err error)
//sys Mkdir(path string, mode uint32) (err error) //sys Mkdir(path string, mode uint32) (err error)
+359
View File
@@ -853,20 +853,86 @@ const (
DM_VERSION_MAJOR = 0x4 DM_VERSION_MAJOR = 0x4
DM_VERSION_MINOR = 0x32 DM_VERSION_MINOR = 0x32
DM_VERSION_PATCHLEVEL = 0x0 DM_VERSION_PATCHLEVEL = 0x0
DT_ADDRRNGHI = 0x6ffffeff
DT_ADDRRNGLO = 0x6ffffe00
DT_BLK = 0x6 DT_BLK = 0x6
DT_CHR = 0x2 DT_CHR = 0x2
DT_DEBUG = 0x15
DT_DIR = 0x4 DT_DIR = 0x4
DT_ENCODING = 0x20
DT_FIFO = 0x1 DT_FIFO = 0x1
DT_FINI = 0xd
DT_FLAGS_1 = 0x6ffffffb
DT_GNU_HASH = 0x6ffffef5
DT_HASH = 0x4
DT_HIOS = 0x6ffff000
DT_HIPROC = 0x7fffffff
DT_INIT = 0xc
DT_JMPREL = 0x17
DT_LNK = 0xa DT_LNK = 0xa
DT_LOOS = 0x6000000d
DT_LOPROC = 0x70000000
DT_NEEDED = 0x1
DT_NULL = 0x0
DT_PLTGOT = 0x3
DT_PLTREL = 0x14
DT_PLTRELSZ = 0x2
DT_REG = 0x8 DT_REG = 0x8
DT_REL = 0x11
DT_RELA = 0x7
DT_RELACOUNT = 0x6ffffff9
DT_RELAENT = 0x9
DT_RELASZ = 0x8
DT_RELCOUNT = 0x6ffffffa
DT_RELENT = 0x13
DT_RELSZ = 0x12
DT_RPATH = 0xf
DT_SOCK = 0xc DT_SOCK = 0xc
DT_SONAME = 0xe
DT_STRSZ = 0xa
DT_STRTAB = 0x5
DT_SYMBOLIC = 0x10
DT_SYMENT = 0xb
DT_SYMTAB = 0x6
DT_TEXTREL = 0x16
DT_UNKNOWN = 0x0 DT_UNKNOWN = 0x0
DT_VALRNGHI = 0x6ffffdff
DT_VALRNGLO = 0x6ffffd00
DT_VERDEF = 0x6ffffffc
DT_VERDEFNUM = 0x6ffffffd
DT_VERNEED = 0x6ffffffe
DT_VERNEEDNUM = 0x6fffffff
DT_VERSYM = 0x6ffffff0
DT_WHT = 0xe DT_WHT = 0xe
ECHO = 0x8 ECHO = 0x8
ECRYPTFS_SUPER_MAGIC = 0xf15f ECRYPTFS_SUPER_MAGIC = 0xf15f
EFD_SEMAPHORE = 0x1 EFD_SEMAPHORE = 0x1
EFIVARFS_MAGIC = 0xde5e81e4 EFIVARFS_MAGIC = 0xde5e81e4
EFS_SUPER_MAGIC = 0x414a53 EFS_SUPER_MAGIC = 0x414a53
EI_CLASS = 0x4
EI_DATA = 0x5
EI_MAG0 = 0x0
EI_MAG1 = 0x1
EI_MAG2 = 0x2
EI_MAG3 = 0x3
EI_NIDENT = 0x10
EI_OSABI = 0x7
EI_PAD = 0x8
EI_VERSION = 0x6
ELFCLASS32 = 0x1
ELFCLASS64 = 0x2
ELFCLASSNONE = 0x0
ELFCLASSNUM = 0x3
ELFDATA2LSB = 0x1
ELFDATA2MSB = 0x2
ELFDATANONE = 0x0
ELFMAG = "\177ELF"
ELFMAG0 = 0x7f
ELFMAG1 = 'E'
ELFMAG2 = 'L'
ELFMAG3 = 'F'
ELFOSABI_LINUX = 0x3
ELFOSABI_NONE = 0x0
EM_386 = 0x3 EM_386 = 0x3
EM_486 = 0x6 EM_486 = 0x6
EM_68K = 0x4 EM_68K = 0x4
@@ -1152,14 +1218,24 @@ const (
ETH_P_WCCP = 0x883e ETH_P_WCCP = 0x883e
ETH_P_X25 = 0x805 ETH_P_X25 = 0x805
ETH_P_XDSA = 0xf8 ETH_P_XDSA = 0xf8
ET_CORE = 0x4
ET_DYN = 0x3
ET_EXEC = 0x2
ET_HIPROC = 0xffff
ET_LOPROC = 0xff00
ET_NONE = 0x0
ET_REL = 0x1
EV_ABS = 0x3 EV_ABS = 0x3
EV_CNT = 0x20 EV_CNT = 0x20
EV_CURRENT = 0x1
EV_FF = 0x15 EV_FF = 0x15
EV_FF_STATUS = 0x17 EV_FF_STATUS = 0x17
EV_KEY = 0x1 EV_KEY = 0x1
EV_LED = 0x11 EV_LED = 0x11
EV_MAX = 0x1f EV_MAX = 0x1f
EV_MSC = 0x4 EV_MSC = 0x4
EV_NONE = 0x0
EV_NUM = 0x2
EV_PWR = 0x16 EV_PWR = 0x16
EV_REL = 0x2 EV_REL = 0x2
EV_REP = 0x14 EV_REP = 0x14
@@ -2276,7 +2352,167 @@ const (
NLM_F_REPLACE = 0x100 NLM_F_REPLACE = 0x100
NLM_F_REQUEST = 0x1 NLM_F_REQUEST = 0x1
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NN_386_IOPERM = "LINUX"
NN_386_TLS = "LINUX"
NN_ARC_V2 = "LINUX"
NN_ARM_FPMR = "LINUX"
NN_ARM_GCS = "LINUX"
NN_ARM_HW_BREAK = "LINUX"
NN_ARM_HW_WATCH = "LINUX"
NN_ARM_PACA_KEYS = "LINUX"
NN_ARM_PACG_KEYS = "LINUX"
NN_ARM_PAC_ENABLED_KEYS = "LINUX"
NN_ARM_PAC_MASK = "LINUX"
NN_ARM_POE = "LINUX"
NN_ARM_SSVE = "LINUX"
NN_ARM_SVE = "LINUX"
NN_ARM_SYSTEM_CALL = "LINUX"
NN_ARM_TAGGED_ADDR_CTRL = "LINUX"
NN_ARM_TLS = "LINUX"
NN_ARM_VFP = "LINUX"
NN_ARM_ZA = "LINUX"
NN_ARM_ZT = "LINUX"
NN_AUXV = "CORE"
NN_FILE = "CORE"
NN_GNU_PROPERTY_TYPE_0 = "GNU"
NN_LOONGARCH_CPUCFG = "LINUX"
NN_LOONGARCH_CSR = "LINUX"
NN_LOONGARCH_HW_BREAK = "LINUX"
NN_LOONGARCH_HW_WATCH = "LINUX"
NN_LOONGARCH_LASX = "LINUX"
NN_LOONGARCH_LBT = "LINUX"
NN_LOONGARCH_LSX = "LINUX"
NN_MIPS_DSP = "LINUX"
NN_MIPS_FP_MODE = "LINUX"
NN_MIPS_MSA = "LINUX"
NN_PPC_DEXCR = "LINUX"
NN_PPC_DSCR = "LINUX"
NN_PPC_EBB = "LINUX"
NN_PPC_HASHKEYR = "LINUX"
NN_PPC_PKEY = "LINUX"
NN_PPC_PMU = "LINUX"
NN_PPC_PPR = "LINUX"
NN_PPC_SPE = "LINUX"
NN_PPC_TAR = "LINUX"
NN_PPC_TM_CDSCR = "LINUX"
NN_PPC_TM_CFPR = "LINUX"
NN_PPC_TM_CGPR = "LINUX"
NN_PPC_TM_CPPR = "LINUX"
NN_PPC_TM_CTAR = "LINUX"
NN_PPC_TM_CVMX = "LINUX"
NN_PPC_TM_CVSX = "LINUX"
NN_PPC_TM_SPR = "LINUX"
NN_PPC_VMX = "LINUX"
NN_PPC_VSX = "LINUX"
NN_PRFPREG = "CORE"
NN_PRPSINFO = "CORE"
NN_PRSTATUS = "CORE"
NN_PRXFPREG = "LINUX"
NN_RISCV_CSR = "LINUX"
NN_RISCV_TAGGED_ADDR_CTRL = "LINUX"
NN_RISCV_VECTOR = "LINUX"
NN_S390_CTRS = "LINUX"
NN_S390_GS_BC = "LINUX"
NN_S390_GS_CB = "LINUX"
NN_S390_HIGH_GPRS = "LINUX"
NN_S390_LAST_BREAK = "LINUX"
NN_S390_PREFIX = "LINUX"
NN_S390_PV_CPU_DATA = "LINUX"
NN_S390_RI_CB = "LINUX"
NN_S390_SYSTEM_CALL = "LINUX"
NN_S390_TDB = "LINUX"
NN_S390_TIMER = "LINUX"
NN_S390_TODCMP = "LINUX"
NN_S390_TODPREG = "LINUX"
NN_S390_VXRS_HIGH = "LINUX"
NN_S390_VXRS_LOW = "LINUX"
NN_SIGINFO = "CORE"
NN_TASKSTRUCT = "CORE"
NN_VMCOREDD = "LINUX"
NN_X86_SHSTK = "LINUX"
NN_X86_XSAVE_LAYOUT = "LINUX"
NN_X86_XSTATE = "LINUX"
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NT_386_IOPERM = 0x201
NT_386_TLS = 0x200
NT_ARC_V2 = 0x600
NT_ARM_FPMR = 0x40e
NT_ARM_GCS = 0x410
NT_ARM_HW_BREAK = 0x402
NT_ARM_HW_WATCH = 0x403
NT_ARM_PACA_KEYS = 0x407
NT_ARM_PACG_KEYS = 0x408
NT_ARM_PAC_ENABLED_KEYS = 0x40a
NT_ARM_PAC_MASK = 0x406
NT_ARM_POE = 0x40f
NT_ARM_SSVE = 0x40b
NT_ARM_SVE = 0x405
NT_ARM_SYSTEM_CALL = 0x404
NT_ARM_TAGGED_ADDR_CTRL = 0x409
NT_ARM_TLS = 0x401
NT_ARM_VFP = 0x400
NT_ARM_ZA = 0x40c
NT_ARM_ZT = 0x40d
NT_AUXV = 0x6
NT_FILE = 0x46494c45
NT_GNU_PROPERTY_TYPE_0 = 0x5
NT_LOONGARCH_CPUCFG = 0xa00
NT_LOONGARCH_CSR = 0xa01
NT_LOONGARCH_HW_BREAK = 0xa05
NT_LOONGARCH_HW_WATCH = 0xa06
NT_LOONGARCH_LASX = 0xa03
NT_LOONGARCH_LBT = 0xa04
NT_LOONGARCH_LSX = 0xa02
NT_MIPS_DSP = 0x800
NT_MIPS_FP_MODE = 0x801
NT_MIPS_MSA = 0x802
NT_PPC_DEXCR = 0x111
NT_PPC_DSCR = 0x105
NT_PPC_EBB = 0x106
NT_PPC_HASHKEYR = 0x112
NT_PPC_PKEY = 0x110
NT_PPC_PMU = 0x107
NT_PPC_PPR = 0x104
NT_PPC_SPE = 0x101
NT_PPC_TAR = 0x103
NT_PPC_TM_CDSCR = 0x10f
NT_PPC_TM_CFPR = 0x109
NT_PPC_TM_CGPR = 0x108
NT_PPC_TM_CPPR = 0x10e
NT_PPC_TM_CTAR = 0x10d
NT_PPC_TM_CVMX = 0x10a
NT_PPC_TM_CVSX = 0x10b
NT_PPC_TM_SPR = 0x10c
NT_PPC_VMX = 0x100
NT_PPC_VSX = 0x102
NT_PRFPREG = 0x2
NT_PRPSINFO = 0x3
NT_PRSTATUS = 0x1
NT_PRXFPREG = 0x46e62b7f
NT_RISCV_CSR = 0x900
NT_RISCV_TAGGED_ADDR_CTRL = 0x902
NT_RISCV_VECTOR = 0x901
NT_S390_CTRS = 0x304
NT_S390_GS_BC = 0x30c
NT_S390_GS_CB = 0x30b
NT_S390_HIGH_GPRS = 0x300
NT_S390_LAST_BREAK = 0x306
NT_S390_PREFIX = 0x305
NT_S390_PV_CPU_DATA = 0x30e
NT_S390_RI_CB = 0x30d
NT_S390_SYSTEM_CALL = 0x307
NT_S390_TDB = 0x308
NT_S390_TIMER = 0x301
NT_S390_TODCMP = 0x302
NT_S390_TODPREG = 0x303
NT_S390_VXRS_HIGH = 0x30a
NT_S390_VXRS_LOW = 0x309
NT_SIGINFO = 0x53494749
NT_TASKSTRUCT = 0x4
NT_VMCOREDD = 0x700
NT_X86_SHSTK = 0x204
NT_X86_XSAVE_LAYOUT = 0x205
NT_X86_XSTATE = 0x202
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
@@ -2463,6 +2699,59 @@ const (
PERF_RECORD_MISC_USER = 0x2 PERF_RECORD_MISC_USER = 0x2
PERF_SAMPLE_BRANCH_PLM_ALL = 0x7 PERF_SAMPLE_BRANCH_PLM_ALL = 0x7
PERF_SAMPLE_WEIGHT_TYPE = 0x1004000 PERF_SAMPLE_WEIGHT_TYPE = 0x1004000
PF_ALG = 0x26
PF_APPLETALK = 0x5
PF_ASH = 0x12
PF_ATMPVC = 0x8
PF_ATMSVC = 0x14
PF_AX25 = 0x3
PF_BLUETOOTH = 0x1f
PF_BRIDGE = 0x7
PF_CAIF = 0x25
PF_CAN = 0x1d
PF_DECnet = 0xc
PF_ECONET = 0x13
PF_FILE = 0x1
PF_IB = 0x1b
PF_IEEE802154 = 0x24
PF_INET = 0x2
PF_INET6 = 0xa
PF_IPX = 0x4
PF_IRDA = 0x17
PF_ISDN = 0x22
PF_IUCV = 0x20
PF_KCM = 0x29
PF_KEY = 0xf
PF_LLC = 0x1a
PF_LOCAL = 0x1
PF_MAX = 0x2e
PF_MCTP = 0x2d
PF_MPLS = 0x1c
PF_NETBEUI = 0xd
PF_NETLINK = 0x10
PF_NETROM = 0x6
PF_NFC = 0x27
PF_PACKET = 0x11
PF_PHONET = 0x23
PF_PPPOX = 0x18
PF_QIPCRTR = 0x2a
PF_R = 0x4
PF_RDS = 0x15
PF_ROSE = 0xb
PF_ROUTE = 0x10
PF_RXRPC = 0x21
PF_SECURITY = 0xe
PF_SMC = 0x2b
PF_SNA = 0x16
PF_TIPC = 0x1e
PF_UNIX = 0x1
PF_UNSPEC = 0x0
PF_VSOCK = 0x28
PF_W = 0x2
PF_WANPIPE = 0x19
PF_X = 0x1
PF_X25 = 0x9
PF_XDP = 0x2c
PID_FS_MAGIC = 0x50494446 PID_FS_MAGIC = 0x50494446
PIPEFS_MAGIC = 0x50495045 PIPEFS_MAGIC = 0x50495045
PPPIOCGNPMODE = 0xc008744c PPPIOCGNPMODE = 0xc008744c
@@ -2758,6 +3047,23 @@ const (
PTRACE_SYSCALL_INFO_NONE = 0x0 PTRACE_SYSCALL_INFO_NONE = 0x0
PTRACE_SYSCALL_INFO_SECCOMP = 0x3 PTRACE_SYSCALL_INFO_SECCOMP = 0x3
PTRACE_TRACEME = 0x0 PTRACE_TRACEME = 0x0
PT_AARCH64_MEMTAG_MTE = 0x70000002
PT_DYNAMIC = 0x2
PT_GNU_EH_FRAME = 0x6474e550
PT_GNU_PROPERTY = 0x6474e553
PT_GNU_RELRO = 0x6474e552
PT_GNU_STACK = 0x6474e551
PT_HIOS = 0x6fffffff
PT_HIPROC = 0x7fffffff
PT_INTERP = 0x3
PT_LOAD = 0x1
PT_LOOS = 0x60000000
PT_LOPROC = 0x70000000
PT_NOTE = 0x4
PT_NULL = 0x0
PT_PHDR = 0x6
PT_SHLIB = 0x5
PT_TLS = 0x7
P_ALL = 0x0 P_ALL = 0x0
P_PGID = 0x2 P_PGID = 0x2
P_PID = 0x1 P_PID = 0x1
@@ -3091,6 +3397,47 @@ const (
SEEK_MAX = 0x4 SEEK_MAX = 0x4
SEEK_SET = 0x0 SEEK_SET = 0x0
SELINUX_MAGIC = 0xf97cff8c SELINUX_MAGIC = 0xf97cff8c
SHF_ALLOC = 0x2
SHF_EXCLUDE = 0x8000000
SHF_EXECINSTR = 0x4
SHF_GROUP = 0x200
SHF_INFO_LINK = 0x40
SHF_LINK_ORDER = 0x80
SHF_MASKOS = 0xff00000
SHF_MASKPROC = 0xf0000000
SHF_MERGE = 0x10
SHF_ORDERED = 0x4000000
SHF_OS_NONCONFORMING = 0x100
SHF_RELA_LIVEPATCH = 0x100000
SHF_RO_AFTER_INIT = 0x200000
SHF_STRINGS = 0x20
SHF_TLS = 0x400
SHF_WRITE = 0x1
SHN_ABS = 0xfff1
SHN_COMMON = 0xfff2
SHN_HIPROC = 0xff1f
SHN_HIRESERVE = 0xffff
SHN_LIVEPATCH = 0xff20
SHN_LOPROC = 0xff00
SHN_LORESERVE = 0xff00
SHN_UNDEF = 0x0
SHT_DYNAMIC = 0x6
SHT_DYNSYM = 0xb
SHT_HASH = 0x5
SHT_HIPROC = 0x7fffffff
SHT_HIUSER = 0xffffffff
SHT_LOPROC = 0x70000000
SHT_LOUSER = 0x80000000
SHT_NOBITS = 0x8
SHT_NOTE = 0x7
SHT_NULL = 0x0
SHT_NUM = 0xc
SHT_PROGBITS = 0x1
SHT_REL = 0x9
SHT_RELA = 0x4
SHT_SHLIB = 0xa
SHT_STRTAB = 0x3
SHT_SYMTAB = 0x2
SHUT_RD = 0x0 SHUT_RD = 0x0
SHUT_RDWR = 0x2 SHUT_RDWR = 0x2
SHUT_WR = 0x1 SHUT_WR = 0x1
@@ -3317,6 +3664,16 @@ const (
STATX_UID = 0x8 STATX_UID = 0x8
STATX_WRITE_ATOMIC = 0x10000 STATX_WRITE_ATOMIC = 0x10000
STATX__RESERVED = 0x80000000 STATX__RESERVED = 0x80000000
STB_GLOBAL = 0x1
STB_LOCAL = 0x0
STB_WEAK = 0x2
STT_COMMON = 0x5
STT_FILE = 0x4
STT_FUNC = 0x2
STT_NOTYPE = 0x0
STT_OBJECT = 0x1
STT_SECTION = 0x3
STT_TLS = 0x6
SYNC_FILE_RANGE_WAIT_AFTER = 0x4 SYNC_FILE_RANGE_WAIT_AFTER = 0x4
SYNC_FILE_RANGE_WAIT_BEFORE = 0x1 SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
SYNC_FILE_RANGE_WRITE = 0x2 SYNC_FILE_RANGE_WRITE = 0x2
@@ -3553,6 +3910,8 @@ const (
UTIME_OMIT = 0x3ffffffe UTIME_OMIT = 0x3ffffffe
V9FS_MAGIC = 0x1021997 V9FS_MAGIC = 0x1021997
VERASE = 0x2 VERASE = 0x2
VER_FLG_BASE = 0x1
VER_FLG_WEAK = 0x2
VINTR = 0x0 VINTR = 0x0
VKILL = 0x3 VKILL = 0x3
VLNEXT = 0xf VLNEXT = 0xf
+10
View File
@@ -2238,3 +2238,13 @@ func Mseal(b []byte, flags uint) (err error) {
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setMemPolicy(mode int, mask *CPUSet, size int) (err error) {
_, _, e1 := Syscall(SYS_SET_MEMPOLICY, uintptr(mode), uintptr(unsafe.Pointer(mask)), uintptr(size))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+4 -4
View File
@@ -72,7 +72,7 @@ import (
//go:cgo_import_dynamic libc_kill kill "libc.so" //go:cgo_import_dynamic libc_kill kill "libc.so"
//go:cgo_import_dynamic libc_lchown lchown "libc.so" //go:cgo_import_dynamic libc_lchown lchown "libc.so"
//go:cgo_import_dynamic libc_link link "libc.so" //go:cgo_import_dynamic libc_link link "libc.so"
//go:cgo_import_dynamic libc___xnet_llisten __xnet_llisten "libsocket.so" //go:cgo_import_dynamic libc___xnet_listen __xnet_listen "libsocket.so"
//go:cgo_import_dynamic libc_lstat lstat "libc.so" //go:cgo_import_dynamic libc_lstat lstat "libc.so"
//go:cgo_import_dynamic libc_madvise madvise "libc.so" //go:cgo_import_dynamic libc_madvise madvise "libc.so"
//go:cgo_import_dynamic libc_mkdir mkdir "libc.so" //go:cgo_import_dynamic libc_mkdir mkdir "libc.so"
@@ -221,7 +221,7 @@ import (
//go:linkname procKill libc_kill //go:linkname procKill libc_kill
//go:linkname procLchown libc_lchown //go:linkname procLchown libc_lchown
//go:linkname procLink libc_link //go:linkname procLink libc_link
//go:linkname proc__xnet_llisten libc___xnet_llisten //go:linkname proc__xnet_listen libc___xnet_listen
//go:linkname procLstat libc_lstat //go:linkname procLstat libc_lstat
//go:linkname procMadvise libc_madvise //go:linkname procMadvise libc_madvise
//go:linkname procMkdir libc_mkdir //go:linkname procMkdir libc_mkdir
@@ -371,7 +371,7 @@ var (
procKill, procKill,
procLchown, procLchown,
procLink, procLink,
proc__xnet_llisten, proc__xnet_listen,
procLstat, procLstat,
procMadvise, procMadvise,
procMkdir, procMkdir,
@@ -1178,7 +1178,7 @@ func Link(path string, link string) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Listen(s int, backlog int) (err error) { func Listen(s int, backlog int) (err error) {
_, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_llisten)), 2, uintptr(s), uintptr(backlog), 0, 0, 0, 0) _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_listen)), 2, uintptr(s), uintptr(backlog), 0, 0, 0, 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)
} }
+3 -2
View File
@@ -203,7 +203,8 @@ type Xucred struct {
Uid uint32 Uid uint32
Ngroups int16 Ngroups int16
Groups [16]uint32 Groups [16]uint32
_ *byte _ byte
Pid uint32
} }
type Linger struct { type Linger struct {
@@ -268,7 +269,7 @@ const (
SizeofSockaddrAny = 0x6c SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36 SizeofSockaddrDatalink = 0x36
SizeofXucred = 0x50 SizeofXucred = 0x54
SizeofLinger = 0x8 SizeofLinger = 0x8
SizeofIovec = 0x8 SizeofIovec = 0x8
SizeofIPMreq = 0x8 SizeofIPMreq = 0x8
+3 -2
View File
@@ -200,7 +200,8 @@ type Xucred struct {
Uid uint32 Uid uint32
Ngroups int16 Ngroups int16
Groups [16]uint32 Groups [16]uint32
_ *byte _ byte
Pid uint32
} }
type Linger struct { type Linger struct {
@@ -265,7 +266,7 @@ const (
SizeofSockaddrAny = 0x6c SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36 SizeofSockaddrDatalink = 0x36
SizeofXucred = 0x58 SizeofXucred = 0x54
SizeofLinger = 0x8 SizeofLinger = 0x8
SizeofIovec = 0x10 SizeofIovec = 0x10
SizeofIPMreq = 0x8 SizeofIPMreq = 0x8
+3 -2
View File
@@ -202,7 +202,8 @@ type Xucred struct {
Uid uint32 Uid uint32
Ngroups int16 Ngroups int16
Groups [16]uint32 Groups [16]uint32
_ *byte _ byte
Pid uint32
} }
type Linger struct { type Linger struct {
@@ -267,7 +268,7 @@ const (
SizeofSockaddrAny = 0x6c SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36 SizeofSockaddrDatalink = 0x36
SizeofXucred = 0x50 SizeofXucred = 0x54
SizeofLinger = 0x8 SizeofLinger = 0x8
SizeofIovec = 0x8 SizeofIovec = 0x8
SizeofIPMreq = 0x8 SizeofIPMreq = 0x8
+3 -2
View File
@@ -200,7 +200,8 @@ type Xucred struct {
Uid uint32 Uid uint32
Ngroups int16 Ngroups int16
Groups [16]uint32 Groups [16]uint32
_ *byte _ byte
Pid uint32
} }
type Linger struct { type Linger struct {
@@ -265,7 +266,7 @@ const (
SizeofSockaddrAny = 0x6c SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36 SizeofSockaddrDatalink = 0x36
SizeofXucred = 0x58 SizeofXucred = 0x54
SizeofLinger = 0x8 SizeofLinger = 0x8
SizeofIovec = 0x10 SizeofIovec = 0x10
SizeofIPMreq = 0x8 SizeofIPMreq = 0x8
+3 -2
View File
@@ -200,7 +200,8 @@ type Xucred struct {
Uid uint32 Uid uint32
Ngroups int16 Ngroups int16
Groups [16]uint32 Groups [16]uint32
_ *byte _ byte
Pid uint32
} }
type Linger struct { type Linger struct {
@@ -265,7 +266,7 @@ const (
SizeofSockaddrAny = 0x6c SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36 SizeofSockaddrDatalink = 0x36
SizeofXucred = 0x58 SizeofXucred = 0x54
SizeofLinger = 0x8 SizeofLinger = 0x8
SizeofIovec = 0x10 SizeofIovec = 0x10
SizeofIPMreq = 0x8 SizeofIPMreq = 0x8
+72
View File
@@ -632,6 +632,8 @@ const (
IFA_FLAGS = 0x8 IFA_FLAGS = 0x8
IFA_RT_PRIORITY = 0x9 IFA_RT_PRIORITY = 0x9
IFA_TARGET_NETNSID = 0xa IFA_TARGET_NETNSID = 0xa
IFAL_LABEL = 0x2
IFAL_ADDRESS = 0x1
RT_SCOPE_UNIVERSE = 0x0 RT_SCOPE_UNIVERSE = 0x0
RT_SCOPE_SITE = 0xc8 RT_SCOPE_SITE = 0xc8
RT_SCOPE_LINK = 0xfd RT_SCOPE_LINK = 0xfd
@@ -689,6 +691,7 @@ const (
SizeofRtAttr = 0x4 SizeofRtAttr = 0x4
SizeofIfInfomsg = 0x10 SizeofIfInfomsg = 0x10
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofIfAddrlblmsg = 0xc
SizeofIfaCacheinfo = 0x10 SizeofIfaCacheinfo = 0x10
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
@@ -740,6 +743,15 @@ type IfAddrmsg struct {
Index uint32 Index uint32
} }
type IfAddrlblmsg struct {
Family uint8
_ uint8
Prefixlen uint8
Flags uint8
Index uint32
Seq uint32
}
type IfaCacheinfo struct { type IfaCacheinfo struct {
Prefered uint32 Prefered uint32
Valid uint32 Valid uint32
@@ -3052,6 +3064,23 @@ const (
) )
const ( const (
TCA_UNSPEC = 0x0
TCA_KIND = 0x1
TCA_OPTIONS = 0x2
TCA_STATS = 0x3
TCA_XSTATS = 0x4
TCA_RATE = 0x5
TCA_FCNT = 0x6
TCA_STATS2 = 0x7
TCA_STAB = 0x8
TCA_PAD = 0x9
TCA_DUMP_INVISIBLE = 0xa
TCA_CHAIN = 0xb
TCA_HW_OFFLOAD = 0xc
TCA_INGRESS_BLOCK = 0xd
TCA_EGRESS_BLOCK = 0xe
TCA_DUMP_FLAGS = 0xf
TCA_EXT_WARN_MSG = 0x10
RTNLGRP_NONE = 0x0 RTNLGRP_NONE = 0x0
RTNLGRP_LINK = 0x1 RTNLGRP_LINK = 0x1
RTNLGRP_NOTIFY = 0x2 RTNLGRP_NOTIFY = 0x2
@@ -3086,6 +3115,18 @@ const (
RTNLGRP_IPV6_MROUTE_R = 0x1f RTNLGRP_IPV6_MROUTE_R = 0x1f
RTNLGRP_NEXTHOP = 0x20 RTNLGRP_NEXTHOP = 0x20
RTNLGRP_BRVLAN = 0x21 RTNLGRP_BRVLAN = 0x21
RTNLGRP_MCTP_IFADDR = 0x22
RTNLGRP_TUNNEL = 0x23
RTNLGRP_STATS = 0x24
RTNLGRP_IPV4_MCADDR = 0x25
RTNLGRP_IPV6_MCADDR = 0x26
RTNLGRP_IPV6_ACADDR = 0x27
TCA_ROOT_UNSPEC = 0x0
TCA_ROOT_TAB = 0x1
TCA_ROOT_FLAGS = 0x2
TCA_ROOT_COUNT = 0x3
TCA_ROOT_TIME_DELTA = 0x4
TCA_ROOT_EXT_WARN_MSG = 0x5
) )
type CapUserHeader struct { type CapUserHeader struct {
@@ -3549,6 +3590,8 @@ type Nhmsg struct {
Flags uint32 Flags uint32
} }
const SizeofNhmsg = 0x8
type NexthopGrp struct { type NexthopGrp struct {
Id uint32 Id uint32
Weight uint8 Weight uint8
@@ -3556,6 +3599,8 @@ type NexthopGrp struct {
Resvd2 uint16 Resvd2 uint16
} }
const SizeofNexthopGrp = 0x8
const ( const (
NHA_UNSPEC = 0x0 NHA_UNSPEC = 0x0
NHA_ID = 0x1 NHA_ID = 0x1
@@ -6291,3 +6336,30 @@ type SockDiagReq struct {
} }
const RTM_NEWNVLAN = 0x70 const RTM_NEWNVLAN = 0x70
const (
MPOL_BIND = 0x2
MPOL_DEFAULT = 0x0
MPOL_F_ADDR = 0x2
MPOL_F_MEMS_ALLOWED = 0x4
MPOL_F_MOF = 0x8
MPOL_F_MORON = 0x10
MPOL_F_NODE = 0x1
MPOL_F_NUMA_BALANCING = 0x2000
MPOL_F_RELATIVE_NODES = 0x4000
MPOL_F_SHARED = 0x1
MPOL_F_STATIC_NODES = 0x8000
MPOL_INTERLEAVE = 0x3
MPOL_LOCAL = 0x4
MPOL_MAX = 0x7
MPOL_MF_INTERNAL = 0x10
MPOL_MF_LAZY = 0x8
MPOL_MF_MOVE_ALL = 0x4
MPOL_MF_MOVE = 0x2
MPOL_MF_STRICT = 0x1
MPOL_MF_VALID = 0x7
MPOL_MODE_FLAGS = 0xe000
MPOL_PREFERRED = 0x1
MPOL_PREFERRED_MANY = 0x5
MPOL_WEIGHTED_INTERLEAVE = 0x6
)
+9 -45
View File
@@ -62,7 +62,6 @@ import (
"path/filepath" "path/filepath"
"runtime" "runtime"
"sort" "sort"
"strconv"
"strings" "strings"
"text/template" "text/template"
) )
@@ -543,47 +542,9 @@ func (f *Fn) ParamPrintList() string {
return join(f.Params, func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `) return join(f.Params, func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
} }
// ParamCount return number of syscall parameters for function f. // SyscallN returns a string representing the SyscallN function.
func (f *Fn) ParamCount() int { func (f *Fn) SyscallN() string {
n := 0 return syscalldot() + "SyscallN"
for _, p := range f.Params {
n += len(p.SyscallArgList())
}
return n
}
// SyscallParamCount determines which version of Syscall/Syscall6/Syscall9/...
// to use. It returns parameter count for correspondent SyscallX function.
func (f *Fn) SyscallParamCount() int {
n := f.ParamCount()
switch {
case n <= 3:
return 3
case n <= 6:
return 6
case n <= 9:
return 9
case n <= 12:
return 12
case n <= 15:
return 15
case n <= 42: // current SyscallN limit
return n
default:
panic("too many arguments to system call")
}
}
// Syscall determines which SyscallX function to use for function f.
func (f *Fn) Syscall() string {
c := f.SyscallParamCount()
if c == 3 {
return syscalldot() + "Syscall"
}
if c > 15 {
return syscalldot() + "SyscallN"
}
return syscalldot() + "Syscall" + strconv.Itoa(c)
} }
// SyscallParamList returns source code for SyscallX parameters for function f. // SyscallParamList returns source code for SyscallX parameters for function f.
@@ -592,9 +553,12 @@ func (f *Fn) SyscallParamList() string {
for _, p := range f.Params { for _, p := range f.Params {
a = append(a, p.SyscallArgList()...) a = append(a, p.SyscallArgList()...)
} }
for len(a) < f.SyscallParamCount() {
a = append(a, "0") // Check if the number exceeds the current SyscallN limit
if len(a) > 42 {
panic("too many arguments to system call")
} }
return strings.Join(a, ", ") return strings.Join(a, ", ")
} }
@@ -1015,7 +979,7 @@ func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{
{{define "results"}}{{if .Rets.List}}{{.Rets.List}} {{end}}{{end}} {{define "results"}}{{if .Rets.List}}{{.Rets.List}} {{end}}{{end}}
{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(),{{if le .ParamCount 15}} {{.ParamCount}},{{end}} {{.SyscallParamList}}){{end}} {{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.SyscallN}}(proc{{.DLLFuncName}}.Addr(), {{.SyscallParamList}}){{end}}
{{define "tmpvarsreadback"}}{{range .Params}}{{if .TmpVarReadbackCode}} {{define "tmpvarsreadback"}}{{range .Params}}{{if .TmpVarReadbackCode}}
{{.TmpVarReadbackCode}}{{end}}{{end}}{{end}} {{.TmpVarReadbackCode}}{{end}}{{end}}{{end}}
+4 -4
View File
@@ -50,7 +50,7 @@ func TestDLLFilenameEscaping(t *testing.T) {
} }
} }
func TestSyscallXGeneration(t *testing.T) { func TestSyscallNGeneration(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
wantsysfunc string wantsysfunc string
@@ -58,17 +58,17 @@ func TestSyscallXGeneration(t *testing.T) {
}{ }{
{ {
name: "syscall with 2 params", name: "syscall with 2 params",
wantsysfunc: "syscall.Syscall", wantsysfunc: "syscall.SyscallN",
sig: "Example(a1 *uint16, a2 *uint16) = ", sig: "Example(a1 *uint16, a2 *uint16) = ",
}, },
{ {
name: "syscall with 6 params", name: "syscall with 6 params",
wantsysfunc: "syscall.Syscall6", wantsysfunc: "syscall.SyscallN",
sig: "Example(a1 *uint, a2 *uint, a3 *uint, a4 *uint, a5 *uint, a6 *uint) = ", sig: "Example(a1 *uint, a2 *uint, a3 *uint, a4 *uint, a5 *uint, a6 *uint) = ",
}, },
{ {
name: "syscall with 15 params", name: "syscall with 15 params",
wantsysfunc: "syscall.Syscall15", wantsysfunc: "syscall.SyscallN",
sig: strings.ReplaceAll(`Example(a1 *uint, a2 *uint, a3 *uint, a4 *uint, a5 *uint, a6 *uint, sig: strings.ReplaceAll(`Example(a1 *uint, a2 *uint, a3 *uint, a4 *uint, a5 *uint, a6 *uint,
a7 *uint, a8 *uint, a9 *uint, a10 *uint, a11 *uint, a12 *uint, a7 *uint, a8 *uint, a9 *uint, a10 *uint, a11 *uint, a12 *uint,
a13 *uint, a14 *uint, a15 *uint) = `, "\n", ""), a13 *uint, a14 *uint, a15 *uint) = `, "\n", ""),
+8 -8
View File
@@ -52,7 +52,7 @@ var (
) )
func regConnectRegistry(machinename *uint16, key syscall.Handle, result *syscall.Handle) (regerrno error) { func regConnectRegistry(machinename *uint16, key syscall.Handle, result *syscall.Handle) (regerrno error) {
r0, _, _ := syscall.Syscall(procRegConnectRegistryW.Addr(), 3, uintptr(unsafe.Pointer(machinename)), uintptr(key), uintptr(unsafe.Pointer(result))) r0, _, _ := syscall.SyscallN(procRegConnectRegistryW.Addr(), uintptr(unsafe.Pointer(machinename)), uintptr(key), uintptr(unsafe.Pointer(result)))
if r0 != 0 { if r0 != 0 {
regerrno = syscall.Errno(r0) regerrno = syscall.Errno(r0)
} }
@@ -60,7 +60,7 @@ func regConnectRegistry(machinename *uint16, key syscall.Handle, result *syscall
} }
func regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) { func regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) {
r0, _, _ := syscall.Syscall9(procRegCreateKeyExW.Addr(), 9, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(reserved), uintptr(unsafe.Pointer(class)), uintptr(options), uintptr(desired), uintptr(unsafe.Pointer(sa)), uintptr(unsafe.Pointer(result)), uintptr(unsafe.Pointer(disposition))) r0, _, _ := syscall.SyscallN(procRegCreateKeyExW.Addr(), uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(reserved), uintptr(unsafe.Pointer(class)), uintptr(options), uintptr(desired), uintptr(unsafe.Pointer(sa)), uintptr(unsafe.Pointer(result)), uintptr(unsafe.Pointer(disposition)))
if r0 != 0 { if r0 != 0 {
regerrno = syscall.Errno(r0) regerrno = syscall.Errno(r0)
} }
@@ -68,7 +68,7 @@ func regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *
} }
func regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) { func regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) {
r0, _, _ := syscall.Syscall(procRegDeleteKeyW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(subkey)), 0) r0, _, _ := syscall.SyscallN(procRegDeleteKeyW.Addr(), uintptr(key), uintptr(unsafe.Pointer(subkey)))
if r0 != 0 { if r0 != 0 {
regerrno = syscall.Errno(r0) regerrno = syscall.Errno(r0)
} }
@@ -76,7 +76,7 @@ func regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) {
} }
func regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) { func regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) {
r0, _, _ := syscall.Syscall(procRegDeleteValueW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(name)), 0) r0, _, _ := syscall.SyscallN(procRegDeleteValueW.Addr(), uintptr(key), uintptr(unsafe.Pointer(name)))
if r0 != 0 { if r0 != 0 {
regerrno = syscall.Errno(r0) regerrno = syscall.Errno(r0)
} }
@@ -84,7 +84,7 @@ func regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) {
} }
func regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) { func regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) {
r0, _, _ := syscall.Syscall9(procRegEnumValueW.Addr(), 8, uintptr(key), uintptr(index), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(valtype)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(buflen)), 0) r0, _, _ := syscall.SyscallN(procRegEnumValueW.Addr(), uintptr(key), uintptr(index), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(valtype)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(buflen)))
if r0 != 0 { if r0 != 0 {
regerrno = syscall.Errno(r0) regerrno = syscall.Errno(r0)
} }
@@ -92,7 +92,7 @@ func regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint3
} }
func regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint32, buflenCopied *uint32, flags uint32, dir *uint16) (regerrno error) { func regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint32, buflenCopied *uint32, flags uint32, dir *uint16) (regerrno error) {
r0, _, _ := syscall.Syscall9(procRegLoadMUIStringW.Addr(), 7, uintptr(key), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(unsafe.Pointer(buflenCopied)), uintptr(flags), uintptr(unsafe.Pointer(dir)), 0, 0) r0, _, _ := syscall.SyscallN(procRegLoadMUIStringW.Addr(), uintptr(key), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(unsafe.Pointer(buflenCopied)), uintptr(flags), uintptr(unsafe.Pointer(dir)))
if r0 != 0 { if r0 != 0 {
regerrno = syscall.Errno(r0) regerrno = syscall.Errno(r0)
} }
@@ -100,7 +100,7 @@ func regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint
} }
func regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) { func regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) {
r0, _, _ := syscall.Syscall6(procRegSetValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(valueName)), uintptr(reserved), uintptr(vtype), uintptr(unsafe.Pointer(buf)), uintptr(bufsize)) r0, _, _ := syscall.SyscallN(procRegSetValueExW.Addr(), uintptr(key), uintptr(unsafe.Pointer(valueName)), uintptr(reserved), uintptr(vtype), uintptr(unsafe.Pointer(buf)), uintptr(bufsize))
if r0 != 0 { if r0 != 0 {
regerrno = syscall.Errno(r0) regerrno = syscall.Errno(r0)
} }
@@ -108,7 +108,7 @@ func regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype
} }
func expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) { func expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) {
r0, _, e1 := syscall.Syscall(procExpandEnvironmentStringsW.Addr(), 3, uintptr(unsafe.Pointer(src)), uintptr(unsafe.Pointer(dst)), uintptr(size)) r0, _, e1 := syscall.SyscallN(procExpandEnvironmentStringsW.Addr(), uintptr(unsafe.Pointer(src)), uintptr(unsafe.Pointer(dst)), uintptr(size))
n = uint32(r0) n = uint32(r0)
if n == 0 { if n == 0 {
err = errnoErr(e1) err = errnoErr(e1)
+17
View File
@@ -321,6 +321,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
//sys SetConsoleOutputCP(cp uint32) (err error) = kernel32.SetConsoleOutputCP //sys SetConsoleOutputCP(cp uint32) (err error) = kernel32.SetConsoleOutputCP
//sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW //sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW
//sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW //sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW
//sys GetNumberOfConsoleInputEvents(console Handle, numevents *uint32) (err error) = kernel32.GetNumberOfConsoleInputEvents
//sys FlushConsoleInputBuffer(console Handle) (err error) = kernel32.FlushConsoleInputBuffer
//sys resizePseudoConsole(pconsole Handle, size uint32) (hr error) = kernel32.ResizePseudoConsole //sys resizePseudoConsole(pconsole Handle, size uint32) (hr error) = kernel32.ResizePseudoConsole
//sys CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot //sys CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot
//sys Module32First(snapshot Handle, moduleEntry *ModuleEntry32) (err error) = kernel32.Module32FirstW //sys Module32First(snapshot Handle, moduleEntry *ModuleEntry32) (err error) = kernel32.Module32FirstW
@@ -890,8 +892,12 @@ const socket_error = uintptr(^uint32(0))
//sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar //sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar
//sys getBestInterfaceEx(sockaddr unsafe.Pointer, pdwBestIfIndex *uint32) (errcode error) = iphlpapi.GetBestInterfaceEx //sys getBestInterfaceEx(sockaddr unsafe.Pointer, pdwBestIfIndex *uint32) (errcode error) = iphlpapi.GetBestInterfaceEx
//sys GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) = iphlpapi.GetIfEntry2Ex //sys GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) = iphlpapi.GetIfEntry2Ex
//sys GetIpForwardEntry2(row *MibIpForwardRow2) (errcode error) = iphlpapi.GetIpForwardEntry2
//sys GetIpForwardTable2(family uint16, table **MibIpForwardTable2) (errcode error) = iphlpapi.GetIpForwardTable2
//sys GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) = iphlpapi.GetUnicastIpAddressEntry //sys GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) = iphlpapi.GetUnicastIpAddressEntry
//sys FreeMibTable(memory unsafe.Pointer) = iphlpapi.FreeMibTable
//sys NotifyIpInterfaceChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyIpInterfaceChange //sys NotifyIpInterfaceChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyIpInterfaceChange
//sys NotifyRouteChange2(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyRouteChange2
//sys NotifyUnicastIpAddressChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyUnicastIpAddressChange //sys NotifyUnicastIpAddressChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyUnicastIpAddressChange
//sys CancelMibChangeNotify2(notificationHandle Handle) (errcode error) = iphlpapi.CancelMibChangeNotify2 //sys CancelMibChangeNotify2(notificationHandle Handle) (errcode error) = iphlpapi.CancelMibChangeNotify2
@@ -914,6 +920,17 @@ type RawSockaddrInet6 struct {
Scope_id uint32 Scope_id uint32
} }
// RawSockaddrInet is a union that contains an IPv4, an IPv6 address, or an address family. See
// https://learn.microsoft.com/en-us/windows/win32/api/ws2ipdef/ns-ws2ipdef-sockaddr_inet.
//
// A [*RawSockaddrInet] may be converted to a [*RawSockaddrInet4] or [*RawSockaddrInet6] using
// unsafe, depending on the address family.
type RawSockaddrInet struct {
Family uint16
Port uint16
Data [6]uint32
}
type RawSockaddr struct { type RawSockaddr struct {
Family uint16 Family uint16
Data [14]int8 Data [14]int8
+98
View File
@@ -65,6 +65,22 @@ var signals = [...]string{
15: "terminated", 15: "terminated",
} }
// File flags for [os.OpenFile]. The O_ prefix is used to indicate
// that these flags are specific to the OpenFile function.
const (
O_FILE_FLAG_OPEN_NO_RECALL = FILE_FLAG_OPEN_NO_RECALL
O_FILE_FLAG_OPEN_REPARSE_POINT = FILE_FLAG_OPEN_REPARSE_POINT
O_FILE_FLAG_SESSION_AWARE = FILE_FLAG_SESSION_AWARE
O_FILE_FLAG_POSIX_SEMANTICS = FILE_FLAG_POSIX_SEMANTICS
O_FILE_FLAG_BACKUP_SEMANTICS = FILE_FLAG_BACKUP_SEMANTICS
O_FILE_FLAG_DELETE_ON_CLOSE = FILE_FLAG_DELETE_ON_CLOSE
O_FILE_FLAG_SEQUENTIAL_SCAN = FILE_FLAG_SEQUENTIAL_SCAN
O_FILE_FLAG_RANDOM_ACCESS = FILE_FLAG_RANDOM_ACCESS
O_FILE_FLAG_NO_BUFFERING = FILE_FLAG_NO_BUFFERING
O_FILE_FLAG_OVERLAPPED = FILE_FLAG_OVERLAPPED
O_FILE_FLAG_WRITE_THROUGH = FILE_FLAG_WRITE_THROUGH
)
const ( const (
FILE_READ_DATA = 0x00000001 FILE_READ_DATA = 0x00000001
FILE_READ_ATTRIBUTES = 0x00000080 FILE_READ_ATTRIBUTES = 0x00000080
@@ -1976,6 +1992,12 @@ const (
SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1 SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1
) )
// FILE_ZERO_DATA_INFORMATION from winioctl.h
type FileZeroDataInformation struct {
FileOffset int64
BeyondFinalZero int64
}
const ( const (
ComputerNameNetBIOS = 0 ComputerNameNetBIOS = 0
ComputerNameDnsHostname = 1 ComputerNameDnsHostname = 1
@@ -2298,6 +2320,82 @@ type MibIfRow2 struct {
OutQLen uint64 OutQLen uint64
} }
// IP_ADDRESS_PREFIX stores an IP address prefix. See
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-ip_address_prefix.
type IpAddressPrefix struct {
Prefix RawSockaddrInet
PrefixLength uint8
}
// NL_ROUTE_ORIGIN enumeration from nldef.h or
// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_route_origin.
const (
NlroManual = 0
NlroWellKnown = 1
NlroDHCP = 2
NlroRouterAdvertisement = 3
Nlro6to4 = 4
)
// NL_ROUTE_ORIGIN enumeration from nldef.h or
// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_route_protocol.
const (
MIB_IPPROTO_OTHER = 1
MIB_IPPROTO_LOCAL = 2
MIB_IPPROTO_NETMGMT = 3
MIB_IPPROTO_ICMP = 4
MIB_IPPROTO_EGP = 5
MIB_IPPROTO_GGP = 6
MIB_IPPROTO_HELLO = 7
MIB_IPPROTO_RIP = 8
MIB_IPPROTO_IS_IS = 9
MIB_IPPROTO_ES_IS = 10
MIB_IPPROTO_CISCO = 11
MIB_IPPROTO_BBN = 12
MIB_IPPROTO_OSPF = 13
MIB_IPPROTO_BGP = 14
MIB_IPPROTO_IDPR = 15
MIB_IPPROTO_EIGRP = 16
MIB_IPPROTO_DVMRP = 17
MIB_IPPROTO_RPL = 18
MIB_IPPROTO_DHCP = 19
MIB_IPPROTO_NT_AUTOSTATIC = 10002
MIB_IPPROTO_NT_STATIC = 10006
MIB_IPPROTO_NT_STATIC_NON_DOD = 10007
)
// MIB_IPFORWARD_ROW2 stores information about an IP route entry. See
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipforward_row2.
type MibIpForwardRow2 struct {
InterfaceLuid uint64
InterfaceIndex uint32
DestinationPrefix IpAddressPrefix
NextHop RawSockaddrInet
SitePrefixLength uint8
ValidLifetime uint32
PreferredLifetime uint32
Metric uint32
Protocol uint32
Loopback uint8
AutoconfigureAddress uint8
Publish uint8
Immortal uint8
Age uint32
Origin uint32
}
// MIB_IPFORWARD_TABLE2 contains a table of IP route entries. See
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipforward_table2.
type MibIpForwardTable2 struct {
NumEntries uint32
Table [1]MibIpForwardRow2
}
// Rows returns the IP route entries in the table.
func (t *MibIpForwardTable2) Rows() []MibIpForwardRow2 {
return unsafe.Slice(&t.Table[0], t.NumEntries)
}
// MIB_UNICASTIPADDRESS_ROW stores information about a unicast IP address. See // MIB_UNICASTIPADDRESS_ROW stores information about a unicast IP address. See
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_unicastipaddress_row. // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_unicastipaddress_row.
type MibUnicastIpAddressRow struct { type MibUnicastIpAddressRow struct {
File diff suppressed because it is too large Load Diff