Create Go bindings for the updated fscrypt UAPI from Linux v5.4:
- Various new ioctls. We use the regex FS_IOC_.*ENCRYPTION to match
both the new and existing fscrypt ioctls.
- Various new structures for passing to the ioctls
- Various new constants named like FSCRYPT_*
- FscryptPolicy was renamed to FscryptPolicyV1. (But the old name is
still available for source compatibility.)
- The existing fscrypt-related constants named like FS_* (besides the
ioctls) were renamed to FSCRYPT_*. (But the old names are still
available for source compatibility.)
For reference, see fscrypt.h:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/fscrypt.h?h=v5.4Fixesgolang/go#35856
Change-Id: I48ddd37cfa7c1e0e7eb227baa6f220c848ddc880
Reviewed-on: https://go-review.googlesource.com/c/sys/+/208898
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Attempting to upgrade to the Ubuntu 19.10 Docker image results in
failures due to Ubuntu/Debian removing the mips{,64}{,le} cross
compilers, so we stick with 19.04 for now.
Change-Id: Ie75057447889ea1648d638a410e1c35c047b579a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/208737
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
For more information on devlink, see: https://lwn.net/Articles/674867/.
Change-Id: I68815c94160864f4a3d2bb78b2e5d06949d27acf
Reviewed-on: https://go-review.googlesource.com/c/sys/+/203878
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Adjust TestSelect on Linux to match the Darwin/*BSD changes in CL
196802.
Updates golang/go#34458
Change-Id: Ia17fdadf7091001ea785391da23aaf9d3ec4ac5e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/196806
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
The code generator produces -0x1 for (~0) from the tipc.h C header, but this
value is unusable in Go as a uint32. Undefine and replace this value with
the appropriate constant for TIPC_WAIT_FOREVER.
Fixesgolang/go#34310
Change-Id: Ic6ab0ddd14394e15868085e2123a9a97a841bc6d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/195757
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
rsync needs to be explicitly installed for 'make headers_install' to
work.
Change-Id: Icd3d6b3f004a7684b5ae32b4b7cab8d50631900d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/195258
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Adds initial constants and types to use with SockaddrTIPC. For more
information on TIPC, see: http://tipc.sourceforge.net/.
Because the C struct sockaddr_tipc makes use of a union for its addr
field, I have created a wrapping layer in SockaddrTIPC that uses
an interface to determine which variant is in use.
Tests accompany this change due to the complexity of this code. There
is currently little test coverage in the Sockaddr-related code, but
perhaps this is something that could be picked up as a relatively
straightforward task for a new contributor.
Change-Id: I5033a0685cb7128d4b1a23d18aca71c202d0c0aa
Reviewed-on: https://go-review.googlesource.com/c/sys/+/187960
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Add IoctlRetInt() for ioctls that use syscall's return value
as an output parameter. Add a unit test for Linux, and the
NS_GET_ defines that it requires (see ioctl_ns(2)).
Motivation:
Currently, x/sys/unix provides a few functions to deal with ioctls.
In particular, IoctlGetInt(), which "performs an ioctl operation
which gets an integer value". It does that by passing a pointer
to an integer to a syscall and returning that integer. The value
returned from syscall is treated as success/failure flag
(0 means success, -1 means failure, and in such case errno
is used to figure out the underlying error).
It appears that there are a few ioctls in Linux and at least one
in Solaris, which do not use the above way to return an int, instead
they use the syscall's return value (in case it's not negative).
As Linux ioctl(2) man page says,
> RETURN VALUE
> Usually, on success zero is returned. A few ioctl() requests
> use the return value as an output parameter and return
> a nonnegative value on success. On error, -1 is returned,
> and errno is set appropriately.
Currently I am aware of at least 6 Linux ioctls that do that
(return the value directly):
* LOOP_CTL_* ioctls on /dev/loop-control (all 3 of them). Source: loop(4)
* NS_* ioctls (3 out of 4) on /proc/PID/ns/*. Source: ioctl_ns(2)
And one in Solaris:
* I_FIND ioctl, source: streamio(7i).
There might be some more ioctls like the ones above, but since
ioctls are scarcely documented, it is hard to say how many more.
Obviously, using IoctlGetInt() for such ioctls would be a big
mistake, as 0 will always be returned. For example, there was
a bug in Docker's pkg/loopback (moby/moby#39801).
[v6: make it linux-specific for now]
Fixesgolang/go#33966
Change-Id: Ie64f72fd84101b955ba14519a357e06a66d685d0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/192780
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Add wrappers for Getcap/Setcap on Linux as well as some related types
and consts.
Change-Id: I07764c2e64717214850ea3cbdc238e313d1e38c4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/183218
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This will also add two BPF_* consts which weren't added as part of
CL 174978 because they were generated before the Linux version update
in CL 175158.
Change-Id: I5dfecbecb9d94b56d01490a5f17f2250ad5b30d4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/178658
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Also add KexecFileLoad on linux/arm now that is has SYS_KEXEC_FILE_LOAD.
Change-Id: I519bc2f611b511af994e1c7bbaa07f68cd615ef4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/175158
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Also enable KexecFileLoad on linux/{arm64,riscv64} now that they have
SYS_KEXEC_FILE_LOAD.
Change-Id: I1c52d09a1a617794f2df697e4966c4c24a166611
Reviewed-on: https://go-review.googlesource.com/c/sys/+/164997
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This teaches unix/mksyscall.go about mapping uint64 to syscall
arguments, similar to existing handling of int64.
Change-Id: I536b4b09bbf6a8e3016565a4a04d2b9d32cbc624
Reviewed-on: https://go-review.googlesource.com/c/164664
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Drop the manually defined *_XDP constants which were added to glibc.
Install python3 instead of python because glibc's confugure script now
requires at least 3.4.
Change-Id: Ic19ff4d8aa4dbadeb5438e331ccafeafc2cc9925
Reviewed-on: https://go-review.googlesource.com/c/160957
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Also add additional packet timestamping constants and types defined
in the same header.
Change-Id: I4280f925b46e229f4c3a83a7fee4612592314016
Reviewed-on: https://go-review.googlesource.com/c/158761
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This adds the ClockNanosleep syscall and the TIMER_* constants;
currently only TIMER_ABSTIME for specifying an absolute timestamp.
Change-Id: Ic8d857eb92818529aadab569cd8646a19bb9c055
Reviewed-on: https://go-review.googlesource.com/c/157658
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
InitModule loads a kernel module from an ELF image. FinitModule loads a
kernel module from a file descriptor. DeleteModule unloads a kernel
module.
These syscalls require the CAP_SYS_MODULE capability.
See http://man7.org/linux/man-pages/man2/init_module.2.html and
http://man7.org/linux/man-pages/man2/delete_module.2.html for details.
Also drop deprecated syscalls related to kernel modules from the list
of unimplemented syscalls.
Change-Id: I131e17f02c5617640f5f4073982d2b27a6d78bbf
Reviewed-on: https://go-review.googlesource.com/c/144173
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
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>
Add a wrapper for the memfd_create syscall on Linux. See
http://man7.org/linux/man-pages/man2/memfd_create.2.html for more
information.
Also add the corresponding MFD_* constants to be used in the flags
argument.
Change-Id: Ib30a007e15575a38ecf204601ffede9c913799b6
Reviewed-on: https://go-review.googlesource.com/135915
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Including linux/stat.h in mkerrors.sh is no longer necessary because the
statx types and constants were added to the glibc headers.
Change-Id: I643c35fd2da76dd2c15015556658d7fa862249c4
Reviewed-on: https://go-review.googlesource.com/129100
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Renameat2 is Linux-specific and allows to pass an additional flags
argument to the renameat syscall. Also add the corresponding RENAME_*
flag mask values.
Change-Id: Ib4baa46fdd0b07ccd0988ac624862ce69d5c3ad5
Reviewed-on: https://go-review.googlesource.com/127763
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This adds the NETNSA constants from net_namespace.h, used for creating
and querying network namespace IDs.
Fixesgolang/go#26330
Change-Id: I786c4c4771be3eddc4fdb830a52e128aa1a2b9fd
Reviewed-on: https://go-review.googlesource.com/124436
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Change-Id: I280fc3b2cd3402c40f2840d152bac2fa288f48a0
Reviewed-on: https://go-review.googlesource.com/118661
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
The code has been regenerated using the updated software versions.
Change-Id: Ic2af968d4d8cbf3ab31e5bca1d6640642eb7115a
Reviewed-on: https://go-review.googlesource.com/118255
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Add ErrnoName and SignalName to get errno and signal name strings from
syscall.Errno and syscall.Signal values, respectively.
This repurposes the errors and signals vars (because they are not used
within x/sys/unix currently) and turns them into slices of struct,
containing errno/signal number, name and description. ErrnoName and
SignalName can then be trivially implemented using sort.Search.
Renaming errors to errorList additionaly allows to avoid package aliases
for the errors package.
Fixesgolang/go#25134
Change-Id: Ie195872793f44c437f0f175ccfaa13a2546338c5
Reviewed-on: https://go-review.googlesource.com/110875
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
These types and constants are taken from hdreg.h, and will enable
querying and manipulation of block devices on Linux.
Fixesgolang/go#24971
Change-Id: Iafe8f81ba7ab9f1e127743dab6a9fb1912874a5c
Reviewed-on: https://go-review.googlesource.com/108455
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
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>
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>
To be used e.g. in github.com/mdlayher/vsock
Change-Id: I52148a6e6c53c022c07e2cc8bf7348a96445c17b
Reviewed-on: https://go-review.googlesource.com/76193
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
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>
To be used e.g. in
2e60d5b8c8
Change-Id: If79ffec9021dc79375c861a0ddd9dd443adb4692
Reviewed-on: https://go-review.googlesource.com/72375
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>