Same as CL 386415 does for package syscall.
accept is no longer used on Linux since CL 347329 changed Accept to use
accept4 only.
For golang/go#45964
Change-Id: I9f431044c03e7f28c08152390ad71f45eddfe9dd
Reviewed-on: https://go-review.googlesource.com/c/sys/+/386954
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
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>
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>
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#45964Fixesgolang/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>
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>
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>
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>
This adds the constants and types needed for the Linux NFC Subsystem.
It also adds support for sockaddr_nfc and sockaddr_nfc_llcp to Connect.
The Linux NFC Subsystem is documented in:
https://www.kernel.org/doc/html/latest/networking/nfc.html.
Change-Id: Ic6a79afdba85e9b154ec46f191f27714b4b38a57
Reviewed-on: https://go-review.googlesource.com/c/sys/+/323551
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>
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).
Not strictly necessary but will avoid spurious changes
as files are edited.
Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild
Change-Id: I01667f826428426a39c84717d02efa25fa44553c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/294490
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Russ Cox <rsc@golang.org>
There is some inconsistent use of tabs and spaces in the //sys and
//sysnb lines. However, the large majority is using tabs, so use these
consistently.
Also change the regexp in mksyscall*.go to only accept tabs going
forward.
Change-Id: I78944e88b5fec11c1bd1d103cea894bc5109da56
Reviewed-on: https://go-review.googlesource.com/c/sys/+/283596
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>
Android O and newer blocks access to the dup2 syscall. Route calls
to Dup2 to Dup3.
Change-Id: I76c0180db260ece4840b8ebf2736fb3f8c7ff9eb
Reviewed-on: https://go-review.googlesource.com/c/sys/+/231277
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
setfsuid(2) and setfsgid(2) both return an int value that indicates the
previous fsuid or fsgid set. This change makes unix.Setfsgid() and
unix.Setfsuid() return these values too instead of returning only an
error.
Fixesgolang/go#36649
Change-Id: I56cbb49d7485023b6b04f7b95e8f675473241d8c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/215240
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
On linux/riscv64, the renameat syscall no longer exists and has been
superseded by renameat2. Use Renameat2 to implement Renameat on
linux/riscv64.
Based on a patch by Ryan O'Leary.
Updates golang/go#27532
Change-Id: I7c60c7f824750408265f67397b8ac1fa7226f425
Reviewed-on: https://go-review.googlesource.com/c/157899
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
ARM64 does this exact same thing, and in fact this is required on
Android 9, where Bionic now only allows lstat on 32-bit platforms
Folks are running into this when using Android on Chromebooks,
which are keeping AMD64 Android alive. So, we change the AMD64
behavior to model that of ARM64.
Change-Id: Id933cc22b42ab365c12980915557bdbf88661a4d
Reviewed-on: https://go-review.googlesource.com/c/153319
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
ARM64 does this exact same thing, and in fact this is required on
Android 9, where Bionic now only allows inotify_init on 32-bit
platforms. Folks are running into this when using Android on
Chromebooks, which are keeping AMD64 Android alive. So, we change the
AMD64 behavior to model that of ARM64. However, since Go must run on
kernels between 2.6.27 and 2.6.23, we must still fall back to the
original call.
Fixes: https://lore.kernel.org/wireguard/CALv=V9Gv6apdWJ9P-80zf9bgByd=c3QqPhRHuw6o0_OaH0=W6g@mail.gmail.com
Change-Id: I183e82679cb7d702d12a35457920ccd422176254
Reviewed-on: https://go-review.googlesource.com/c/153318
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Add a wrapper for the kexec_file_load syscall on the architectures that
implement it (amd64, ppc64x, s390x). See
http://man7.org/linux/man-pages/man2/kexec_file_load.2.html
Change-Id: Ie29f871902176610a6ba7ed0a7bcc95c10eb172b
Reviewed-on: https://go-review.googlesource.com/c/140037
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
On linux/arm64 we used to manually define syscall numbers for some
deprecated syscalls. Most of them are unused by now anyhow. Convert the
remaining syscall wrappers using them to implement the respective
functionality using a non-deprecated syscall (in the same way glibc does
it):
- Implement EpollCreate using EpollCreate1 and additionally check
that the passed size argument is larger than 0.
- Implement Futimesat and utimes using utimensat. Also change futimesat
on the other geese to take a string instead of *byte and let the
generated wrapper do the BytePtrFromString conversion.
- Return ENOSYS from Ustat. The ustat syscall has been deprecated for a
long time in favor of fstatfs and statfs. Even glibc will deprecate
ustat in the upcoming 2.28 release [1].
[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS;h=d51fa09544f03899b7ff5a80569db088c3c23c28;hb=HEAD#l90
Change-Id: I7ea38a3cd394b0875f17443b14e107fd9c70350d
Reviewed-on: https://go-review.googlesource.com/119655
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
The stat syscall is disallowed by Android's seccomp policy on
linux/amd64. Use the fstatat syscall with AT_FDCWD and zero flags to
achieve the same behavior.
CL 109835 did the same for package syscall.
Change-Id: Iaa7d0dbf17ade4803f59b4361973ce627bcb65b4
Reviewed-on: https://go-review.googlesource.com/110061
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This is yet another syscall that needs to be changed around for
Android's seccomp. We already do this in MIPS64 and ARM64, but
apparently forgot about AMD64.
Change-Id: I42c8a4653a55d4714dacfaf7add14012f428c992
Reviewed-on: https://go-review.googlesource.com/109835
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Looks like it's enough to just add wrappers pointing to the
corresponding SYS_FSTATAT{,64} or SYS_NEWFSTATAT syscall. Add a test to
verify that assumption which checks that the returned stat data matches
what is returned by Stat/Lstat.
Also add the AT_NO_AUTOMOUNT constant which may be used for the flags
parmeter.
Fixesgolang/go#14216
Change-Id: I73f27b483bd97d2dcf09d4b95a7957e75d194395
Reviewed-on: https://go-review.googlesource.com/79795
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
All the implementations of NsecToTimespec and NsecToTimeval were the
same other than types. Write a single version that uses
GOARCH/GOOS-specific setTimespec and setTimeval functions to handle the
types.
The logic in NsecToTimespec and NsecToTimeval caused times before 1970
to have a negative usec/nsec. The Linux kernel requires that usec
contain a positive number; for consistency, we do this for both
NsecToTimespec and NsecToTimeval.
Follow CL 30826 which did the same for syscall.
Change-Id: Id6c6f4fef8450251447d1a5b01f35c2a36b5aeb1
Reviewed-on: https://go-review.googlesource.com/73170
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
All implementations of these functions are identical.
Follow CL 30819 which did the same for syscall.
Change-Id: I3c78f05ea12251306f3e100a006d266154a5238e
Reviewed-on: https://go-review.googlesource.com/72378
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
These functions are redeclared in gccgo builds, so move them
to separate files with the "!gccgo" build constraint.
Fixesgolang/go#18312
Change-Id: I868cfb77fc394e5e96cee78af0f3abf43db6082a
Reviewed-on: https://go-review.googlesource.com/34379
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Use a shim for Poll on arm64.
Fixesgolang/go#16052.
Change-Id: I929e7a2293561bddb9355bf65f98bc68b91905b2
Reviewed-on: https://go-review.googlesource.com/24062
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Pause is a legacy syscall not available on linux-arm64. Use ppoll with
all args as 0 to emulate - this is the way musl libc does Pause when the
pause syscall isn't available.
With the changes in syscall_linux* and regenerating zsyscall_linux*,
this calling Pause on linux-arm64 works and returns EINTR as expected.
Change-Id: I88236290313f18c742d826e759e86ff260a8b383
Reviewed-on: https://go-review.googlesource.com/22014
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
epoll_wait syscall doesn't exist on arm64. Implement it with
by callign epoll_pwait(). According to man epoll_pwait,
calling epoll_pwait with sigmask of NULL is identical to
epoll_wait.
Testing exposed that EpollEvent needs padding on arm64
like on arm.
This changeset is to fix:
https://github.com/fsnotify/fsnotify/issues/130
Testcase: go test with fsnotify ported from syscall to x/sys:
https://github.com/suihkulokki/fsnotify/tree/go-sys
Change-Id: I76136bf4c82c2ee597549133848f490da46dd488
Reviewed-on: https://go-review.googlesource.com/21971
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
It wasn't in linux/arm.
Tested with:
$ for x in $(go tool dist list ) ; do \
export GOOS=$(echo $x | cut -d/ -f1); \
export GOARCH=$(echo $x | cut -d/ -f2); \
echo "$GOOS; $GOARCH"; go install .; done
... which all pass, except openbsd/arm which is still broken exactly
how it was broken previously.
Fixesgolang/go#14643
Change-Id: Ie7ae861b581b539178de26f15ba3f4bdd0e9b785
Reviewed-on: https://go-review.googlesource.com/21013
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Some system calls are obsolete and no longer available for EABI.
This CL replace such system call usages.
Updates golang/go#14524
Change-Id: Ib99b239455ca677e46d7097911904c45119051bd
Reviewed-on: https://go-review.googlesource.com/19945
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This is a copy of http://golang.org/cl/9870 in the syscall package.
This is in preparation for arm64 support, as the arm64 Linux kernel
does not have an inotify_init system call, only inotify_init1.
Update golang/go#10150.
Change-Id: I9224a094af79adbb2f5714ad977b195d5a941eb0
Reviewed-on: https://go-review.googlesource.com/10036
Reviewed-by: Rob Pike <r@golang.org>
This copies http://golang.org/cl/8723 from the syscall package.
Quoting the original CL:
This is clumsy, but currently cover tool fails as:
$ go test -run=none -cover syscall
syscall_linux_amd64.go:15: can only use //go:noescape with external func imp
FAIL syscall [build failed]
This happens because cover tool mishandles //go: comments.
r and gri said that fixing cover is infeasible due to go/ast limitations.
So at least fix the offending code so that coverage works.
This come up in context of coverage-guided fuzzing which works best
with program-wide coverage.
Change-Id: Id9e243968a4eb7ae75a585877fdf3192c89e419c
Reviewed-on: https://go-review.googlesource.com/10035
Reviewed-by: Rob Pike <r@golang.org>
This brings over three CLs from the main syscall package:
http://golang.org/cl/5833http://golang.org/cl/5835http://golang.org/cl/5837
Pipe, Pipe2, and Dup2 are moved from syscall_linux.go to the GOARCH
specific variants. On 386 and amd64, Linux kernel version 2.6.23 (the
documented minimum Linux kernel version the Go distribution supports)
does not support the pipe2 system call, so Pipe continues to call
pipe. On ARM, Pipe now calls pipe2.
Several system calls are reimplemented in terms of the *at syscalls,
passing AT_FDCWD to indicate that pathnames are to be interpreted
relative to the current directory. The *at syscalls were added in
Linux kernel version 2.6.16.
This is in preparation for arm64 support, as the arm64 Linux kernel
does not provide the traditional syscall variants.
Change-Id: Id6bc6097dc5f4324cd9e429c5e1f3a411a08ce42
Reviewed-on: https://go-review.googlesource.com/10032
Reviewed-by: Rob Pike <r@golang.org>
Because ARM ABI requires 64-bit argument to be passed in even
register pairs, to avoid wasting one register between fd and
advise in the usual fadvise64 syscall signature, linux/arm
has its own variation that reorders the argument so that the
arguments fit in six registers.
While we're at it, also fix build for linux/386.
Fixesgolang/go#10294.
Change-Id: I322e2226619c5aa9c096a1d5cb7ae1e94fd4a5a1
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8282
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
If we use a local type, it won't compare properly with errors from
the rest of the standard library. Errors are the one type from syscall
that propagates through the system, so it's important to have only
one type for them.
Ditto for syscall.Signal.
LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/123490043
Semi-automatic migration from package syscall to package {plan9,windows,unix}.
No builds attempted yet, but this gets a lot of noise behind us so subsequent
CLs will be more concise and easier to follow.
Subsequent CLs will have semantic content.
LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/121520043
This CL copies to each package of go.sys the files from syscall it will need.
Different directories have different files, but these:
mkall.sh
str.go
syscall.go
mksyscall.pl
race.go
race0.go
syscall_test.go
are copied to all three.
No changes yet, these are just copies. They are not ready to use yet:
package names are wrong, for starters. But this clean copy will make
it easier to follow the changes as the packages are enabled.
LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/126960043