|
3 | 3 |
|
4 | 4 | /* Missing glibc definitions to access certain kernel APIs */ |
5 | 5 |
|
6 | | -#include <errno.h> |
7 | | -#include <fcntl.h> |
8 | | -#include <inttypes.h> |
9 | | -#include <linux/audit.h> |
10 | | -#include <linux/falloc.h> |
11 | | -#include <linux/oom.h> |
12 | | -#include <net/ethernet.h> |
13 | | -#include <stdlib.h> |
14 | | -#include <sys/resource.h> |
15 | | -#include <sys/socket.h> |
16 | | -#include <sys/syscall.h> |
17 | | -#include <unistd.h> |
18 | | - |
19 | | -#if HAVE_AUDIT |
20 | | -#include <libaudit.h> |
21 | | -#endif |
22 | | - |
23 | | -#ifdef ARCH_MIPS |
24 | | -#include <asm/sgidefs.h> |
25 | | -#endif |
26 | | - |
27 | | -#if HAVE_LINUX_VM_SOCKETS_H |
28 | | -#include <linux/vm_sockets.h> |
29 | | -#else |
30 | | -#define VMADDR_CID_ANY -1U |
31 | | -struct sockaddr_vm { |
32 | | - unsigned short svm_family; |
33 | | - unsigned short svm_reserved1; |
34 | | - unsigned int svm_port; |
35 | | - unsigned int svm_cid; |
36 | | - unsigned char svm_zero[sizeof(struct sockaddr) - |
37 | | - sizeof(unsigned short) - |
38 | | - sizeof(unsigned short) - |
39 | | - sizeof(unsigned int) - |
40 | | - sizeof(unsigned int)]; |
41 | | -}; |
42 | | -#endif /* !HAVE_LINUX_VM_SOCKETS_H */ |
43 | | - |
44 | | -#ifndef RLIMIT_RTTIME |
45 | | -#define RLIMIT_RTTIME 15 |
46 | | -#endif |
47 | | - |
48 | | -/* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */ |
49 | | -#define _RLIMIT_MAX (RLIMIT_RTTIME+1 > RLIMIT_NLIMITS ? RLIMIT_RTTIME+1 : RLIMIT_NLIMITS) |
50 | | - |
51 | | -#ifndef F_LINUX_SPECIFIC_BASE |
52 | | -#define F_LINUX_SPECIFIC_BASE 1024 |
53 | | -#endif |
54 | | - |
55 | | -#ifndef F_SETPIPE_SZ |
56 | | -#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7) |
57 | | -#endif |
58 | | - |
59 | | -#ifndef F_GETPIPE_SZ |
60 | | -#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8) |
61 | | -#endif |
62 | | - |
63 | | -#ifndef F_ADD_SEALS |
64 | | -#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) |
65 | | -#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) |
66 | | - |
67 | | -#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ |
68 | | -#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ |
69 | | -#define F_SEAL_GROW 0x0004 /* prevent file from growing */ |
70 | | -#define F_SEAL_WRITE 0x0008 /* prevent writes */ |
71 | | -#endif |
72 | | - |
73 | | -#ifndef F_OFD_GETLK |
74 | | -#define F_OFD_GETLK 36 |
75 | | -#define F_OFD_SETLK 37 |
76 | | -#define F_OFD_SETLKW 38 |
77 | | -#endif |
78 | | - |
79 | | -#ifndef MFD_ALLOW_SEALING |
80 | | -#define MFD_ALLOW_SEALING 0x0002U |
81 | | -#endif |
82 | | - |
83 | | -#ifndef MFD_CLOEXEC |
84 | | -#define MFD_CLOEXEC 0x0001U |
85 | | -#endif |
86 | | - |
87 | | -#ifndef IP_FREEBIND |
88 | | -#define IP_FREEBIND 15 |
89 | | -#endif |
90 | | - |
91 | | -#ifndef OOM_SCORE_ADJ_MIN |
92 | | -#define OOM_SCORE_ADJ_MIN (-1000) |
93 | | -#endif |
94 | | - |
95 | | -#ifndef OOM_SCORE_ADJ_MAX |
96 | | -#define OOM_SCORE_ADJ_MAX 1000 |
97 | | -#endif |
98 | | - |
99 | | -#ifndef AUDIT_SERVICE_START |
100 | | -#define AUDIT_SERVICE_START 1130 /* Service (daemon) start */ |
101 | | -#endif |
102 | | - |
103 | | -#ifndef AUDIT_SERVICE_STOP |
104 | | -#define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */ |
105 | | -#endif |
106 | | - |
107 | | -#ifndef TIOCVHANGUP |
108 | | -#define TIOCVHANGUP 0x5437 |
109 | | -#endif |
110 | | - |
111 | | -#ifndef IP_TRANSPARENT |
112 | | -#define IP_TRANSPARENT 19 |
113 | | -#endif |
114 | | - |
115 | | -#ifndef SOL_NETLINK |
116 | | -#define SOL_NETLINK 270 |
117 | | -#endif |
118 | | - |
119 | | -#ifndef NETLINK_LIST_MEMBERSHIPS |
120 | | -#define NETLINK_LIST_MEMBERSHIPS 9 |
121 | | -#endif |
122 | | - |
123 | | -#ifndef SOL_SCTP |
124 | | -#define SOL_SCTP 132 |
125 | | -#endif |
126 | | - |
127 | | -#ifndef GRND_NONBLOCK |
128 | | -#define GRND_NONBLOCK 0x0001 |
129 | | -#endif |
130 | | - |
131 | | -#ifndef GRND_RANDOM |
132 | | -#define GRND_RANDOM 0x0002 |
133 | | -#endif |
134 | | - |
135 | | -#ifndef FS_NOCOW_FL |
136 | | -#define FS_NOCOW_FL 0x00800000 |
137 | | -#endif |
138 | | - |
139 | | -#ifndef CLONE_NEWCGROUP |
140 | | -#define CLONE_NEWCGROUP 0x02000000 |
141 | | -#endif |
142 | | - |
143 | | -#ifndef MS_MOVE |
144 | | -#define MS_MOVE 8192 |
145 | | -#endif |
146 | | - |
147 | | -#ifndef MS_REC |
148 | | -#define MS_REC 16384 |
149 | | -#endif |
150 | | - |
151 | | -#ifndef MS_PRIVATE |
152 | | -#define MS_PRIVATE (1<<18) |
153 | | -#endif |
154 | | - |
155 | | -#ifndef MS_REC |
156 | | -#define MS_REC (1<<19) |
157 | | -#endif |
158 | | - |
159 | | -#ifndef MS_SHARED |
160 | | -#define MS_SHARED (1<<20) |
161 | | -#endif |
162 | | - |
163 | | -#ifndef MS_RELATIME |
164 | | -#define MS_RELATIME (1<<21) |
165 | | -#endif |
166 | | - |
167 | | -#ifndef MS_KERNMOUNT |
168 | | -#define MS_KERNMOUNT (1<<22) |
169 | | -#endif |
170 | | - |
171 | | -#ifndef MS_I_VERSION |
172 | | -#define MS_I_VERSION (1<<23) |
173 | | -#endif |
174 | | - |
175 | | -#ifndef MS_STRICTATIME |
176 | | -#define MS_STRICTATIME (1<<24) |
177 | | -#endif |
178 | | - |
179 | | -#ifndef MS_LAZYTIME |
180 | | -#define MS_LAZYTIME (1<<25) |
181 | | -#endif |
182 | | - |
183 | | -#ifndef SCM_SECURITY |
184 | | -#define SCM_SECURITY 0x03 |
185 | | -#endif |
186 | | - |
187 | | -#ifndef DM_DEFERRED_REMOVE |
188 | | -#define DM_DEFERRED_REMOVE (1 << 17) |
189 | | -#endif |
190 | | - |
191 | | -#ifndef MAX_HANDLE_SZ |
192 | | -#define MAX_HANDLE_SZ 128 |
193 | | -#endif |
194 | | - |
195 | | -#if ! HAVE_SECURE_GETENV |
196 | | -# if HAVE___SECURE_GETENV |
197 | | -# define secure_getenv __secure_getenv |
198 | | -# else |
199 | | -# error "neither secure_getenv nor __secure_getenv are available" |
200 | | -# endif |
201 | | -#endif |
202 | | - |
203 | | -#ifndef CIFS_MAGIC_NUMBER |
204 | | -# define CIFS_MAGIC_NUMBER 0xFF534D42 |
205 | | -#endif |
206 | | - |
207 | | -#ifndef TFD_TIMER_CANCEL_ON_SET |
208 | | -# define TFD_TIMER_CANCEL_ON_SET (1 << 1) |
209 | | -#endif |
210 | | - |
211 | | -#ifndef SO_REUSEPORT |
212 | | -# define SO_REUSEPORT 15 |
213 | | -#endif |
214 | | - |
215 | | -#ifndef SO_PEERGROUPS |
216 | | -# define SO_PEERGROUPS 59 |
217 | | -#endif |
218 | | - |
219 | | -#ifndef DRM_IOCTL_SET_MASTER |
220 | | -# define DRM_IOCTL_SET_MASTER _IO('d', 0x1e) |
221 | | -#endif |
222 | | - |
223 | | -#ifndef DRM_IOCTL_DROP_MASTER |
224 | | -# define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f) |
225 | | -#endif |
226 | | - |
227 | | -/* The precise definition of __O_TMPFILE is arch specific; use the |
228 | | - * values defined by the kernel (note: some are hexa, some are octal, |
229 | | - * duplicated as-is from the kernel definitions): |
230 | | - * - alpha, parisc, sparc: each has a specific value; |
231 | | - * - others: they use the "generic" value. |
232 | | - */ |
233 | | - |
234 | | -#ifndef __O_TMPFILE |
235 | | -#if defined(__alpha__) |
236 | | -#define __O_TMPFILE 0100000000 |
237 | | -#elif defined(__parisc__) || defined(__hppa__) |
238 | | -#define __O_TMPFILE 0400000000 |
239 | | -#elif defined(__sparc__) || defined(__sparc64__) |
240 | | -#define __O_TMPFILE 0x2000000 |
241 | | -#else |
242 | | -#define __O_TMPFILE 020000000 |
243 | | -#endif |
244 | | -#endif |
245 | | - |
246 | | -/* a horrid kludge trying to make sure that this will fail on old kernels */ |
247 | | -#ifndef O_TMPFILE |
248 | | -#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) |
249 | | -#endif |
250 | | - |
251 | | -#ifndef BPF_XOR |
252 | | -#define BPF_XOR 0xa0 |
253 | | -#endif |
254 | | - |
255 | | -/* Note that LOOPBACK_IFINDEX is currently not exported by the |
256 | | - * kernel/glibc, but hardcoded internally by the kernel. However, as |
257 | | - * it is exported to userspace indirectly via rtnetlink and the |
258 | | - * ioctls, and made use of widely we define it here too, in a way that |
259 | | - * is compatible with the kernel's internal definition. */ |
260 | | -#ifndef LOOPBACK_IFINDEX |
261 | | -#define LOOPBACK_IFINDEX 1 |
262 | | -#endif |
263 | | - |
264 | | -#ifndef MAX_AUDIT_MESSAGE_LENGTH |
265 | | -#define MAX_AUDIT_MESSAGE_LENGTH 8970 |
266 | | -#endif |
267 | | - |
268 | | -#ifndef AUDIT_NLGRP_MAX |
269 | | -#define AUDIT_NLGRP_READLOG 1 |
270 | | -#endif |
271 | | - |
272 | | -#ifndef RENAME_NOREPLACE |
273 | | -#define RENAME_NOREPLACE (1 << 0) |
274 | | -#endif |
275 | | - |
276 | | -#ifndef KCMP_FILE |
277 | | -#define KCMP_FILE 0 |
278 | | -#endif |
279 | | - |
280 | | -#ifndef ETHERTYPE_LLDP |
281 | | -#define ETHERTYPE_LLDP 0x88cc |
282 | | -#endif |
283 | | - |
284 | | -#ifndef SOL_ALG |
285 | | -#define SOL_ALG 279 |
286 | | -#endif |
287 | | - |
288 | | -#ifndef AF_VSOCK |
289 | | -#define AF_VSOCK 40 |
290 | | -#endif |
291 | | - |
292 | | -#ifndef EXT4_IOC_RESIZE_FS |
293 | | -# define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64) |
294 | | -#endif |
295 | | - |
296 | | -#ifndef NS_GET_NSTYPE |
297 | | -#define NS_GET_NSTYPE _IO(0xb7, 0x3) |
298 | | -#endif |
299 | | - |
300 | | -#ifndef FALLOC_FL_KEEP_SIZE |
301 | | -#define FALLOC_FL_KEEP_SIZE 0x01 |
302 | | -#endif |
303 | | - |
304 | | -#ifndef FALLOC_FL_PUNCH_HOLE |
305 | | -#define FALLOC_FL_PUNCH_HOLE 0x02 |
306 | | -#endif |
307 | | - |
308 | | -#ifndef PF_KTHREAD |
309 | | -#define PF_KTHREAD 0x00200000 |
310 | | -#endif |
311 | | - |
312 | | -/* The maximum thread/process name length including trailing NUL byte. This mimics the kernel definition of the same |
313 | | - * name, which we need in userspace at various places but is not defined in userspace currently, neither under this |
314 | | - * name nor any other. */ |
315 | | -#ifndef TASK_COMM_LEN |
316 | | -#define TASK_COMM_LEN 16 |
317 | | -#endif |
318 | | - |
| 6 | +#include "missing_audit.h" |
319 | 7 | #include "missing_btrfs_tree.h" |
320 | 8 | #include "missing_capability.h" |
| 9 | +#include "missing_fcntl.h" |
| 10 | +#include "missing_fs.h" |
321 | 11 | #include "missing_input.h" |
322 | 12 | #include "missing_magic.h" |
| 13 | +#include "missing_mman.h" |
323 | 14 | #include "missing_network.h" |
324 | 15 | #include "missing_prctl.h" |
| 16 | +#include "missing_random.h" |
| 17 | +#include "missing_resource.h" |
| 18 | +#include "missing_sched.h" |
| 19 | +#include "missing_socket.h" |
| 20 | +#include "missing_stdlib.h" |
| 21 | +#include "missing_timerfd.h" |
325 | 22 | #include "missing_type.h" |
326 | 23 |
|
327 | 24 | #include "missing_syscall.h" |
0 commit comments