xref: /linux/include/uapi/linux/close_range.h (revision 4effd80841b3c26ab33e30409e810b35a0dc0385)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI_LINUX_CLOSE_RANGE_H
3 #define _UAPI_LINUX_CLOSE_RANGE_H
4 
5 /*
6  * A macro of one of these names defined before this header is parsed, by
7  * a libc or by a program's own fallback, would replace the enumerator.
8  */
9 #undef CLOSE_RANGE_UNSHARE
10 #undef CLOSE_RANGE_CLOEXEC
11 #undef CLOSE_RANGE_EXCEPT
12 #undef CLOSE_RANGE_CLOEXEC_ONLY
13 
14 enum close_range_flags {
15 	/* Unshare the file descriptor table before closing file descriptors. */
16 	CLOSE_RANGE_UNSHARE	= (1U << 1),
17 
18 	/* Set the FD_CLOEXEC bit instead of closing the file descriptor. */
19 	CLOSE_RANGE_CLOEXEC	= (1U << 2),
20 
21 	/* Act on every file descriptor outside of the given range instead. */
22 	CLOSE_RANGE_EXCEPT	= (1U << 3),
23 
24 	/* Only close file descriptors that have the FD_CLOEXEC bit set. */
25 	CLOSE_RANGE_CLOEXEC_ONLY	= (1U << 4),
26 };
27 
28 /* Keep #ifdef working and let glibc skip its own definitions. */
29 #define CLOSE_RANGE_UNSHARE		CLOSE_RANGE_UNSHARE
30 #define CLOSE_RANGE_CLOEXEC		CLOSE_RANGE_CLOEXEC
31 #define CLOSE_RANGE_EXCEPT		CLOSE_RANGE_EXCEPT
32 #define CLOSE_RANGE_CLOEXEC_ONLY	CLOSE_RANGE_CLOEXEC_ONLY
33 
34 #endif /* _UAPI_LINUX_CLOSE_RANGE_H */
35 
36