Граф коммитов

42 Коммитов

Автор SHA1 Сообщение Дата
Eric Lagergren b1e9470b6e unix: add MemfdSecret
Fixes #51547

Change-Id: I07a02e8e6ac8baaa72f1c214621fbaca6a6ed707
Reviewed-on: https://go-review.googlesource.com/c/sys/+/397774
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2022-04-05 05:20:23 +00:00
Tobias Klauser 039c03cc5b unix: add race annotations to Pread and Pwrite
Follow CL 391954 which changed Pread/Pwrite in package syscall.

For golang/go#51618

Change-Id: Icc587c61f083886bb66ca96717f686f56b398e34
Reviewed-on: https://go-review.googlesource.com/c/sys/+/392794
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-15 19:43:20 +00:00
Tobias Klauser b146bcec3b unix: remove accept on Linux
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>
2022-02-22 16:06:53 +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
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
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 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
Tom Thorogood 9665404d36 unix: support Linux NFC Subsystem
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>
2021-06-03 12:58:02 +00:00
Russ Cox 9a76102bfb all: go fmt ./...
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>
2021-02-20 05:07:31 +00:00
Tobias Klauser 73548a7a48 unix: consistently use tabs in //sys and //sysnb lines
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>
2021-02-17 08:59:31 +00:00
Elias Naur 10377860bb unix: replace blocked dup2 calls with dup3 on Android
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>
2020-05-01 05:29:02 +00:00
Sergey Ivanov e047566fdf unix: add new setfsuid/setfsgid wrappers
Added SetfsgidRetGid and SetfsuidRetUid wrappers for corresponding
syscalls, both returning previous gid or uid set.

Fixes golang/go#36649

Change-Id: I95176f4442258ca68db79cf967fbf0bbf0a57acf
Reviewed-on: https://go-review.googlesource.com/c/sys/+/215579
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-01-22 13:43:26 +00:00
Brad Fitzpatrick c1edf53553 Revert "unix: fix Setfsuid and Setfsgid return values"
This reverts commit 94506bca4f.

Reason for revert: breaking API change; I want more discussion before we do this.
 
e.g. it breaks https://github.com/search?utf8=%E2%9C%93&q=unix.Setfsuid+filename%3A*.go&type=Code&ref=advsearch&l=&l= ... like 351481c720/src/LinuxBoot/github.com/u-root/u-root/cmds/core/fusermount/fusermount_linux.go

Change-Id: I474195047f080d0b2c2178578c5f45520af96c53
Reviewed-on: https://go-review.googlesource.com/c/sys/+/215518
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-01-20 15:04:07 +00:00
Sergey Ivanov 94506bca4f unix: fix Setfsuid and Setfsgid return values
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.

Fixes golang/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>
2020-01-20 14:57:06 +00:00
andig f460065e89 unix: add Msghdr.SetIovlen
Fixes golang/go#34164

Change-Id: I77e634fafe8e573d5d2c65ddae9b0771c9f3e88f
GitHub-Last-Rev: dd25f06f86
GitHub-Pull-Request: golang/sys#42
Reviewed-on: https://go-review.googlesource.com/c/sys/+/194077
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-09-09 08:27:30 +00:00
Tobias Klauser e5ecc2a674 unix: use Renameat2 to implement Renameat on linux/riscv64
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>
2019-01-16 15:12:25 +00:00
Jason A. Donenfeld 2a47403f2a unix: always use fstatat(AT_SYMLINK_NOFOLLOW) over lstat on AMD64
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>
2018-12-10 03:00:07 +00:00
Jason A. Donenfeld b0bfa5dc15 unix: always use inotify_init1 over inotify_init on AMD64
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>
2018-12-10 02:59:51 +00:00
Tobias Klauser f81de40a84 unix: add KexecFileLoad on linux/{amd64,ppc64x,s390x}
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>
2018-10-05 13:07:39 +00:00
Tobias Klauser fc8bd948cf unix: don't use deprecated syscalls on linux/arm64
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>
2018-06-19 16:09:47 +00:00
Tobias Klauser f67ecc163a unix: use Fstatat for Stat on linux/amd64
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>
2018-04-30 07:01:21 +00:00
Jason A. Donenfeld cbbc999da3 unix: use pselect on amd64 to satisfy Android
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>
2018-04-27 15:18:31 +00:00
Tobias Klauser 4ff8c001ce unix: add Fstatat on Linux for all GOOSes
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.

Fixes golang/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>
2017-11-24 17:10:47 +00:00
Tobias Klauser e825973668 unix: unify NsecToTime{spec,val}, fix for times < 1970
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>
2017-10-25 08:56:33 +00:00
Tobias Klauser a1a1f1746d unix: unify TimespecToNsec and TimevalToNsec
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>
2017-10-23 17:51:51 +00:00
Joe Richey joerichey@google.com a45f55524b unix: defer Getpagesize() to runtime
In general, page size is not a function of the archetecture. This was
addressed in the Go standard library here:
https://go-review.googlesource.com/25051

This change simply defers to the standard library "syscall" package,
which in turn defers to the runtime. This helps in addressing golang/go#10180 and
also fixes a bug on ppc64.

Currently, we return 65536 as the page size on ppc64, but the kernel
supports 4k and 64k sizes, see here:
http://elixir.free-electrons.com/linux/v4.13/source/arch/powerpc/include/asm/page.h#L24

Now that various page size calculations are not needed, various
components are now dead code and can also be removed. This CL reverts:
https://go-review.googlesource.com/14483
and part of:
https://go-review.googlesource.com/30755

Change-Id: I9d7a2d96359054e0dca9c985b026c8072b2eeaf3
Reviewed-on: https://go-review.googlesource.com/62111
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-07 22:11:50 +00:00
Samuel Tan d75a526598 x/sys/unix: move gccgo redeclared functions to separate files
These functions are redeclared in gccgo builds, so move them
to separate files with the "!gccgo" build constraint.

Fixes golang/go#18312

Change-Id: I868cfb77fc394e5e96cee78af0f3abf43db6082a
Reviewed-on: https://go-review.googlesource.com/34379
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-12-14 19:05:18 +00:00
kortschak 5a8c7f28c1 unix: add Ppoll support for linux
Use a shim for Poll on arm64.

Fixes golang/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>
2016-06-14 16:43:59 +00:00
Riku Voipio f64b50fbea unix: fix Pause on linux-arm64
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>
2016-04-15 13:58:44 +00:00
Riku Voipio 324e137580 unix: fix EpollWait for arm64
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>
2016-04-13 20:47:32 +00:00
Brad Fitzpatrick afce3de575 unix: make TimevalToNsec available everywhere
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.

Fixes golang/go#14643

Change-Id: Ie7ae861b581b539178de26f15ba3f4bdd0e9b785
Reviewed-on: https://go-review.googlesource.com/21013
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-22 23:22:43 +00:00
Hiroshi Ioka 7e44b69d78 x/sys/unix: fix invalid syscall on linux/arm
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>
2016-02-28 22:21:53 +00:00
Shenghou Ma 379497e3ff unix: add explicit build tags
Change-Id: I62774b8ee0c1a7cc1a3b7009ca860e3fd64a6564
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/10182
Reviewed-by: Rob Pike <r@golang.org>
2015-05-18 19:15:57 +00:00
Ian Lance Taylor 04f0f96bfa unix: move InotifyInit into GOARCH specific Linux files
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>
2015-05-13 22:15:23 +00:00
Ian Lance Taylor 44366790d7 unix: correct code for cover cmd
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>
2015-05-13 22:08:58 +00:00
Ian Lance Taylor b10968a446 unix: split Pipe/Pipe2/Dup2, use *at replacement calls
This brings over three CLs from the main syscall package:
http://golang.org/cl/5833
http://golang.org/cl/5835
http://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>
2015-05-13 21:31:04 +00:00
Shenghou Ma ea75526483 unix: fix build for linux/386 and linux/arm
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.

Fixes golang/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>
2015-03-31 06:30:55 +00:00
Rob Pike dc3c21c62b go.sys/unix: use syscall.Errno for errors
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
2014-08-15 09:57:24 -07:00
Rob Pike 8442dd2c63 go.sys: update package names
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
2014-08-11 15:58:26 -07:00
Rob Pike 20acc5cf31 go.sys: copy files from syscall package to go.sys/{plan9,windows,unix}
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
2014-08-11 14:48:46 -07:00