This commit adds linux/s390x support to the unix package. It is
based on the changes made to the syscall package in
https://golang.org/cl/20961/. It also adds mkpost.go which is
used to cleanup the API generated by cgo -godefs.
The biggest departure that is made with the syscall package is
the use of the -fsigned-char flag to force signed chars. We
couldn't do this in the syscall package because of the need to
maintain compatibility with the gccgo implementation of the syscall
package (gccgo has supported s390x for a longer time than the Go
toolchain). The unix package does not have this constraint.
Using the -fsigned-char flag makes the API look more like the one
generated on amd64 and arm64 and also more consistent with itself
(the syscall package represents chars using both int8 and uint8
types, the sys package will only ever use int8). Unfortunately it
also means that applications transitioning from the syscall package
to the unix package will see a different API on s390x which might
be confusing. I think the tradeoff is worth it though.
Change-Id: I40b90c18ed787e74ba7a2ebd004bd6bd1ba6279a
Reviewed-on: https://go-review.googlesource.com/23045
Reviewed-by: Ian Lance Taylor <iant@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>
These constants are used for fadvise() on Linux and were missing from
the ztypes_linux_*.go files.
Including the bluetooth headers is necessary so that cgo can resolve
struct sockaddr_hci.
Fixesgolang/go#15114
Change-Id: I1538b5a7b9b24f910c0520d446b2fa5bd8a09013
Reviewed-on: https://go-review.googlesource.com/21753
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Tried to generate them with mkerrors.sh by including
bluetooth/bluetooth.h, but it introduces way much more
than necessary stuff.
Change-Id: I380f66892f55dbe4cbfc76a0e3f9817f81d269b9
Reviewed-on: https://go-review.googlesource.com/21675
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
If we want new secure DLL approach to be adopted, we should make
conversion as simple as possible to explain and implement.
I think that replacing
syscall.NewLazyDLL(...) -> windows.NewLazySystemDLL(...)
is easier than
syscall.NewLazyDLL(...) -> &windows.LazyDLL{Name: ..., System: true}
So I propose we introduce convenience function NewLazySystemDLL.
$GOROOT/src/mksyscall_windows.go changes in the following CL.
Change-Id: If3432aff301c347cb355e4e837834696191b2219
Reviewed-on: https://go-review.googlesource.com/21592
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This allows linux binaries to have bazel-style dependencies on x/sys/windows.
Change-Id: I248fe62e045705f409e5d96842ed52d0764ae68f
Reviewed-on: https://go-review.googlesource.com/21081
Reviewed-by: Brad Fitzpatrick <bradfitz@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>
Since Linux 3.11, O_TMPFILE flag can be used in open syscall to create
an unnamed file in a directory. The file occupies space in the
filesystem, and can be given a name using linkat syscall. If the file is
closed without being given a name, its contents are deleted.
See the manpage open(2) in Linux for details.
Exports O_TMPFILE for Linux in 386 and amd64 (other architectures
already had it). Exports Linkat syscall and AT_SYMLINK_FOLLOW (used for
giving a name to the file) for all Linux in all architectures.
Fixesgolang/go#7830.
Change-Id: Ib82e44f405b227e227b9cbf317c2657b32e046f5
Reviewed-on: https://go-review.googlesource.com/21003
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
arm64 doesn't have a Dup2 syscall, instead Dup3 is supposed
to be used. Since Dup3 is linux-specific, provide a wrapper
to make writing portable code easier.
Updates golang/go#10235
To verify it, added a testcase for Dup and Dup2.
Change-Id: I066bb60d62b2bd64d7ba0fdfbb334ce2213c78e9
Reviewed-on: https://go-review.googlesource.com/20178
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
In commit "7e44b69 x/sys/unix: fix invalid syscall on linux/arm"
a test was added for time/utime syscall. This test exposed that
neither time/utime work on arm64, because they call the legacy
syscall "utimes". As a new architecture, arm64 doesn't implement
any legacy syscalls.
Implement by first calling utimensat, using UtimesNano as exampple.
Change-Id: Iffed410730c06ac4c8184241d16eebf08c367524
Reviewed-on: https://go-review.googlesource.com/20174
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
This system call is used to reassociate the current thread with a Linux
namespace (e.g. a network namespace or a mount namespace). This system
call is key to interacting with the primitives enabling Linux containers.
The users of this system call will most likely want to wrap their calls
with a pair of LockOSThread / UnlockOSThread calls. Here is an example
that is a reasonably close approximation of the `ns_exec' program given
as an example in `man 2 setns':
package main
import (
"log"
"os"
"os/exec"
"runtime"
"golang.org/x/sys/unix"
)
func main() {
if len(os.Args) < 3 {
log.Fatalf("%s /proc/PID/ns/FILE cmd args...", os.Args[0])
}
fd, err := unix.Open(os.Args[1], unix.O_RDONLY, 0)
if err != nil {
log.Fatalf("open: %s", err)
}
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err = unix.Setns(fd, 0); err != nil {
log.Fatalf("setns: %s", err)
}
cmd := exec.Command(os.Args[2], os.Args[3:]...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err = cmd.Run()
if err != nil {
log.Fatalf("exec: %s", err)
}
}
Fixesgolang/go#5968.
Change-Id: I78dc54667cfaef4f9e99a08d48f6e423686f1b22
Reviewed-on: https://go-review.googlesource.com/20054
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
OpenBSD (and likely NetBSD, but it's not enabled for these tests
anyway) use a different sysctl API for fetching process information
than FreeBSD and its derivatives.
Change-Id: Id2ab10f170b788ba4d9bd45d3347f530555da23b
Reviewed-on: https://go-review.googlesource.com/19232
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
The flags parameter was added in https://golang.org/cl/7917. In that CL
the reviewers discussed adding UnlinkAt and changing Unlinkat, and opted
for the latter.
Unfortunately, I then undid that in https://golang.org/cl/10032, which
was a backport of (among others) https://golang.org/cl/5837. I didn't
notice that in the syscall package 5837 removed Unlinkat with two
parameters, but the port to the x/sys/unix package removed Unlinkat with
three parameters. Argh.
This CL effectively restores 7917, by adding the parameter back.
Fixesgolang/go#9923.
Change-Id: I8fe218ac637d0eb0346b63b596666671374bd19f
Reviewed-on: https://go-review.googlesource.com/18981
Reviewed-by: Rob Pike <r@golang.org>
- types_linux.go: Use the kernel-defined termios structure, *not* the
LIBC-defined one. The LIBC termios structure cannot be safely used
to do tty-related ioctls on all architectures (e.g. ppc64,
ppc64le). The kernel termios structure, and the associated
macros/constants, are defined in: "asm/termbits.h" which is included
by "linux/termios.h". The LIBC termios structure is defined in
"bits/termios.h" which is included by "termios.h". These structures
are *not* the same.
For systems that have both "struct termios" and "struct termios2"
use the latter to define the Termios type. This is ok, since the
"struct termios2" memory layout is compatible with "struct termios"
(with a couple of fields added at the end). This way, type Termios
can be used with both: the "old-style" TCSETS[FW], TCGETS ioctls,
*and* with the new TCSETS[FW]2, TCGETS2 ioctls. The new ioctls allow
configuring arbitrary baudrates.
The new Termios definitions (kernel-compatible) have the same fields
as the old ones (LIBC-derived) so there should be no user-code
compatibility issues.
Change-Id: I3c1484c60f45b28e13404765c01616c33063afd5
Reviewed-on: https://go-review.googlesource.com/17185
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
- mkerrors.sh: Included several termios-related constants that were
missing. Also included definitions of tty-related ioctl numbers for
linux.
- zerrors_linux_*: the files have been generated using
"./mkerrors.sh". After their automatic generation the files have
been manually edited to remove changes that were not due to this
patch.
Change-Id: I0463112542a5c1c41583007003b652375f9ce572
Reviewed-on: https://go-review.googlesource.com/17184
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Add support for optional sysctl arguments which is required to support
sysctls that require more than the mib identifer args as returned from
nametomib such as kern.proc.pid.
Add SysctlUint64 which allows sysctls that return 64 bit ints to be
queried.
Add SysctlRaw which allows sysctls that return structs or other
unsupported types to be queried.
Change-Id: If0fa23935ee09496f2df210364d8988ccd0f3db6
Reviewed-on: https://go-review.googlesource.com/14955
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Update the generated types and errors for FreeBSD by running mkall.sh
and ensuring no values where removed.
Change-Id: I5b82b1896b64f1b33d569dcaa477bb88641dfa8d
Reviewed-on: https://go-review.googlesource.com/15011
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Clang is much more common now so use the OS cc instead of forcing gcc
by default.
Change-Id: I1dd34c7ba56c91794ee57042dd8ac024fdd649d8
Reviewed-on: https://go-review.googlesource.com/15010
Reviewed-by: Rob Pike <r@golang.org>
The existing code has no way to manipulate termios or winsize structures
on solaris. This change adds IoctlGetXXX and IoctlSetXXX functions for
int, termios, termio, and winsize. The embedded awk script in
mkerrors.sh has additional patterns to generate the needed ioctl
constants for these calls.
Fixesgolang/go#12574
Change-Id: Ic62a8c698d42c8ca379c90f71e9f27635e7d03b5
Reviewed-on: https://go-review.googlesource.com/14587
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Various syscalls offered by x/sys/unix on Linux are not available on
Solaris and should be, such as Mkfifo, Getwd(), Futimes() and others.
In particular, all of the *at() variants of existing functions were
added where appropriate.
Getgroups() was fixed to use the correct value for its sanity check on
the maximum number of groups.
Utimesnano() was updated to use the native Solaris utimensat function
for setting nanosecond-precision time.
Utimes() was updated to have the same error semantics and checking as
other platforms.
Getgroups(), anysocktoaddr(), and Recvmsg() were fixed to check the
return value before assuming syscall failure instead of relying solely
on errno being set.
mksyscall_solaris.pl needed some updates to better match the output of
the one found in syscall.
mkerrors.sh needed some updates to work out of the box on Solaris,
matching those recently done to the one in syscall.
The signatures (names) of some function parameters were changed to be
consistent with other platforms for the sake of documentation.
Fixes#8609
Change-Id: I9e4e2fee6d3ecfad9f4d845a5702ffde5166e804
Reviewed-on: https://go-review.googlesource.com/14643
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
In preparation for issues such as #10180, Getpagesize() needs to be
fixed to return the actual system's page size instead of assuming it's
always 4096.
This is particularly important for future platform support on Solaris.
Fixes#12076
Change-Id: I78205165909529215fe93ed6ba56e9c3ee1c2abb
Reviewed-on: https://go-review.googlesource.com/14483
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
These are already exposed on Linux. I believe they were left out of
darwin because fchmodat didn't exist on older versions of XNU.
Change-Id: I166f2b23270937c1b6cc3bd73e7f7b72d2d488e9
Reviewed-on: https://go-review.googlesource.com/14092
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This makes the script resistant to changes in the SDK location, which
apparently happens from time to time.
While I was at it, made another cosmetic touch-up: use a .gitignore file
to stop `git status` from showing the _obj/ directory generated by
mkall.sh.
Change-Id: Ia706114d94e324ab443f6f5d6aa7c0c9f8a84620
Reviewed-on: https://go-review.googlesource.com/14192
Reviewed-by: Ian Lance Taylor <iant@golang.org>
I did this on OS X 10.10.5 (14F27) using the OS X 10.10 SDK included in
Xcode 6.4 (6E35b) for syscall numbers. I believe this SDK is intended
for 64-bit Macs, but the syscall numbers aren't likely to vary. See also
the discussion in this thread:
https://groups.google.com/d/topic/golang-dev/738LXeykFsM/discussion
This commit contains the same SYS_SYSCTL -> SYS___SYSCTL workaround
found in commit 9ef4b6c; see its description for more info.
Change-Id: I952ae56032033b49f8910281c68dcc72abb2d106
Reviewed-on: https://go-review.googlesource.com/14151
Reviewed-by: Ian Lance Taylor <iant@golang.org>
I did this on OS X 10.10.5 (14F27) using the iOS SDK included in Xcode
6.4 (6E35b). This commit contains the same SYS_SYSCTL -> SYS___SYSCTL
workaround found in commit 9ef4b6c; see its description for more info.
Change-Id: I4dddc2a6d030ce297ee711f4430ec9db3abcda50
Reviewed-on: https://go-review.googlesource.com/14094
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>