Commit Graph

1256 Commits

Author SHA1 Message Date
Brad Fitzpatrick
fcb26fe61c windows: gofmt to add go:build lines
Change-Id: I71b9023fcb6c9860ea35ba0d2cf77a6eed5176b9
Reviewed-on: https://go-review.googlesource.com/c/sys/+/357329
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-20 15:40:33 +00:00
Jason A. Donenfeld
25fac919d9 windows/svc: do not close service handle
The documentation [1] says "The service status handle does not have to
be closed." That makes it seem like it's optional. But actually, closing
it raises a user exception, because it's not a legitimate handle to
close.

This commit also adds the right go build comments with a `go fmt` pass.

[1] https://docs.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-registerservicectrlhandlerexa

Change-Id: Ibf67c0e8d94c87068720472009b24cecdfda6519
Reviewed-on: https://go-review.googlesource.com/c/sys/+/357250
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-20 15:30:01 +00:00
Jason A. Donenfeld
0ec99a608a windows/svc: rewrite in Go
The old service management code was written in assembly and communicated
over Windows events, which resulted in non-obvious control flow.
NewCallback makes it possible to rewrite all of this in vanilla Go. This
also enables the service test on the Go builders, as modifying system
services shouldn't be an issue there.

Change-Id: I8003b57d11d4469f762058c648a4b7733530eeb8
Reviewed-on: https://go-review.googlesource.com/c/sys/+/330010
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-20 06:40:51 +00:00
Koichi Shiraishi
9d821ace86 unix: add all trampoline_addr to darwin_test.go and sorted
lacked:
  libc_clock_gettime_trampoline_addr
  libc_clonefile_trampoline_addr
  libc_clonefileat_trampoline_addr
  libc_fclonefileat_trampoline_addr
  libc_getcwd_trampoline_addr
  libc_sendfile_trampoline_addr
  libc_setattrlist_trampoline_addr
  libc_shmat_trampoline_addr
  libc_shmctl_trampoline_addr
  libc_shmdt_trampoline_addr
  libc_shmget_trampoline_addr

Change-Id: I5722c61db415fd409a05c351959740d57891db04
Reviewed-on: https://go-review.googlesource.com/c/sys/+/354469
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-10-19 18:19:41 +00:00
Tobias Klauser
69063c4bb7 unix: test AF_VSOCK sockets on linux
Follow the implementation of the tests added in CL 354269 for darwin.

Change-Id: I00701227dfb26169a356d875ddb3737849d0bba0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/356289
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2021-10-15 20:08:01 +00:00
Hao Mou
97ac67df71 windows: add const values
When I was working with NtCreateFile and DeviceIoControl, I found a lot
of the constant values are missing, so I added them.

The access masks I added for NtCreateFile are described here: https://docs.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntcreatefile
Their values are listed here: https://docs.microsoft.com/en-us/windows/win32/fileio/file-access-rights-constants
The FSCTL control codes I added for DeviceIoControl are listed here: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/4dc02779-9d95-43f8-bba4-8d4ce4961458

This seems trivial so I did not create an issue.

Change-Id: I0c1b72ac1b34413a6ed7420026df46ff94cefe5f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/355350
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-10-13 07:50:03 +00:00
Weilu Jia
d3039528d8 windows: add low level memory related syscalls
Adds VirtualQuery, VirtualQueryEx, VirtualProtectEx, ReadProcessMemory, and WriteProcessMemory.

VirtualProtect already exists.

https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualquery
https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualqueryex
https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualprotectex
https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-readprocessmemory
https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-writeprocessmemory

Change-Id: I609a09641c502d8d3802036123e0784b7c76e99b
GitHub-Last-Rev: 368f8c7b62
GitHub-Pull-Request: golang/sys#117
Reviewed-on: https://go-review.googlesource.com/c/sys/+/352249
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-10-07 07:53:35 +00:00
Koichi Shiraishi
1a26e0398e unix: add SockaddrVM type and AF_VSOCK to anyToSockaddrGOOS to darwin
Change-Id: I511be555d92ac87a797949fc4c99fd8ef9515ace
Reviewed-on: https://go-review.googlesource.com/c/sys/+/354269
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-06 22:55:09 +00:00
Koichi Shiraishi
c8a6f52230 unix: fix lack of Sysv shared trampoline on darwin/arm64
In CL 353509, doesn't generate Sysv shared trampoline for darwin/arm64.

Change-Id: Id4a87205000d2b4169204992ead3d042d1d5aef4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/354270
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-06 19:47:10 +00:00
Koichi Shiraishi
2c5d950f24 unix: support vsock for darwin
Change-Id: Id53e2b0d0dc3b83762bb4ccc001d4e40f738de73
Reviewed-on: https://go-review.googlesource.com/c/sys/+/352209
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-10-04 09:30:28 +00:00
Tobias Klauser
b1ebd4e100 unix: enable Sysv shared memory support on darwin/arm64
Keep it disabled on ios though.

For golang/go#45696
For golang/go#46084

Change-Id: I3d551227a4ebc0eebabdd16b175aa6a75ea9de19
Reviewed-on: https://go-review.googlesource.com/c/sys/+/353509
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-03 12:29:50 +00:00
Tobias Klauser
808efd93c3 cpu: enable TestARM64minimalFeatures on darwin/arm64
Go 1.16 renamed the iOS port from darwin/arm64 to ios/arm64 and
darwin/arm64 was repurposed for the macOS ARM64 port (see
https://golang.org/doc/go1.16#darwin).

Now that Go 1.16 is the oldest supported release, the ios tag can be
used exclusively to detect iOS. Thus, TestARM64minimalFeatures which
ought to run on darwin/arm64 can now be enabled on that platform.

For golang/go#45696

Change-Id: Ic510fbf27dc813832507446201501df58c9f6f31
Reviewed-on: https://go-review.googlesource.com/c/sys/+/353530
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-02 10:42:44 +00:00
Tobias Klauser
b1447f3f25 unix: enable TestPassFD and TestPoll on darwin/arm64
Go 1.16 renamed the iOS port from darwin/arm64 to ios/arm64 and
darwin/arm64 was repurposed for the macOS ARM64 port (see
https://golang.org/doc/go1.16#darwin).

Now that Go 1.16 is the oldest supported release, the ios tag can be
used exclusively to detect iOS. Thus, TestPassFD and TestPoll which
ought to run on darwin/arm64 can now be enabled on that platform.

For golang/go#45696

Change-Id: I0b542af7a1b5ab194bf249d499c49e45bb55a2e1
Reviewed-on: https://go-review.googlesource.com/c/sys/+/353529
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-02 10:42:28 +00:00
Dustin Spicuzza
39dca1131b unix: SysvShmCtl should use ipc_64 on mips64(le)
For golang/go#48708

Change-Id: Ieb5fdb5eb571af836268b69d3f1066ef8497a7b7
GitHub-Last-Rev: 59e24d8fdb
GitHub-Pull-Request: golang/sys#118
Reviewed-on: https://go-review.googlesource.com/c/sys/+/353398
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-01 09:24:34 +00:00
Ian Lance Taylor
f542c8878d unix: skip TestSysvSharedMemory on ENOSYS
Whether System V IPC is supported is a kernel configuration.

For golang/go#48708

Change-Id: Id0d23a5ede5f75f70ca6bb0b8abaec773b6adc74
Reviewed-on: https://go-review.googlesource.com/c/sys/+/353392
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-09-30 21:29:24 +00:00
Dustin Spicuzza
969570ce7c unix: add Sysv shared memory support
Implements proposed API from https://golang.org/issue/46084. I chose
`SysvShmDesc` since it's a clearer name than `SysvShm`. Initially supports Darwin and Linux.

Solaris support has a blocker (https://golang.org/issue/46084#issuecomment-836980018)

For golang/go#46084

Change-Id: Ied0f768a74c448254adc3315348417825a7ec63e
GitHub-Last-Rev: befbd7af6b
GitHub-Pull-Request: golang/sys#110
Reviewed-on: https://go-review.googlesource.com/c/sys/+/327830
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-30 14:19:18 +00:00
Paul E. Murphy
39ccf1dd6f unix: skip TestIoctlGetRTCWkAlrm if unsupported
Some RTC devices do not support wakeup alarms and will return
EINVAL in such cases. The generic powerpc rtc driver is one such
case.

Fixes golang/go#48554

Change-Id: I46f6da7902586a7fcaa9a367801d9fead288e264
Reviewed-on: https://go-review.googlesource.com/c/sys/+/352090
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: David Chase <drchase@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-27 09:40:55 +00:00
Jason A. Donenfeld
1cf2251ac2 unix: implement ppoll in terms of poll on Linux
Android's Bionic libc installs a seccomp filter that allows ppoll but
not poll. This has been fine for arm64, where we already implement poll
in terms of ppoll, but not the other architectures, such as amd64, which
runs on Chromebooks, and currently leads to crashes.

This commit implements poll in terms of ppoll on the remaining
architectures and makes this common code, so that everyone uses the more
modern syscall.

Change-Id: Ic01a32b5abe48ab53a2549f592a41561f1684c30
Reviewed-on: https://go-review.googlesource.com/c/sys/+/352310
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-27 05:27:49 +00:00
Weilu Jia
92d5a993a6 windows: add process module related syscalls
Add EnumProcessModules, EnumProcessModulesEx, GetModuleInformation, GetModuleFileNameEx and GetModuleBaseName.

https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-enumprocessmodules
https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-enumprocessmodulesex
https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-getmoduleinformation
https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-getmodulefilenameexw
https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-getmodulebasenamew

Change-Id: I75b062daec7a2cc9685e803dfa851825acee32b6
GitHub-Last-Rev: 7c208d6d3e
GitHub-Pull-Request: golang/sys#116
Reviewed-on: https://go-review.googlesource.com/c/sys/+/350870
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Minux Ma <minux@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-09-25 03:26:02 +00:00
Tobias Klauser
b8560ed6a9 unix/linux: update Dockerfile to Go 1.17.1
Change-Id: Iba0c7ce39221a0b9d7eaddd569bc6ea8ccceebd5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/351429
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-23 06:10:19 +00:00
Tobias Klauser
437939a702 unix: use dup3 in Dup2 on all Linux platforms
The minimum required Linux kernel version for Go 1.18 will be changed to
2.6.32, see golang/go#45964. The dup3 syscall was added in 2.6.27, so it
can be used instead of the dup2 syscall which is not implemented on
arm64 and riscv64 or blocked on android.

For golang/go#45964

Change-Id: I9c677db4bae3ce441b258c49580fb9a2cd600436
Reviewed-on: https://go-review.googlesource.com/c/sys/+/350552
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-21 06:55:28 +00:00
Tobias Klauser
d61c044b16 unix: implement Pipe using pipe2 syscall on all linux platforms
Most architectures currently already implement Pipe using the pipe2
syscall. Only 386, amd64, mips{,le}, ppc and sparc64 still use the pipe
syscall. However, some systems (e.g. Android seccomp policies) block
that syscall, see golang/go#40828 for an example.

The pipe2 syscall was added in Linux kernel version 2.6.27. The minimum
required Linux kernel version for Go 1.18 will be changed to 2.6.32
per golang/go#45964 so it is possible to unify the implementation of
Pipe using the pipe2 syscall.

Same as CL 350530 did for package syscall.

For golang/go#45964
Fixes golang/go#40828

Change-Id: I07d84d3ea06a54e37d9ff6b72702fe5d96efef7b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/350549
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-17 16:11:53 +00:00
Tobias Klauser
ed5796bab1 unix: implement EpollCreate using EpollCreate1 on all linux platforms
Most newer architectures (e.g. arm64 or riscv64) don't provide the
epoll_create syscall. Some systems (e.g. Android) block it even if it
were available. In the kernel, the epoll_create syscall is implemented
[1] the same way EpollCreate is implemented in this package for
platforms without the epoll_create syscall. Thus, avoid the separate
wrapper and consistently implement EpollCreate using EpollCreate1.

[1] https://elixir.bootlin.com/linux/v5.15-rc1/source/fs/eventpoll.c#L2006

Change-Id: I8ac11d0de939dafa4b1d189d97d350b9c324c3ab
Reviewed-on: https://go-review.googlesource.com/c/sys/+/349809
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-15 08:33:10 +00:00
Nahum Shalman
751e447fb3 unix: add additional illumos STREAMS ioctls
This work is in support of WireGuard/wireguard-go#39

Change-Id: I04f3fdb40c1a6c8fe42cab5253c9edd4a5a1845d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/348950
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Than McIntosh <thanm@google.com>
2021-09-10 15:07:52 +00:00
Lorenz Bauer
528a39cd75 unix: add PidfdOpen and PidfdGetfd
Add wrappers for the pidfd_open and pidfd_getfd sycalls, available since 5.3.

PIDFD_NONBLOCK is defined manually since mkerrors.sh doesn't handle including
linux/pidfd.h well.

See https://man7.org/linux/man-pages/man2/pidfd_open.2.html

Change-Id: I68dfb52f6a7a44b7f3324a8379860a1bb765e71b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/347332
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-09 19:32:31 +00:00
jharshman
aa78b53d33 unix: define Time_t for FreeBSD
Fixes golang/go#48148

Change-Id: I8c0a62b204689fc6ac9e29b1ba0b084e3d807323
Reviewed-on: https://go-review.googlesource.com/c/sys/+/348012
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-09-08 23:34:32 +00:00
Matt Layher
a851e7ddee unix: change Landlock type aliases to new types
Type aliases were introduced in CL 348349 and I did not notice it during
the review process. The typical convention is to create new types instead.

Change-Id: I4789cfc836b8612abfd791451edfd619c93d23df
Reviewed-on: https://go-review.googlesource.com/c/sys/+/348450
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-08 16:03:47 +00:00
Tobias Klauser
c212e73226 unix: add Landlock consts and types
Change-Id: I5b8eee0594072e58951dd8b655058b96caeba497
Reviewed-on: https://go-review.googlesource.com/c/sys/+/348349
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2021-09-08 14:30:11 +00:00
Tobias Klauser
6f6e22806c unix: implement InotifyInit using InotifyInit1 on all linux platforms
Most newer architectures (e.g. arm64 or riscv64) don't provide the
inotify_init syscall and some systems (e.g. Android) block it even if it
were available. Internally, the inotify_init syscall is implemented
exactly like inotify_init1 [1], so there is no point in having a
separate wrapper on some platforms.

[1] https://elixir.bootlin.com/linux/v5.14.1/source/fs/notify/inotify/inotify_user.c#L704

Change-Id: Iae69de8e6cad1c6207fc0f521e275d94cdad3ca5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/347869
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-06 17:05:28 +00:00
Tobias Klauser
97244b9997 unix: drop fallback to accept in Accept on Linux
Same as CL 346849 does for package syscall.

The minimum required Linux kernel version for Go 1.18 will be changed to
2.6.32, see golang/go#45964. The current minimum required version is
2.6.23 and accept4 was added in 2.6.28, so the fallback to accept in
Accept on Linux can be removed.

For golang/go#45964

Change-Id: Idf915d5a24cf570a2cfa0f0548c1841f3fc64d5a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/347329
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2021-09-03 07:17:46 +00:00
Tobias Klauser
2934436797 unix: drop fallback to inotifyInit in InotifyInit on linux/amd64
The minimum required Linux kernel version for Go 1.18 will be changed to
2.6.32, see golang/go#45964. The current minimum required version is
2.6.23 and the inotify_init1 syscall was added in 2.6.27, so the
fallback to inotifyInit and inotifyInit itself can be removed on
linux/amd64.

For golang/go#45964

Change-Id: I8dc83ef04d74cfc9ec80da503076b9acfa9c365a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/347330
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2021-09-03 07:17:12 +00:00
Tobias Klauser
0a7ae4be8d unix: drop fallback to pipe in Pipe on linux/arm
Same as CL 347349 does for package syscall.

The minimum required Linux kernel version for Go 1.18 will be changed to
2.6.32, see golang/go#45964. The pipe2 syscall was added in 2.6.27, so
the fallback to use the pipe syscall in syscall.Pipe on linux/arm can
be removed.

For golang/go#45964

Change-Id: I8e222dc4b373b22f91bc1ddcc48f58a37dafcffa
Reviewed-on: https://go-review.googlesource.com/c/sys/+/347331
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2021-09-03 07:16:34 +00:00
Nahum Shalman
f475640dd0 unix: add more illumos Lifreq helpers
This work is in support of wireGuard/wireguard-go#39

Change-Id: Id205d28935b76b49ec6b29aba0a741659c5c01d7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/345610
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Cherry Mui <cherryyz@google.com>
2021-09-02 05:02:50 +00:00
Tobias Klauser
164ac21ac1 unix: drop fallback to utimes in UtimesNano on Linux
Same as CL 346790 does for package syscall.

The minimum required Linux kernel version for Go 1.18 will be changed to
2.6.32, see golang/go#45964. The current minimum required version is
2.6.23 and utimensat was added in 2.6.22, so the fallback isn't even
necessary for the current minimum supported version. Remove the fallback
to utimes.

For golang/go#45964

Change-Id: Iaed782d182851c9ccff32f831e1704bae52662a6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/346829
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-02 05:02:39 +00:00
Tobias Klauser
f4d43177bf unix/linux: update Dockerfile to Kernel 5.14
Change-Id: Ie6b9521c70c0e91a507a923811f44f797b64e064
Reviewed-on: https://go-review.googlesource.com/c/sys/+/346029
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2021-08-31 04:25:30 +00:00
zhangyunhao
63515b42dc cpu: add support for detecting cmpxchg16b
Change-Id: I892de938e85205c0506aa82e31297b7a99e48e44
Reviewed-on: https://go-review.googlesource.com/c/sys/+/329450
Trust: Martin Möhrmann <martin@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Martin Möhrmann <martin@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <martin@golang.org>
2021-08-23 07:06:55 +00:00
Matt Layher
41cdb8703e unix: add Ifreq.Inet4Addr methods for manipulating IPv4 addresses
ioctls such as SIOCGIFADDR deal with AF_INET sockaddr addresses, but none of
the fields aside from the embedded IPv4 address are used. To keep the interface
more simple, we directly expose Inet4Addr get and set methods which enable use
of these ioctls with the Ifreq wrapper.

Change-Id: Ia8b6ab9730f852cb99f4152e334a59d395476d2f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/343250
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-08-20 12:10:16 +00:00
Tobias Klauser
f52c844e1c unix: add RTF_GLOBAL on darwin
Fixes golang/go#45848

Change-Id: Iadd8499a66d5c5b7940df1477d88926f4b30cdb0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/343509
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2021-08-19 13:52:13 +00:00
Mark Jeffery
bce67f0961 unix: add SetsockoptTCPRepairOpt on Linux
There is currently no function to allow for setting repair options for sockets in repair mode.
There are 4 options catered for in the linux implementation.

TCPOPT_WINDOW
TCPOPT_MAXSEG
TCPOPT_SACK_PERMITTED
TCPOPT_TIMESTAMP

Details of the patch to the kernel and the thinking behind it is here  https://lwn.net/Articles/495304

Work done in this commit
Included the tcp options type and length for inclusion in the Docker build
Added TCPOPT to the regular expression in mkerrors.sh. There was only TCP_ previously
Add the new function to syscall_unix.go

I have tested locally and verified each option with ss -i

I am not sure whether to commit tests because I don't know if socket creation is possible on the test runs in the offical pipeline.
I did check for existing tests but didn't see any that created sockets, only one that validated a string option.

Fixes golang/go#46984

Change-Id: Iade0434c05cebf2fbdfb5f04b2a7b51c8b358423
Reviewed-on: https://go-review.googlesource.com/c/sys/+/332709
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-19 07:21:35 +00:00
David Crawshaw
44f02d92fd windows: add WTSGetActiveConsoleSessionId
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-wtsgetactiveconsolesessionid

Change-Id: I3c180bbb3a768beac6633e78514fac4e3837b69d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/331909
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-19 07:20:04 +00:00
Matt Layher
00dd8d7831 unix: gofmt with Go 1.17
Change-Id: I867e6e01c803fec1b5db464db0e88dfe5799cd43
Reviewed-on: https://go-review.googlesource.com/c/sys/+/343249
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-08-18 15:36:20 +00:00
Matt Layher
bfb29a6856 unix: export Ifreq and add IoctlIfreq function
This CL expands upon CL 340369 by exporting the Ifreq type along with methods
for setting and getting data to/from the ifreq union in a type-safe way.
ifreqData remains unexported as we can keep adding helpers similar to the
IoctlGetEthtoolDrvinfo to expose those operations in a less error-prone way.

A test is also added to verify interface index data using IoctlIfreq against
the modern rtnetlink API used by the standard library.

Change-Id: Ic6980cbcd3792cc341cd614061cce32fa1f851e7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/340370
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-08-17 19:03:40 +00:00
Tobias Klauser
7d9622a276 unix/linux: update Dockerfile to Go 1.17
Change-Id: Ic711a44c7ecf5d0ab5237a910c920f4b76873c57
Reviewed-on: https://go-review.googlesource.com/c/sys/+/342829
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2021-08-17 14:26:37 +00:00
Nahum Shalman
fefb4affbe unix: expose solaris types needed for Event Ports
This work is in support of a cleanup of fsnotify/fsnotify#263

Change-Id: I2bc50036087a038c2aa8b6178687d1a870b9d1fd
Reviewed-on: https://go-review.googlesource.com/c/sys/+/324629
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-17 13:44:02 +00:00
Nahum Shalman
13f9c583af unix: create wrappers for solaris/illumos Event Ports
This work is in support of a cleanup of fsnotify/fsnotify#263

Change-Id: Ibd7500d20322765bfd50aa18333eb43ee7b659d7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/324630
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-08-17 13:33:20 +00:00
Matt Layher
1e6c022a89 unix/linux: use HTTPS to git clone glibc in Dockerfile
This resolves a TODO to replace the insecure git protocol clone. There are no
changes to the generated code.

Change-Id: I66c83bcec572bf35a1206f8c82606cc122abb703
Reviewed-on: https://go-review.googlesource.com/c/sys/+/342553
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-16 18:31:51 +00:00
Tobias Klauser
fcbd12d029 unix/linux: update Dockerfile to glibc 2.34
No changes in generated files.

Change-Id: I83ffd002e070e350c2ec4026c9044a66a847e474
Reviewed-on: https://go-review.googlesource.com/c/sys/+/342569
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2021-08-16 17:40:21 +00:00
Mark Jeffery
15123e1e1f unix: add Send on Linux
Added Send function which in turn calls existing Sendto.

Fixes golang/go#47288

Change-Id: I5c928a19cc4f10961a9e6d2802e197cc3b799438
Reviewed-on: https://go-review.googlesource.com/c/sys/+/336569
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matt Layher <mdlayher@gmail.com>
2021-08-16 07:42:44 +00:00
Tobias Klauser
b9628f2c71 unix: add missing RLIMIT_* consts on openbsd/{386,arm}
Change-Id: I7e978beec3d63d407ffb97fb526ad0bc4ae4a03b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/341069
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-16 07:39:13 +00:00
Tobias Klauser
649d0fc2fc unix/linux: update Dockerfile to Go 1.17rc2
Change-Id: Idc623480fd6a4a2c733fa2eec05091112421af2b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/334530
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-08-16 07:10:09 +00:00