Author SHA1 Message Date
RandyTheSilly d82a9bb43d Apply patch 2025-10-26 12:43:34 -04: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
28 changed files with 748 additions and 726 deletions
-115
View File
@@ -1,115 +0,0 @@
diff --git a/unix/ztypes_freebsd_386.go b/unix/ztypes_freebsd_386.go
index 51e13eb0..5212328e 100644
--- a/unix/ztypes_freebsd_386.go
+++ b/unix/ztypes_freebsd_386.go
@@ -203,7 +203,8 @@ type Xucred struct {
Uid uint32
Ngroups int16
Groups [16]uint32
- _ *byte
+ _ byte
+ Pid uint32
}
type Linger struct {
@@ -268,7 +269,7 @@ const (
SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36
- SizeofXucred = 0x50
+ SizeofXucred = 0x54
SizeofLinger = 0x8
SizeofIovec = 0x8
SizeofIPMreq = 0x8
diff --git a/unix/ztypes_freebsd_amd64.go b/unix/ztypes_freebsd_amd64.go
index d002d8ef..1673b4e8 100644
--- a/unix/ztypes_freebsd_amd64.go
+++ b/unix/ztypes_freebsd_amd64.go
@@ -200,7 +200,8 @@ type Xucred struct {
Uid uint32
Ngroups int16
Groups [16]uint32
- _ *byte
+ _ byte
+ Pid uint32
}
type Linger struct {
@@ -265,7 +266,7 @@ const (
SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36
- SizeofXucred = 0x58
+ SizeofXucred = 0x54
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
diff --git a/unix/ztypes_freebsd_arm.go b/unix/ztypes_freebsd_arm.go
index 3f863d89..a54f4570 100644
--- a/unix/ztypes_freebsd_arm.go
+++ b/unix/ztypes_freebsd_arm.go
@@ -202,7 +202,8 @@ type Xucred struct {
Uid uint32
Ngroups int16
Groups [16]uint32
- _ *byte
+ _ byte
+ Pid uint32
}
type Linger struct {
@@ -267,7 +268,7 @@ const (
SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36
- SizeofXucred = 0x50
+ SizeofXucred = 0x54
SizeofLinger = 0x8
SizeofIovec = 0x8
SizeofIPMreq = 0x8
diff --git a/unix/ztypes_freebsd_arm64.go b/unix/ztypes_freebsd_arm64.go
index 61c72931..a91ccc72 100644
--- a/unix/ztypes_freebsd_arm64.go
+++ b/unix/ztypes_freebsd_arm64.go
@@ -200,7 +200,8 @@ type Xucred struct {
Uid uint32
Ngroups int16
Groups [16]uint32
- _ *byte
+ _ byte
+ Pid uint32
}
type Linger struct {
@@ -265,7 +266,7 @@ const (
SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36
- SizeofXucred = 0x58
+ SizeofXucred = 0x54
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
diff --git a/unix/ztypes_freebsd_riscv64.go b/unix/ztypes_freebsd_riscv64.go
index b5d17414..596538d9 100644
--- a/unix/ztypes_freebsd_riscv64.go
+++ b/unix/ztypes_freebsd_riscv64.go
@@ -200,7 +200,8 @@ type Xucred struct {
Uid uint32
Ngroups int16
Groups [16]uint32
- _ *byte
+ _ byte
+ Pid uint32
}
type Linger struct {
@@ -265,7 +266,7 @@ const (
SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36
- SizeofXucred = 0x58
+ SizeofXucred = 0x54
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
+15 -5
View File
@@ -1,7 +1,17 @@
# sys - rwinkhart patches
This repository holds my custom patches atop the Go sys module.
# sys
The only changes in the master branch are this README and the patches in the `1patches` directory. The patches are applied on other branches and tagged releases are available for import from the releases page.
[![Go Reference](https://pkg.go.dev/badge/golang.org/x/sys.svg)](https://pkg.go.dev/golang.org/x/sys)
# How To?
Copy the desired patch file(s) into a new branch (cloned from upstream master) and apply with `patch -p1 < patchfile.patch`.
This repository holds supplemental Go packages for low-level interactions with
the operating system.
## Report Issues / Send Patches
This repository uses Gerrit for code changes. To learn how to submit changes to
this repository, see https://go.dev/doc/contribute.
The git repository is https://go.googlesource.com/sys.
The main issue tracker for the sys repository is located at
https://go.dev/issues. Prefix your issue with "x/sys:" in the
subject line, so it is easy to find.
-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
// 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) {
fd, err := open(".", O_RDONLY)
if err != nil {
return "", err
}
defer Close(fd)
return Fd2path(fd)
return syscall.Getwd()
}
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.
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 {
s[i] = 0
s[i] = ^cpuMask(0)
}
}
+5 -5
View File
@@ -12,7 +12,7 @@ import (
"os"
"path/filepath"
"runtime"
"sort"
"slices"
"strconv"
"strings"
"testing"
@@ -72,7 +72,7 @@ func TestDirent(t *testing.T) {
}
}
sort.Strings(names)
slices.Sort(names)
t.Logf("names: %q", names)
if len(names) != 10 {
@@ -145,9 +145,9 @@ func TestDirentRepeat(t *testing.T) {
}
// Check results
sort.Strings(files)
sort.Strings(files2)
if strings.Join(files, "|") != strings.Join(files2, "|") {
slices.Sort(files)
slices.Sort(files2)
if !slices.Equal(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.
func (fds *FdSet) Zero() {
for i := range fds.Bits {
fds.Bits[i] = 0
}
clear(fds.Bits[:])
}
+4 -5
View File
@@ -10,8 +10,7 @@ import (
"fmt"
"os"
"path/filepath"
"sort"
"strings"
"slices"
"testing"
"golang.org/x/sys/unix"
@@ -71,9 +70,9 @@ func testGetdirentries(t *testing.T, count int) {
}
}
sort.Strings(names)
sort.Strings(names2)
if strings.Join(names, ":") != strings.Join(names2, ":") {
slices.Sort(names)
slices.Sort(names2)
if !slices.Equal(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
// being sent to the kernel if an ifreq is reused.
func (ifr *Ifreq) clear() {
for i := range ifr.raw.Ifru {
ifr.raw.Ifru[i] = 0
}
clear(ifr.raw.Ifru[:])
}
// TODO(mdlayher): export as IfreqData? For now we can provide helpers such as
+36 -1
View File
@@ -121,6 +121,7 @@ struct termios2 {
#include <linux/hidraw.h>
#include <linux/icmp.h>
#include <linux/icmpv6.h>
#include <linux/if_addrlabel.h>
#include <linux/if_alg.h>
#include <linux/if_bridge.h>
#include <linux/if_packet.h>
@@ -878,6 +879,8 @@ const (
IFA_FLAGS = C.IFA_FLAGS
IFA_RT_PRIORITY = C.IFA_RT_PRIORITY
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_SITE = C.RT_SCOPE_SITE
RT_SCOPE_LINK = C.RT_SCOPE_LINK
@@ -935,6 +938,7 @@ const (
SizeofRtAttr = C.sizeof_struct_rtattr
SizeofIfInfomsg = C.sizeof_struct_ifinfomsg
SizeofIfAddrmsg = C.sizeof_struct_ifaddrmsg
SizeofIfAddrlblmsg = C.sizeof_struct_ifaddrlblmsg
SizeofIfaCacheinfo = C.sizeof_struct_ifa_cacheinfo
SizeofRtMsg = C.sizeof_struct_rtmsg
SizeofRtNexthop = C.sizeof_struct_rtnexthop
@@ -956,6 +960,8 @@ type IfInfomsg C.struct_ifinfomsg
type IfAddrmsg C.struct_ifaddrmsg
type IfAddrlblmsg C.struct_ifaddrlblmsg
type IfaCacheinfo C.struct_ifa_cacheinfo
type RtMsg C.struct_rtmsg
@@ -3113,8 +3119,25 @@ const (
)
// 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 (
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_LINK = C.RTNLGRP_LINK
RTNLGRP_NOTIFY = C.RTNLGRP_NOTIFY
@@ -3149,6 +3172,18 @@ const (
RTNLGRP_IPV6_MROUTE_R = C.RTNLGRP_IPV6_MROUTE_R
RTNLGRP_NEXTHOP = C.RTNLGRP_NEXTHOP
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
+1
View File
@@ -49,6 +49,7 @@ esac
if [[ "$GOOS" = "linux" ]]; then
# Use the Docker-based build system
# 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 run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && pwd):/build generate:$GOOS
exit
+1 -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.
binary.BigEndian.PutUint16(sa.raw[6:8], sa.SID)
copy(sa.raw[8:14], sa.Remote)
for i := 14; i < 14+IFNAMSIZ; i++ {
sa.raw[i] = 0
}
clear(sa.raw[14 : 14+IFNAMSIZ])
copy(sa.raw[14:], sa.Dev)
return unsafe.Pointer(&sa.raw), SizeofSockaddrPPPoX, nil
}
+17
View File
@@ -248,6 +248,23 @@ func Statvfs(path string, buf *Statvfs_t) (err error) {
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
*/
+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 Lchown(path string, uid int, gid int) (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 Madvise(b []byte, advice int) (err error)
//sys Mkdir(path string, mode uint32) (err error)
+4 -4
View File
@@ -72,7 +72,7 @@ import (
//go:cgo_import_dynamic libc_kill kill "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___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_madvise madvise "libc.so"
//go:cgo_import_dynamic libc_mkdir mkdir "libc.so"
@@ -221,7 +221,7 @@ import (
//go:linkname procKill libc_kill
//go:linkname procLchown libc_lchown
//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 procMadvise libc_madvise
//go:linkname procMkdir libc_mkdir
@@ -371,7 +371,7 @@ var (
procKill,
procLchown,
procLink,
proc__xnet_llisten,
proc__xnet_listen,
procLstat,
procMadvise,
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
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 {
err = errnoErr(e1)
}
+3 -2
View File
@@ -203,7 +203,8 @@ type Xucred struct {
Uid uint32
Ngroups int16
Groups [16]uint32
_ *byte
_ byte
Pid uint32
}
type Linger struct {
@@ -268,7 +269,7 @@ const (
SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36
SizeofXucred = 0x50
SizeofXucred = 0x54
SizeofLinger = 0x8
SizeofIovec = 0x8
SizeofIPMreq = 0x8
+3 -2
View File
@@ -200,7 +200,8 @@ type Xucred struct {
Uid uint32
Ngroups int16
Groups [16]uint32
_ *byte
_ byte
Pid uint32
}
type Linger struct {
@@ -265,7 +266,7 @@ const (
SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36
SizeofXucred = 0x58
SizeofXucred = 0x54
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
+3 -2
View File
@@ -202,7 +202,8 @@ type Xucred struct {
Uid uint32
Ngroups int16
Groups [16]uint32
_ *byte
_ byte
Pid uint32
}
type Linger struct {
@@ -267,7 +268,7 @@ const (
SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36
SizeofXucred = 0x50
SizeofXucred = 0x54
SizeofLinger = 0x8
SizeofIovec = 0x8
SizeofIPMreq = 0x8
+3 -2
View File
@@ -200,7 +200,8 @@ type Xucred struct {
Uid uint32
Ngroups int16
Groups [16]uint32
_ *byte
_ byte
Pid uint32
}
type Linger struct {
@@ -265,7 +266,7 @@ const (
SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36
SizeofXucred = 0x58
SizeofXucred = 0x54
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
+3 -2
View File
@@ -200,7 +200,8 @@ type Xucred struct {
Uid uint32
Ngroups int16
Groups [16]uint32
_ *byte
_ byte
Pid uint32
}
type Linger struct {
@@ -265,7 +266,7 @@ const (
SizeofSockaddrAny = 0x6c
SizeofSockaddrUnix = 0x6a
SizeofSockaddrDatalink = 0x36
SizeofXucred = 0x58
SizeofXucred = 0x54
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
+41
View File
@@ -632,6 +632,8 @@ const (
IFA_FLAGS = 0x8
IFA_RT_PRIORITY = 0x9
IFA_TARGET_NETNSID = 0xa
IFAL_LABEL = 0x2
IFAL_ADDRESS = 0x1
RT_SCOPE_UNIVERSE = 0x0
RT_SCOPE_SITE = 0xc8
RT_SCOPE_LINK = 0xfd
@@ -689,6 +691,7 @@ const (
SizeofRtAttr = 0x4
SizeofIfInfomsg = 0x10
SizeofIfAddrmsg = 0x8
SizeofIfAddrlblmsg = 0xc
SizeofIfaCacheinfo = 0x10
SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8
@@ -740,6 +743,15 @@ type IfAddrmsg struct {
Index uint32
}
type IfAddrlblmsg struct {
Family uint8
_ uint8
Prefixlen uint8
Flags uint8
Index uint32
Seq uint32
}
type IfaCacheinfo struct {
Prefered uint32
Valid uint32
@@ -3052,6 +3064,23 @@ 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_LINK = 0x1
RTNLGRP_NOTIFY = 0x2
@@ -3086,6 +3115,18 @@ const (
RTNLGRP_IPV6_MROUTE_R = 0x1f
RTNLGRP_NEXTHOP = 0x20
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 {
+9 -45
View File
@@ -62,7 +62,6 @@ import (
"path/filepath"
"runtime"
"sort"
"strconv"
"strings"
"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) }, `", ", `)
}
// ParamCount return number of syscall parameters for function f.
func (f *Fn) ParamCount() int {
n := 0
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)
// SyscallN returns a string representing the SyscallN function.
func (f *Fn) SyscallN() string {
return syscalldot() + "SyscallN"
}
// SyscallParamList returns source code for SyscallX parameters for function f.
@@ -592,9 +553,12 @@ func (f *Fn) SyscallParamList() string {
for _, p := range f.Params {
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, ", ")
}
@@ -1015,7 +979,7 @@ func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{
{{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}}
{{.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 {
name string
wantsysfunc string
@@ -58,17 +58,17 @@ func TestSyscallXGeneration(t *testing.T) {
}{
{
name: "syscall with 2 params",
wantsysfunc: "syscall.Syscall",
wantsysfunc: "syscall.SyscallN",
sig: "Example(a1 *uint16, a2 *uint16) = ",
},
{
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) = ",
},
{
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,
a7 *uint, a8 *uint, a9 *uint, a10 *uint, a11 *uint, a12 *uint,
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) {
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 {
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) {
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 {
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) {
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 {
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) {
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 {
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) {
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 {
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) {
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 {
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) {
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 {
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) {
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)
if n == 0 {
err = errnoErr(e1)
+2
View File
@@ -321,6 +321,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
//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 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 CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot
//sys Module32First(snapshot Handle, moduleEntry *ModuleEntry32) (err error) = kernel32.Module32FirstW
+22
View File
@@ -65,6 +65,22 @@ var signals = [...]string{
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 (
FILE_READ_DATA = 0x00000001
FILE_READ_ATTRIBUTES = 0x00000080
@@ -1976,6 +1992,12 @@ const (
SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1
)
// FILE_ZERO_DATA_INFORMATION from winioctl.h
type FileZeroDataInformation struct {
FileOffset int64
BeyondFinalZero int64
}
const (
ComputerNameNetBIOS = 0
ComputerNameDnsHostname = 1
File diff suppressed because it is too large Load Diff