mirror of
https://github.com/netdata/libbpf.git
synced 2026-03-21 16:59:07 +08:00
sync: add back fcnt.h and openat2.h UAPI headers
They were removed during one of the syncs because Linux repo's tools/ versions of UAPI headers were removed (as they were not needed for perf anymore). This is no right for libbpf, so add them back. And moving forward, we'll sync them from Linux repo original UAPIs. Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
This commit is contained in:
committed by
Andrii Nakryiko
parent
67901a67cb
commit
289e4a2160
180
include/uapi/linux/fcntl.h
Normal file
180
include/uapi/linux/fcntl.h
Normal file
@@ -0,0 +1,180 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
#ifndef _LINUX_FCNTL_H
|
||||
#define _LINUX_FCNTL_H
|
||||
|
||||
#include <asm/fcntl.h>
|
||||
#include <linux/openat2.h>
|
||||
|
||||
#define F_SETLEASE (F_LINUX_SPECIFIC_BASE + 0)
|
||||
#define F_GETLEASE (F_LINUX_SPECIFIC_BASE + 1)
|
||||
|
||||
/*
|
||||
* Request nofications on a directory.
|
||||
* See below for events that may be notified.
|
||||
*/
|
||||
#define F_NOTIFY (F_LINUX_SPECIFIC_BASE + 2)
|
||||
|
||||
#define F_DUPFD_QUERY (F_LINUX_SPECIFIC_BASE + 3)
|
||||
|
||||
/* Was the file just created? */
|
||||
#define F_CREATED_QUERY (F_LINUX_SPECIFIC_BASE + 4)
|
||||
|
||||
/*
|
||||
* Cancel a blocking posix lock; internal use only until we expose an
|
||||
* asynchronous lock api to userspace:
|
||||
*/
|
||||
#define F_CANCELLK (F_LINUX_SPECIFIC_BASE + 5)
|
||||
|
||||
/* Create a file descriptor with FD_CLOEXEC set. */
|
||||
#define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6)
|
||||
|
||||
/*
|
||||
* Set and get of pipe page size array
|
||||
*/
|
||||
#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
|
||||
#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
|
||||
|
||||
/*
|
||||
* Set/Get seals
|
||||
*/
|
||||
#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
|
||||
#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
|
||||
|
||||
/*
|
||||
* Types of seals
|
||||
*/
|
||||
#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
|
||||
#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
|
||||
#define F_SEAL_GROW 0x0004 /* prevent file from growing */
|
||||
#define F_SEAL_WRITE 0x0008 /* prevent writes */
|
||||
#define F_SEAL_FUTURE_WRITE 0x0010 /* prevent future writes while mapped */
|
||||
#define F_SEAL_EXEC 0x0020 /* prevent chmod modifying exec bits */
|
||||
/* (1U << 31) is reserved for signed error codes */
|
||||
|
||||
/*
|
||||
* Set/Get write life time hints. {GET,SET}_RW_HINT operate on the
|
||||
* underlying inode, while {GET,SET}_FILE_RW_HINT operate only on
|
||||
* the specific file.
|
||||
*/
|
||||
#define F_GET_RW_HINT (F_LINUX_SPECIFIC_BASE + 11)
|
||||
#define F_SET_RW_HINT (F_LINUX_SPECIFIC_BASE + 12)
|
||||
#define F_GET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 13)
|
||||
#define F_SET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 14)
|
||||
|
||||
/*
|
||||
* Valid hint values for F_{GET,SET}_RW_HINT. 0 is "not set", or can be
|
||||
* used to clear any hints previously set.
|
||||
*/
|
||||
#define RWH_WRITE_LIFE_NOT_SET 0
|
||||
#define RWH_WRITE_LIFE_NONE 1
|
||||
#define RWH_WRITE_LIFE_SHORT 2
|
||||
#define RWH_WRITE_LIFE_MEDIUM 3
|
||||
#define RWH_WRITE_LIFE_LONG 4
|
||||
#define RWH_WRITE_LIFE_EXTREME 5
|
||||
|
||||
/*
|
||||
* The originally introduced spelling is remained from the first
|
||||
* versions of the patch set that introduced the feature, see commit
|
||||
* v4.13-rc1~212^2~51.
|
||||
*/
|
||||
#define RWF_WRITE_LIFE_NOT_SET RWH_WRITE_LIFE_NOT_SET
|
||||
|
||||
/*
|
||||
* Types of directory notifications that may be requested.
|
||||
*/
|
||||
#define DN_ACCESS 0x00000001 /* File accessed */
|
||||
#define DN_MODIFY 0x00000002 /* File modified */
|
||||
#define DN_CREATE 0x00000004 /* File created */
|
||||
#define DN_DELETE 0x00000008 /* File removed */
|
||||
#define DN_RENAME 0x00000010 /* File renamed */
|
||||
#define DN_ATTRIB 0x00000020 /* File changed attibutes */
|
||||
#define DN_MULTISHOT 0x80000000 /* Don't remove notifier */
|
||||
|
||||
/* Reserved kernel ranges [-100], [-10000, -40000]. */
|
||||
#define AT_FDCWD -100 /* Special value for dirfd used to
|
||||
indicate openat should use the
|
||||
current working directory. */
|
||||
|
||||
/*
|
||||
* The concept of process and threads in userland and the kernel is a confusing
|
||||
* one - within the kernel every thread is a 'task' with its own individual PID,
|
||||
* however from userland's point of view threads are grouped by a single PID,
|
||||
* which is that of the 'thread group leader', typically the first thread
|
||||
* spawned.
|
||||
*
|
||||
* To cut the Gideon knot, for internal kernel usage, we refer to
|
||||
* PIDFD_SELF_THREAD to refer to the current thread (or task from a kernel
|
||||
* perspective), and PIDFD_SELF_THREAD_GROUP to refer to the current thread
|
||||
* group leader...
|
||||
*/
|
||||
#define PIDFD_SELF_THREAD -10000 /* Current thread. */
|
||||
#define PIDFD_SELF_THREAD_GROUP -10001 /* Current thread group leader. */
|
||||
|
||||
#define FD_PIDFS_ROOT -10002 /* Root of the pidfs filesystem */
|
||||
#define FD_INVALID -10009 /* Invalid file descriptor: -10000 - EBADF = -10009 */
|
||||
|
||||
/* Generic flags for the *at(2) family of syscalls. */
|
||||
|
||||
/* Reserved for per-syscall flags 0xff. */
|
||||
#define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic
|
||||
links. */
|
||||
/* Reserved for per-syscall flags 0x200 */
|
||||
#define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */
|
||||
#define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount
|
||||
traversal. */
|
||||
#define AT_EMPTY_PATH 0x1000 /* Allow empty relative
|
||||
pathname to operate on dirfd
|
||||
directly. */
|
||||
/*
|
||||
* These flags are currently statx(2)-specific, but they could be made generic
|
||||
* in the future and so they should not be used for other per-syscall flags.
|
||||
*/
|
||||
#define AT_STATX_SYNC_TYPE 0x6000 /* Type of synchronisation required from statx() */
|
||||
#define AT_STATX_SYNC_AS_STAT 0x0000 /* - Do whatever stat() does */
|
||||
#define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */
|
||||
#define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */
|
||||
|
||||
#define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */
|
||||
|
||||
/*
|
||||
* Per-syscall flags for the *at(2) family of syscalls.
|
||||
*
|
||||
* These are flags that are so syscall-specific that a user passing these flags
|
||||
* to the wrong syscall is so "clearly wrong" that we can safely call such
|
||||
* usage "undefined behaviour".
|
||||
*
|
||||
* For example, the constants AT_REMOVEDIR and AT_EACCESS have the same value.
|
||||
* AT_EACCESS is meaningful only to faccessat, while AT_REMOVEDIR is meaningful
|
||||
* only to unlinkat. The two functions do completely different things and
|
||||
* therefore, the flags can be allowed to overlap. For example, passing
|
||||
* AT_REMOVEDIR to faccessat would be undefined behavior and thus treating it
|
||||
* equivalent to AT_EACCESS is valid undefined behavior.
|
||||
*
|
||||
* Note for implementers: When picking a new per-syscall AT_* flag, try to
|
||||
* reuse already existing flags first. This leaves us with as many unused bits
|
||||
* as possible, so we can use them for generic bits in the future if necessary.
|
||||
*/
|
||||
|
||||
/* Flags for renameat2(2) (must match legacy RENAME_* flags). */
|
||||
#define AT_RENAME_NOREPLACE 0x0001
|
||||
#define AT_RENAME_EXCHANGE 0x0002
|
||||
#define AT_RENAME_WHITEOUT 0x0004
|
||||
|
||||
/* Flag for faccessat(2). */
|
||||
#define AT_EACCESS 0x200 /* Test access permitted for
|
||||
effective IDs, not real IDs. */
|
||||
/* Flag for unlinkat(2). */
|
||||
#define AT_REMOVEDIR 0x200 /* Remove directory instead of
|
||||
unlinking file. */
|
||||
/* Flags for name_to_handle_at(2). */
|
||||
#define AT_HANDLE_FID 0x200 /* File handle is needed to compare
|
||||
object identity and may not be
|
||||
usable with open_by_handle_at(2). */
|
||||
#define AT_HANDLE_MNT_ID_UNIQUE 0x001 /* Return the u64 unique mount ID. */
|
||||
#define AT_HANDLE_CONNECTABLE 0x002 /* Request a connectable file handle */
|
||||
|
||||
/* Flags for execveat2(2). */
|
||||
#define AT_EXECVE_CHECK 0x10000 /* Only perform a check if execution
|
||||
would be allowed. */
|
||||
|
||||
#endif /* _LINUX_FCNTL_H */
|
||||
43
include/uapi/linux/openat2.h
Normal file
43
include/uapi/linux/openat2.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
#ifndef _LINUX_OPENAT2_H
|
||||
#define _LINUX_OPENAT2_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/*
|
||||
* Arguments for how openat2(2) should open the target path. If only @flags and
|
||||
* @mode are non-zero, then openat2(2) operates very similarly to openat(2).
|
||||
*
|
||||
* However, unlike openat(2), unknown or invalid bits in @flags result in
|
||||
* -EINVAL rather than being silently ignored. @mode must be zero unless one of
|
||||
* {O_CREAT, O_TMPFILE} are set.
|
||||
*
|
||||
* @flags: O_* flags.
|
||||
* @mode: O_CREAT/O_TMPFILE file mode.
|
||||
* @resolve: RESOLVE_* flags.
|
||||
*/
|
||||
struct open_how {
|
||||
__u64 flags;
|
||||
__u64 mode;
|
||||
__u64 resolve;
|
||||
};
|
||||
|
||||
/* how->resolve flags for openat2(2). */
|
||||
#define RESOLVE_NO_XDEV 0x01 /* Block mount-point crossings
|
||||
(includes bind-mounts). */
|
||||
#define RESOLVE_NO_MAGICLINKS 0x02 /* Block traversal through procfs-style
|
||||
"magic-links". */
|
||||
#define RESOLVE_NO_SYMLINKS 0x04 /* Block traversal through all symlinks
|
||||
(implies OEXT_NO_MAGICLINKS) */
|
||||
#define RESOLVE_BENEATH 0x08 /* Block "lexical" trickery like
|
||||
"..", symlinks, and absolute
|
||||
paths which escape the dirfd. */
|
||||
#define RESOLVE_IN_ROOT 0x10 /* Make all jumps to "/" and ".."
|
||||
be scoped inside the dirfd
|
||||
(similar to chroot(2)). */
|
||||
#define RESOLVE_CACHED 0x20 /* Only complete if resolution can be
|
||||
completed through cached lookup. May
|
||||
return -EAGAIN if that's not
|
||||
possible. */
|
||||
|
||||
#endif /* _LINUX_OPENAT2_H */
|
||||
Reference in New Issue
Block a user