]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/missing_fcntl.h
mkosi: update arch commit reference
[thirdparty/systemd.git] / src / basic / missing_fcntl.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <fcntl.h>
5
6 #ifndef F_LINUX_SPECIFIC_BASE
7 #define F_LINUX_SPECIFIC_BASE 1024
8 #endif
9
10 #ifndef F_SETPIPE_SZ
11 #define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
12 #endif
13
14 #ifndef F_GETPIPE_SZ
15 #define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
16 #endif
17
18 #ifndef F_ADD_SEALS
19 #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
20 #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
21
22 #define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
23 #define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
24 #define F_SEAL_GROW 0x0004 /* prevent file from growing */
25 #define F_SEAL_WRITE 0x0008 /* prevent writes */
26 #endif
27
28 #ifndef F_SEAL_FUTURE_WRITE
29 #define F_SEAL_FUTURE_WRITE 0x0010 /* prevent future writes while mapped */
30 #endif
31
32 #ifndef F_SEAL_EXEC
33 #define F_SEAL_EXEC 0x0020 /* prevent chmod modifying exec bits */
34 #endif
35
36 #ifndef F_OFD_GETLK
37 #define F_OFD_GETLK 36
38 #define F_OFD_SETLK 37
39 #define F_OFD_SETLKW 38
40 #endif
41
42 #ifndef MAX_HANDLE_SZ
43 #define MAX_HANDLE_SZ 128
44 #endif
45
46 /* The precise definition of __O_TMPFILE is arch specific; use the
47 * values defined by the kernel (note: some are hexa, some are octal,
48 * duplicated as-is from the kernel definitions):
49 * - alpha, parisc, sparc: each has a specific value;
50 * - others: they use the "generic" value.
51 */
52
53 #ifndef __O_TMPFILE
54 #if defined(__alpha__)
55 #define __O_TMPFILE 0100000000
56 #elif defined(__parisc__) || defined(__hppa__)
57 #define __O_TMPFILE 0400000000
58 #elif defined(__sparc__) || defined(__sparc64__)
59 #define __O_TMPFILE 0x2000000
60 #else
61 #define __O_TMPFILE 020000000
62 #endif
63 #endif
64
65 /* a horrid kludge trying to make sure that this will fail on old kernels */
66 #ifndef O_TMPFILE
67 #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
68 #endif
69
70 /* So O_LARGEFILE is generally implied by glibc, and defined to zero hence, because we only build in LFS
71 * mode. However, when invoking fcntl(F_GETFL) the flag is ORed into the result anyway — glibc does not mask
72 * it away. Which sucks. Let's define the actual value here, so that we can mask it ourselves.
73 *
74 * The precise definition is arch specific, so we use the values defined in the kernel (note that some
75 * are hexa and others are octal; duplicated as-is from the kernel definitions):
76 * - alpha, arm, arm64, m68k, mips, parisc, powerpc, sparc: each has a specific value;
77 * - others: they use the "generic" value (defined in include/uapi/asm-generic/fcntl.h) */
78 #if O_LARGEFILE != 0
79 #define RAW_O_LARGEFILE O_LARGEFILE
80 #else
81 #if defined(__alpha__) || defined(__arm__) || defined(__aarch64__) || defined(__m68k__)
82 #define RAW_O_LARGEFILE 0400000
83 #elif defined(__mips__)
84 #define RAW_O_LARGEFILE 0x2000
85 #elif defined(__parisc__) || defined(__hppa__)
86 #define RAW_O_LARGEFILE 000004000
87 #elif defined(__powerpc__)
88 #define RAW_O_LARGEFILE 0200000
89 #elif defined(__sparc__)
90 #define RAW_O_LARGEFILE 0x40000
91 #else
92 #define RAW_O_LARGEFILE 00100000
93 #endif
94 #endif