unix: add openat2 for linux

openat2 is a new syscall added to Linux 5.6. It provides a superset
of openat(2) functionality, providing a way to extend it in the future,
and (for now) adding flags telling the kernel how to resolve the path.

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

A primitive test case is added to check that Openat2 works as
it should. Tested to skip on kernel 5.5 and pass on 5.6.

Change-Id: Ib8bbd71791762f043200543cecdea16d2fd3c81d
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Reviewed-on: https://go-review.googlesource.com/c/sys/+/227280
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
Kir Kolyshkin
2020-04-06 11:34:30 +00:00
committed by Tobias Klauser
parent c3d8025017
commit c6e801f48b
5 changed files with 72 additions and 0 deletions
+13
View File
@@ -106,6 +106,7 @@ struct termios2 {
#include <linux/netfilter/nfnetlink.h>
#include <linux/netfilter.h>
#include <linux/netlink.h>
#include <linux/openat2.h>
#include <linux/perf_event.h>
#include <linux/random.h>
#include <linux/rtc.h>
@@ -833,6 +834,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 (