Commit Graph

25 Commits

Author SHA1 Message Date
Tobias Klauser
88d2dcc510 unix: add IFLA_* constants for Linux 4.15
Add all IFLA_* constants defined in linux/if_link.h as of Linux kernel
version 4.15.

Change-Id: Ib27205cf560f40303ca9500abe73abf833fc13a8
Reviewed-on: https://go-review.googlesource.com/96595
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-23 16:57:47 +00:00
Tobias Klauser
c1138c84af unix: update to Linux 4.15, glibc 2.27 and Go 1.10
Also use the Ubuntu 17.10 docker image and additionally install bison
which is needed by the glibc build.

The resulting change only consists of a few additional constants.
Exclude the X86_CR3_PCID_NOFLUSH constant on 386 and amd64, though.

Change-Id: I0a9b8959146273ff3b259c17bb616625a9ac8278
Reviewed-on: https://go-review.googlesource.com/96255
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-02-22 21:03:05 +00:00
Garret Kelly
ef802241c9 unix: add sockaddr_l2 definitions
The sockaddr_l2 address type is used with AF_BLUETOOTH sockets using the
BTPROTO_L2CAP protocol.

Change-Id: I263cfd3bb5920a8c1187ead6c2e0527276575d9f
Reviewed-on: https://go-review.googlesource.com/89475
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-01-25 08:08:17 +00:00
Tobias Klauser
fff93fa7cd unix: add Statx on Linux
statx(2) allows to get enhanced file status information (not currently
available through the existing stat syscalls), lightweight stat,
heavyweight stat. The Statx_t type used by Statx has consistent field
sizes on all arches (with year-2038-capable timestamps) and is closer to
the BSD implementation of Stat_t.

See http://man7.org/linux/man-pages/man2/statx.2.html for details. The
syscall was added in Linux kernel 4.11.

See https://github.com/tklauser/statx for an example of how this
function and types can be used to report stat(1)-like file status
information.

Change-Id: I9e9642b5b42a393f94fd532453888ce9ba4f0003
Reviewed-on: https://go-review.googlesource.com/87555
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-01-15 08:58:44 +00:00
Matt Layher
b9cf5f96b6 unix: add cgroupstats type and constants
The cgroupstats structure is available via Linux's generic netlink
taskstats interface.

For more information, please see:
https://www.kernel.org/doc/Documentation/accounting/cgroupstats.txt.

Fixes golang/go#23388.

Change-Id: I8a05a3875209e99a427d54049eacc98f415e44cf
Reviewed-on: https://go-review.googlesource.com/86975
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2018-01-09 18:07:26 +00:00
Tobias Klauser
12d9d5b281 unix: add SchedGetaffinity and SchedSetaffinity on Linux
SchedGetaffinity and SchedSetaffinity are used to get and set a thread's
CPU affinity mask.

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

Also add a manual implementation of CpuSet_t and the corresponding
accessor functions (mimicking the CPU_* macros from sched.h).

Fixes golang/go#11243

Change-Id: Ia5abc0053cd06810b3b09ab65c27434f5323c1ad
Reviewed-on: https://go-review.googlesource.com/85915
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-01-05 20:31:47 +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
52c393dd0c unix: update Dockerfile to go 1.9.2
Update go to 1.9.2 in the Dockerfile used to generate the Linux go files.

The update also changes some zerror definitions: RLIM_INFINITY is
assigned to Rlimit.{Cur,Max} which are both uint64 on all architectures.
PR_SET_PTRACER_ANY is used with Prctl which expects an uintptr.

With the current version, an "constant -1 overflows uint64" error would
result if these constants were used directly without type conversion.

Change-Id: Iefd23a44e983b4fcf210121776531df225014112
Reviewed-on: https://go-review.googlesource.com/73873
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-27 13:58:47 +00:00
Tobias Klauser
833991df06 unix: omit success message if generation of ptrace definition fails
If generating ptrace definitions for a particular pair fails for any
reason, a success message would still be shown. Avoid it in case there
was a failure.

Change-Id: Ica59c888586c055e8ef333a0db00bde2c4d15145
Reviewed-on: https://go-review.googlesource.com/73874
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-27 13:58:17 +00:00
Tobias Klauser
30ef8ff723 unix: single space after period in generated zptrace header
Fix the header in the generated zptrace*_linux.go files to consistently
use single space after a period.

Change-Id: I527f27a68e14bc103639b1dd5734ec06ae267e01
Reviewed-on: https://go-review.googlesource.com/73875
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-27 12:34:53 +00:00
Ian Lance Taylor
3e3646d2c7 unix: add ptrace definitions for compatible GOARCH pairs
For pairs of GOARCH values that can execute each other's binaries on
the same system, such as 386 and amd64, add the definitions and
functions required to fetch and set registers when debugging either
variant.

Fixes golang/go#9739

Change-Id: I7896ddef7d341ffaee56614ebd080dc38c708ed4
Reviewed-on: https://go-review.googlesource.com/73555
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2017-10-26 07:26:40 +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
Joe Richey joerichey@google.com
31e1fafe95 unix: update Linux to v4.13 kernel and v2.26 glibc
This change updates the Linux symbols to correspond to v4.13 of the
kernel and v2.26 of glibc. To get everything building correctly, newer
versions of the build tools are required. Instead of trying to get an
Ubuntu 17.10 docker image working, we just add Artful sources to
/etc/apt/sources.list to get a similar effect.

Now that the kernel UAPI is updated, FS_MAX_KEY_SIZE and fscrypt_key no
longer need to be manually declared, as they are now in the proper
kernel headers.

Change-Id: I5f14c99fd70b43dbb8b44e05f53e4e9f09c9a345
Reviewed-on: https://go-review.googlesource.com/61771
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-07 22:07:22 +00:00
Matt Layher
ab9e364efd unix: add generic netlink types and constants on Linux
Generic netlink is a generalized netlink family which enables a series
of different communication channels to be multiplexed on a single
netlink family.

For more information, please see: https://lwn.net/Articles/208755/.

Fixes golang/go#21682.

Change-Id: I2095150e06471f4a0e1322fba669573aa8f0a9b1
Reviewed-on: https://go-review.googlesource.com/59931
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-29 18:59:17 +00:00
Matt Layher
2d6f6f883a unix: add taskstats enum values
I falsely assumed that enum values would be generated automatically,
but now realize that the previous values I added were actually generated
from preprocessor define statements.

This change adds some missing values I intended to add in CL 59050.

Fixes golang/go#21623.

Change-Id: I3c40c8454ee1d323e1e4e014febe0874e859a378
Reviewed-on: https://go-review.googlesource.com/59090
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-25 19:46:20 +00:00
Matt Layher
22e23b7432 unix: add taskstats type and constants on Linux
Taskstats is a netlink-based interface for sending per-task and
per-process statistics from the kernel to userspace.

For more information, please see:
https://www.kernel.org/doc/Documentation/accounting/taskstats.txt.

Fixes golang/go#21616.

Change-Id: I7d4b8035aa8e993074d61911d9a8c3a3e61c9b2e
Reviewed-on: https://go-review.googlesource.com/59050
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-25 17:12:00 +00:00
Matt Layher
7716a567fb unix: add PacketMreq on Linux
The packet_mreq structure is used on Linux to modify the behavior
of packet sockets using setsockopt.  See 'man 7 packet' for more
details.

Change-Id: I34e5b99a6b6eb1f23d49a9c9f25ce7b77121c8f0
Reviewed-on: https://go-review.googlesource.com/51710
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-28 16:07:29 +00:00
Tobias Klauser
515fc15b65 unix: add missing SizeofIovec constant on Linux
Add the SizeofIovec constant corresponding to type Iovec.

Change-Id: Icde241b8cac3bc89806f0081a4021598bf0ef7cf
Reviewed-on: https://go-review.googlesource.com/51730
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-07-28 15:34:37 +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
739734461d unix: add perf event ioctl constants on Linux
Add the PERF_EVENT_IOC_* constants on Linux which are used to
enable/disable/configure perf events. Also add the PERF_IOC_FLAG_GROUP
constant which might be using as part of the ioct argument. See section
"perf_event ioctl calls" in
http://man7.org/linux/man-pages/man2/perf_event_open.2.html

Change-Id: I92fb8f6ef5cc53711f00db566d8e277cdf1cd607
Reviewed-on: https://go-review.googlesource.com/47770
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-07-07 16:14:08 +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
James Cowgill
156c5a2da4 unix: use struct pt_regs for PtraceRegs on mips
On mips, "struct user" bears no relation to the actual structure used by
PTRACE_GETREGS. The real structure is "struct pt_regs" which is declared
in asm/ptrace.h

Fixes golang/go#20338.

Change-Id: I604d27bd2b0a0903784380cbd3fa2fd9b9811fa5
Reviewed-on: https://go-review.googlesource.com/43431
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-12 16:47:49 +00:00
joerichey@google.com
8c0a5eacba unix: add support for Linux filesystem encryption
This CL adds in the necessary types and constants to support Linux
filesystem encryption. This includes the structs for the keys and
polices as well as the constants for key size and encryption algorithms.

This code also reduces the scope of some of the regexes in mkerrors.sh.
This is to reduce the number of unrelated constants added in with this
change.

Note that due to a bug in the Linux uapi headers, not all of the
necessary constants and structures are declared in linux/fs.h despite
being part of the kernel ABI. This means that some constants and types
had to be manually added in.

The bug has been patched (https://patchwork.kernel.org/patch/9662723),
and the manual additions can be removed when the patch is merged into
the mainline kernel.

Change-Id: Ib508ad99bdf4c0068933ffcf351c52bb359cfcf4
Reviewed-on: https://go-review.googlesource.com/41417
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-24 22:03:05 +00:00
Joe Richey
ea9bcade75 unix: generate all Linux go files from source
Right now the process for adding in new constants, errors, or syscalls
for Linux is a pain and unreliable. The scripts are designed to be run
on the target architecture and use the header files installed on the
user's system. This makes it hard to generate files for all the
architectures or to have consistency between users. See golang/go#15282.

This CL fixes this issue by making all of the files for the 11 supported
architectures directly from source checkouts of Linux, glibc, and bluez.
This is done using Docker, the gcc cross-compilers, and qemu emulation.
Previously discussed here:
    https://go-review.googlesource.com/c/37589/

A README.md file is also added to explain how all the parts of the build
system work.

In order to get the build working for all the architectures, I made
some changes to the other scripts called from mkall_linux.go:
  - Files only used for generating linux code, moved to linux/
  - linux/mksysnum.pl supports a specified CC compiler.
  - The generated C code in mkerrors.sh changed to avoid a warning
  - mkerrors.sh headers changed to fix powerpc64 bug in sys/ioctl.h
  - linux/types.go no longer needs to export Ptrace structs in lowercase

Build instructions:
  - Host system needs to be x86-64 Linux
  - Install Docker (https://docs.docker.com/engine/installation/)
  - ./mkall.sh (That's it!!!)

Change-Id: I87067c14442ba12f8d51991349a43a9d73f38ae0
Reviewed-on: https://go-review.googlesource.com/37943
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-21 00:52:44 +00:00