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

56 Коммитов

Автор SHA1 Сообщение Дата
Christopher Koch 164713f0df unix: remove unnecessary use of unsafe.Pointer.
Change-Id: I7ae67ce410ae2816c2f3e8ecb26e46265aa11d7f
Reviewed-on: https://go-review.googlesource.com/73771
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-26 20:47:33 +00:00
Tobias Klauser 9e4fff1f4d all: single space after period
Follow CL 20022 and consistently use single space after a period in
documentation.

Generated with:

$ perl -i -npe 's,^(\s*// .+[a-z]\.)  +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.)  +([A-Z])')

Change-Id: Ia29ad823668f060e81293e848a79fc4b4857d94b
Reviewed-on: https://go-review.googlesource.com/73530
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-25 20:39:07 +00:00
Tobias Klauser 686000749e unix: correct type for timeout argument to Select on linux/{arm64,mips64x}
Follow CL 70590 which did the same for syscall.

unix.Select uses SYS_PSELECT6 on arm64 and mipx64x, however this
syscall expects its 5th argument to be of type Timespec (with seconds
and nanoseconds) instead of type Timeval (with seconds and microseconds)
This leads to the timeout being too short by a factor of 1000.

This CL fixes this by adjusting the timeout argument accordingly,
similarly to how glibc does it for architectures where neither
SYS_SELECT nor SYS__NEWSELECT are available. It also makes Pselect
generaly available on linux.

Updates golang/go#22246

Change-Id: I69f8821a40c59ee469b8a986d784a4db8727ee9a
Reviewed-on: https://go-review.googlesource.com/70610
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-13 13:55:06 +00:00
Luca Bruno bb24a47a89 unix: drop dummy byte for oob in unixgram SendmsgN
This commit relaxes SendmsgN behavior of introducing a dummy 1-byte
payload when sending ancillary-only messages.
The fake payload is not needed for SOCK_DGRAM type sockets, and actually
breaks interoperability with other fd-passing software (journald is one
known example). This introduces an additional check to avoid injecting
dummy payload in such case.

Backport of https://go.googlesource.com/go/+/93da0b6e66f24c4c307e0df37ceb102a33306174
Full reference at https:/golang.org/issue/6476#issue-51285243

Change-Id: I7cf00a1c7cde75fe62e00b98ccba6ac8469b0493
Reviewed-on: https://go-review.googlesource.com/60190
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-30 13:42:02 +00:00
Tobias Klauser 43e60d72a8 unix: unify memory functions on BSD
Make Madvice, Mlock, Mlockall, Mprotect, Msync, Munlock and Munlockall
available equally on all BSD flavors. NetBSD was previously lacking
SYS_MSYNC, so add it.

Reorder the //sys function prototype alphabetically and clean up already
implemented syscalls everywhere.

Also add tests for Mprotect, Msync and Madvice - now that they're
available on all unix platforms.

Fixes golang/go#18513

Change-Id: I0eb502d72c7e991f191fb96225ef04e8297d8b8d
Reviewed-on: https://go-review.googlesource.com/56172
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-17 23:46:08 +00:00
Kirill Smelkov 35ef4487ce unix: add Syncfs function on Linux
Syncfs is Linux-specific system call to synchronize to disk one
filesystem specified by fd to any of its files.

See http://man7.org/linux/man-pages/man2/syncfs.2.html for details.

Change-Id: Ia2ad6208c3fa0e9c40d5112ce938edd5d374131d
Reviewed-on: https://go-review.googlesource.com/51510
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-07-27 13:53:23 +00:00
Tobias Klauser d6d53c0e54 unix: add Msync function on Linux
Add the Msync function on Linux. See
http://man7.org/linux/man-pages/man2/msync.2.html

Updates golang/go#8245

Change-Id: I964259bafc8d4fbca09961443f21c4278bf56706
Reviewed-on: https://go-review.googlesource.com/50891
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-07-25 13:53:26 +00:00
Tobias Klauser cd2c276457 unix: add ioctl functions to get/set terminal window size on Linux
Add IoctlGetWinsize and IoctlSetWinsize to retreive and manipulate
Winsize structures on Linux, akin to the already existing implementation
on Solaris.

Also remove the named result parameter for IoctlSetInt and
IoctlSetTermios, as they add no additional use.

Change-Id: Id349d1d6a21d5c9a05943f4dcc3a275613ccf7b8
Reviewed-on: https://go-review.googlesource.com/49231
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-18 16:13:35 +00:00
Tobias Klauser 4cd6d1a821 unix: add Mkfifoat function on Linux
Add the Mkfifoat function on Linux, akin to the existing Mkfifo function
but taking an additional dirfd parameter. See
http://man7.org/linux/man-pages/man3/mkfifo.3.html

Originally requested in golang/go#14216

Also remove the named result parameter for Mkfifo, as they add no
additional use (suggested by Brad Fitzpatrick).

Change-Id: I7b759752abf3e1469d7f883a7f13313e3062aeb4
Reviewed-on: https://go-review.googlesource.com/48530
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-14 16:04:39 +00:00
Tobias Klauser 4ed4d404df unix: add ioctl functions for termios on Linux
Add IoctlGetTermios and IoctlGetTermios to retreive and manipulate
Termios structures on Linux, akin to the already existing implementation
or Solaris.

If desired, functions conforming to POSIX tcgetattr/tcsetattr could be
implemented on top of these.

Change-Id: I2a71061bad2e632c597b6f6184ad6374c46a43ee
Reviewed-on: https://go-review.googlesource.com/47330
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-30 17:12:05 +00:00
Tobias Klauser c23410a886 unix: check Fchmodat flags parameter on Linux
Currently Linux' fchmodat(2) syscall implementation doesn't support the
flags parameter (though it might in future versions [1]). Fchmodat in
x/sys/unix takes the parameter and (wrongly) passes it on to the syscall
which will ignore it.

According to the POSIX.1-2008 manual page [2], AT_SYMLINK_NOFOLLOW is
the only valid value for the flags parameter and EOPNOTSUPP should be
returned in case changing the mode of a symbolic link is not supported
by the underlying system.  EINVAL should be returned for any other value
of the flags parameter.

  [1] https://patchwork.kernel.org/patch/9596301/
  [2] http://pubs.opengroup.org/onlinepubs/9699919799/functions/chmod.html

Change the Fchmodat implementation accordingly and also add the
corresponding test.

Fixes golang/go#20130

Change-Id: I62e677e6674d3702eaf388af0ac3d7e623a35c24
Reviewed-on: https://go-review.googlesource.com/46474
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-23 14:22:15 +00:00
Tobias Klauser 0b25a408a5 unix: add Eventfd function on Linux
Add support for the eventfd2 syscall on Linux.

Use the eventfd2 syscall instead of eventfd, as the latter does not
provide a flags argument and glibc also maps its eventfd() function to
the eventfd2 syscall, see the Notes section in
http://man7.org/linux/man-pages/man2/eventfd.2.html

Also add the corresponding flags values EFD_CLOEXEC, EFD_NONBLOCK and
EFD_SEMAPHORE.

Change-Id: Ia8c99e68d5966ab5c7ebe7e45423943fd7d8214e
Reviewed-on: https://go-review.googlesource.com/45093
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-08 16:48:03 +00:00
Tobias Klauser b90f89a1e7 unix: add missing xattr symlink syscall functions on Linux
Add support for the lgetxattr, llistxattr, lremovexattr and lsetxattr on
Linux, akin to the already existing getxattr, listxattr, removexattr and
setxattr syscalls.

These variants are identical to the already existing variants. except in
the case of a symbolic link where the extended attribute operation is
applied to the link itself rather than to the file that it refers to.
See:

  http://man7.org/linux/man-pages/man2/getxattr.2.html
  http://man7.org/linux/man-pages/man2/listxattr.2.html
  http://man7.org/linux/man-pages/man2/removexattr.2.html
  http://man7.org/linux/man-pages/man2/setxattr.2.html

Fixes golang/go#14116

Change-Id: I786953db8bf862566f54bdd745cc1feca5031be7
Reviewed-on: https://go-review.googlesource.com/44374
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-29 18:51:10 +00:00
Matt Layher a55a760868 unix: add IoctlGetInt and IoctlSetInt on Linux
This CL adds basic integer get/set functions which wrap a generic
ioctl call.  The API is similar the one introduced for solaris/amd64
in CL 14587, but the request parameter has been changed to a uint
instead of an int.  This makes requests with a number larger than the
maximum signed 32-bit integer work on linux/386.

For consistency, the solaris/amd64 API has also been updated to make
use of a uint instead of an int for the request number.

Fixes golang/go#20474

Change-Id: Iaae1ee2e4bb4bfcc420dcec252fe53c8d90ce81d
Reviewed-on: https://go-review.googlesource.com/44009
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-24 19:12:47 +00:00
Joe Richey joerichey@google.com a2e06a18b0 unix: add bindings for keyutils syscalls
This CL adds support for the ADD_KEY, REQUESET_KEY, and KEYCTL syscalls.
These syscalls allow access to the kernel keyring facilities. In C code,
these syscalls are wrapped by the libkeyutils package. See:
	http://man7.org/linux/man-pages/man7/keyutils.7.html

The ADD_KEY and REQUEST_KEY calls are fairly straightforward, but the
KEYCTL syscall is a multiplexor for a number of key management
functions. See:
	http://man7.org/linux/man-pages/man3/keyctl.3.html

The Go bindings for the KEYCTL functions attempt to replicate what
libkeyutils does. This is done via generated helper functions.

Change-Id: If8c97d4ef5bce14c43dee3e6772ded42dc3c595a
Reviewed-on: https://go-review.googlesource.com/41415
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-18 22:39:15 +00:00
Derek McGowan f845067cf7 unix: add Linux CopyFileRange syscall
Introduces the CopyFileRange syscall which first appears in Linux 4.5.
Allows copying file content between file descriptors within the kernel
without transferring data to user space. This syscall also allows the
kernel to take advantage of reflinking or other fast copy methods on
supported file systems.
http://man7.org/linux/man-pages/man2/copy_file_range.2.html

Change-Id: Id365f1e5d4d5ddf7159478e3a13084c9576ebd5c
Reviewed-on: https://go-review.googlesource.com/39992
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-12 18:10:32 +00:00
Chris Manghane 493114f682 unix: add GetsockoptTCPInfo
Change-Id: I190098a4a969a706c555e48d2ad938d41017601e
Reviewed-on: https://go-review.googlesource.com/39195
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-03 20:51:32 +00:00
Koki Ide 9a7256cb28 unix: validate ParseDirent inputs
This is a copy of https://golang.org/cl/23780 for the x/sys repo.

Don't panic, crash, or return references to uninitialized memory when 
ParseDirent is passed invalid input.

Updates golang/go#15653
Fixes golang/go#19754

Change-Id: Idb7cffe14d48ed662e5a55ecb5249c1907cf4003
Reviewed-on: https://go-review.googlesource.com/38758
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-29 06:16:34 +00:00
Agis Anastasopoulos afadfcc777 unix: add PtracePeekUser
Fixes golang/go#14459

Change-Id: I9809340141dd5704d5a32a079486a1f889725541
Reviewed-on: https://go-review.googlesource.com/38638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-25 17:05:18 +00:00
Matt Layher 99f16d856c unix: SockaddrVM uses "context ID" terminology instead of "client ID"
"When the client creates a connection, instead of providing an IP address
to choose its server, the client must provide the context ID (CID) of a
virtual machine or host."
Reference:
https://pubs.vmware.com/vsphere-60/topic/com.vmware.ICbase/PDF/ws9_esx60_vmci_sockets.pdf

Change-Id: Ia2dfe015594e0ca43a3c8acec1f43d418f5781af
Reviewed-on: https://go-review.googlesource.com/37864
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-03-08 15:33:27 +00:00
Matt Layher d67a3279ae unix: implement Linux AF_VSOCK sockets
Adds the required constants and new SockaddrVM type for working
with Linux VM sockets.  For more information, see:
https://vmsplice.net/~stefan/stefanha-kvm-forum-2015.pdf.

Fixes golang/go#19434

Change-Id: I9aefb35441b2c7dc412bdfb806ebe08d5c20f6b1
Reviewed-on: https://go-review.googlesource.com/37937
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-03-08 01:50:38 +00:00
Joe Richey 76cc09b634 unix: add Getrandom syscall bindings and flags
This CL introduces the Getrandom syscall. Allowing users of
sufficiently new kernels (3.17) to detect when the operating system
lacks enough entropy to generate cryptographic random data. See:
http://man7.org/linux/man-pages/man2/getrandom.2.html

As we have updated the syscall numbers, the Getrandom function can
just be generated normally. The only other change is to mkerrors.sh
to include the GRND_* flags for getrandom from <linux/random.h>.

It is important to note that currently the mkerrors.sh script cannot
actually be run as it has fallen behind the 4.10 kernel. The GRND_*
flags were added manually.

This was originally part of a larger commit that was split up.
See CL: https://go-review.googlesource.com/37570

Change-Id: I464088a9c9f7224abdcdae476b30a4f2f412d9f5
Reviewed-on: https://go-review.googlesource.com/37589
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-01 01:59:58 +00:00
Matt Layher 075e574b89 unix: implement Vmsplice, add SPLICE_F_* constants
Fixes golang/go#19125

Change-Id: I822b6f260f980178da29a552c6170cb261c8e254
Reviewed-on: https://go-review.googlesource.com/37152
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-02-17 00:34:42 +00:00
Matt Layher e24f485414 unix: add support for AF_ALG sockets on Linux
Fixes golang/go#19033.

Change-Id: Icbd249f63cd4a9035a1decaa8bf4c521303b4494
Reviewed-on: https://go-review.googlesource.com/36805
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-02-13 22:57:39 +00:00
Elliot Morrison-Reed 30237cf4ee x/sys/unix: added SockaddrCAN struct to allow creation of AF_CAN sockets
Fixes golang/go#16188

Change-Id: I396ccbf6ce14147bc03ecdf180c2657c22b477b4
Reviewed-on: https://go-review.googlesource.com/33392
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-22 21:48:34 +00:00
Alexander Menzhinsky b699b70325 x/sys/unix: add Getsid on linux
Fixes golang/go#17872

Change-Id: I4bfe7b47c36c3d2f0c08a2adeba595231e507b81
Reviewed-on: https://go-review.googlesource.com/33050
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-10 16:12:52 +00:00
Ian Lance Taylor 9a2e24c373 unix: fix name of prlimit parameters
Update golang/go#17606.

Change-Id: I922525561d81a8b7d805729028825953424f6ecc
Reviewed-on: https://go-review.googlesource.com/32912
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-11-08 15:13:28 +00:00
Hiroshi Ioka 9bb9f0998d x/sys/unix: add *linkat functions on linux
* expose readlinkat, symlinkat

Fixes golang/go#14459

Change-Id: I8dc87401bb1025c2404e7304ecc4561edd67a452
Reviewed-on: https://go-review.googlesource.com/30890
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-12 00:19:20 +00:00
James Clarke 67f277b6fe unix: Added linux/sparc64 gccgo support
Change-Id: Iff763334a2efbd44af68048d1de700af7d271647
Reviewed-on: https://go-review.googlesource.com/30755
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-11 00:35:16 +00:00
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
Tzu-Jung Lee a80ff226bd unix: add sockaddr_hci support for linux.
Change-Id: Ic2eb52d4e9f7b80992707b125c11be54d7973314
Reviewed-on: https://go-review.googlesource.com/21674
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-08 05:48:20 +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
Riku Voipio 7a56174f00 x/sys/unix: fix time/utime/utimes on arm64
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>
2016-03-03 15:45:59 +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
Ian Lance Taylor eb2c74142f unix: add flags parameter to Unlinkat
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.

Fixes golang/go#9923.

Change-Id: I8fe218ac637d0eb0346b63b596666671374bd19f
Reviewed-on: https://go-review.googlesource.com/18981
Reviewed-by: Rob Pike <r@golang.org>
2016-01-27 15:07:42 +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
Rob Pike 3826714b1e x/sys/unix: allow nil on unix for all variants of Utimes
Fixes golang/go#11830.

Change-Id: Ie6e9f82d05b7c04092b6ee6117238873b746380e
Reviewed-on: https://go-review.googlesource.com/12690
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-27 05:51:57 +00:00
Matt Layher 2c41184ab0 x/sys/unix: allow nil argument slice for Utimes on Linux
Fixes golang/go#11830.

Change-Id: Ie7ffd4579a7b8143ca85a30d24acd3e2e7eece78
Reviewed-on: https://go-review.googlesource.com/12648
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-07-24 22:00:13 +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
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