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

27 Коммитов

Автор SHA1 Сообщение Дата
Brad Fitzpatrick 8d1157a435 Revert "x/sys/unix: add *linkat functions on linux"
This reverts commit I44d8dd8020bc61b9c75e0566c34ca9cc56b23f9d.

Reason for revert: Broke the build. (Fixes #17352)

Original change's description:
> x/sys/unix: add *linkat functions on linux
> 
> * expose linkat, readlinkat, symlinkat
> 
> Fixes golang/go#14459
> 
> Change-Id: I44d8dd8020bc61b9c75e0566c34ca9cc56b23f9d
> Reviewed-on: https://go-review.googlesource.com/20129
> Reviewed-by: Russ Cox <rsc@golang.org>
> 

Change-Id: Ic114a5e60b0caef82c21123156963b2a8232d9d4
Reviewed-on: https://go-review.googlesource.com/30491
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-06 02:51:42 +00:00
Hiroshi Ioka 1f5e250e11 x/sys/unix: add *linkat functions on linux
* expose linkat, readlinkat, symlinkat

Fixes golang/go#14459

Change-Id: I44d8dd8020bc61b9c75e0566c34ca9cc56b23f9d
Reviewed-on: https://go-review.googlesource.com/20129
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-06 00:30:26 +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
kortschak 7f918dd405 unix: add Poll for linux
Change-Id: I273bd852f85d204694872a1615be51dc027b97ee
Reviewed-on: https://go-review.googlesource.com/23661
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-06-11 01:26:39 +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
Caio Marcelo de Oliveira Filho 23999e87b4 x/sys/unix: add support for O_TMPFILE in Linux
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.

Fixes golang/go#7830.

Change-Id: Ib82e44f405b227e227b9cbf317c2657b32e046f5
Reviewed-on: https://go-review.googlesource.com/21003
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-22 23:15:03 +00:00
Benoit Sigoure 54535356f1 x/sys/unix: Add support for the setns system call.
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)
		}
	}

Fixes golang/go#5968.

Change-Id: I78dc54667cfaef4f9e99a08d48f6e423686f1b22
Reviewed-on: https://go-review.googlesource.com/20054
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-29 17:26:46 +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
Dave Cheney 18d75a3b5e unix: add Prctl for linux platforms
Adds Prctl syscall for linux platforms. syscall and x/sys/unix already
defined the PR_ series of constants.

See discussion: https://groups.google.com/forum/#!topic/golang-nuts/rG6xShds2Dc

Change-Id: Ida5562b46abef574a3f9ac31911142f1e8d7fb4f
Reviewed-on: https://go-review.googlesource.com/15520
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-08 03:55: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 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
Damien Neil f2654f8719 unix: add clock_gettime for Linux
Includes 386, amd64, and arm for Linux.

Change-Id: I428bfb732141448659a94dc6e2ab7a98efea507a
Reviewed-on: https://go-review.googlesource.com/9766
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-05-06 23:20:22 +00:00
Peter Waller 0a2b4af5eb unix/amd64: add Utimensat call, pass 0 for flags
This CL adds the Utimensat syscall and AT_SYMLINK_NOFOLLOW constant.

This is required for setting the access/modification times on symlinks.

In addition, it updates the UtimesNano function to pass 0 as the flags
parameter, to avoid potentially passing junk.

Change-Id: I280645f3f53173628b1e1986bc7a47bac254fcf8
Reviewed-on: https://go-review.googlesource.com/9379
Reviewed-by: Rob Pike <r@golang.org>
2015-05-05 17:43:46 +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
Brad Fitzpatrick 46ba3e7a19 unix: re-run mksyscall on freebsd and linux after previous merge
The previous cherry-pick merge of fadvice from Gerrit added the
fadvise system calls, but from before the errno CL, which went in
concurrently.

Change-Id: I6f01e020bfe2930a8ea2fdbe4998ab9e2669ce14
Reviewed-on: https://go-review.googlesource.com/8199
Reviewed-by: Rob Pike <r@golang.org>
2015-03-27 17:05:09 +00:00
Eric ea745763b1 unix: Added posix_fadvise support for Linux and FreeBSD
Support includes 386, amd64, and arm for both Linux and FreeBSD.
FreeBSD changes courtesy Dave Chapeskie <dchapeskie@gmail.com>

Change-Id: I89dc18533d7178e74ae6c442a2e6272c9bd9692c
Reviewed-on: https://go-review.googlesource.com/8055
Reviewed-by: Rob Pike <r@golang.org>
2015-03-27 16:47:22 +00:00
Brad Fitzpatrick 71c96e4240 unix: don't allocate putting common errno values in error interfaces
From main repo: https://go-review.googlesource.com/#/c/6701/3

Fixes golang/go#10266

Change-Id: I141fefe7f317edcea19b588b1569fa8772237f56
Reviewed-on: https://go-review.googlesource.com/8190
Reviewed-by: Rob Pike <r@golang.org>
2015-03-27 16:15:35 +00:00
Ian Lance Taylor 5829c74886 unix: change Dup,Dup2,Dup3 to use Syscall, not RawSyscall
This avoids hanging when a Go program uses a FUSE filesystem and the
dup system call has to close a file descriptor.  When dup uses
RawSyscall then the goroutine calling dup will occupy a scheduler slot
(a p structure) during the call, and may block waiting for some other
goroutine to respond to the close call on the FUSE filesystem.
Changing to Syscall avoids the problem.  This makes Dup a tiny bit
slower but is quite unlikely to make a difference for any real
programs.

Update golang/go#10202.

Change-Id: I590c5c9a04e0a1281a85dc553c7592fa83949ac7
Reviewed-on: https://go-review.googlesource.com/8056
Reviewed-by: Rob Pike <r@golang.org>
2015-03-26 17:59:35 +00:00
Shenghou Ma 2cb975bb60 unix: use Getpgid to emulate Getpgrp on linux
Some Linux architectures (e.g. arm64) don't have the getpgrp syscall,
use getpgid(0) to emulate it.

Update golang/go#10150.

This brings CL 8022 that has been applied to the syscall package to
x/sys.

Change-Id: I24c6d7e8b5b2f075ca4e68b142b2e03ab8a43342
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8023
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-24 20:03:14 +00:00
Dirk Gadsden bfff0ae28b unix: Add UnlinkAt on Linux with third flags argument
For golang/go#9923

Change-Id: I7562d32f1bfcc35fe86d2e5fff26845737fd9ecb
Reviewed-on: https://go-review.googlesource.com/7917
Reviewed-by: Rob Pike <r@golang.org>
2015-03-23 23:07:57 +00:00
Ian Lance Taylor 7f1554891e mksyscall.pl, types_linux.go: regenerate linux {386,amd64} files
Import syscall so that Kill can refer to syscall.Signal.  Drop
termios constants from types_linux.go--all other systems get
them from mkerrors.sh.

Fixes golang/go#8865.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/152980044
2014-10-06 12:02:17 -07:00
Rob Pike c1f6f8bcc5 go.sys/unix: use "use" in syscall interface
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/144980043
2014-09-16 13:36:53 -07: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