unix: add openat2 for linux

openat2 is a new syscall added to Linux 5.6. It provides a superset of
openat(2) functionality, extending it with flags telling the kernel how
to resolve the paths.

For more info, see https://lwn.net/Articles/803237/

NOTE that this is a second attempt to add the call; the previous one
(https://golang.org/cl/227280) was reverted
(https://golang.org/cl/227846) due to the test case failure on ARM
(https://golang.org/issue/38357).

This CL has the test case reworked to be less assumptive to the testing
environment. In particular, it first tries if the most simplistic
openat2() call succeeds, and skips the test otherwise. It is done that
way because CI can be under under different kernels and in various
envrionments -- in particular, Docker+seccomp can result in EPERM from a
system call (which is not expected otherwise).

For previous discussions about the test case, see
https://golang.org/cl/227865.

Change-Id: I4276cf13dc29ecbdbdc9c58da0f76270f585a67f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/253057
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
Kir Kolyshkin
2020-09-09 08:10:42 +00:00
committed by Tobias Klauser
parent d2e65c121b
commit eff7692f90
5 changed files with 111 additions and 0 deletions
+13
View File
@@ -111,6 +111,7 @@ struct termios2 {
#include <linux/netfilter.h>
#include <linux/netlink.h>
#include <linux/nexthop.h>
#include <linux/openat2.h>
#include <linux/perf_event.h>
#include <linux/random.h>
#include <linux/rtc.h>
@@ -874,6 +875,18 @@ const (
AT_EACCESS = C.AT_EACCESS
)
type OpenHow C.struct_open_how
const SizeofOpenHow = C.sizeof_struct_open_how
const (
RESOLVE_BENEATH = C.RESOLVE_BENEATH
RESOLVE_IN_ROOT = C.RESOLVE_IN_ROOT
RESOLVE_NO_MAGICLINKS = C.RESOLVE_NO_MAGICLINKS
RESOLVE_NO_SYMLINKS = C.RESOLVE_NO_SYMLINKS
RESOLVE_NO_XDEV = C.RESOLVE_NO_XDEV
)
type PollFd C.struct_pollfd
const (