• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 13665439908

04 Mar 2025 09:54PM UTC coverage: 71.855% (+0.04%) from 71.819%
13665439908

push

github

poettering
dirent-util: add several assertions in posix_getdents()

Follow-up for e86a492ff.

4 of 4 new or added lines in 1 file covered. (100.0%)

8029 existing lines in 84 files now uncovered.

294783 of 410245 relevant lines covered (71.86%)

717882.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/src/basic/missing_syscall.h
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2
#pragma once
3

4
/* Missing glibc definitions to access certain kernel APIs */
5

6
#include <errno.h>
7
#include <linux/time_types.h>
8
#include <signal.h>
9
#include <sys/syscall.h>
10
#include <sys/types.h>
11
#include <sys/wait.h>
12
#include <unistd.h>
13

14
#ifdef ARCH_MIPS
15
#include <asm/sgidefs.h>
16
#endif
17

18
#include "macro.h"
19
#include "missing_keyctl.h"
20
#include "missing_sched.h"
21
#include "missing_syscall_def.h"
22

23
/* ======================================================================= */
24

25
#if !HAVE_FCHMODAT2
26
/* since kernel v6.6 (78252deb023cf0879256fcfbafe37022c390762b) */
27
static inline int missing_fchmodat2(int dirfd, const char *path, mode_t mode, int flags) {
24,835✔
28
        return syscall(__NR_fchmodat2, dirfd, path, mode, flags);
24,835✔
29
}
30

31
#  define fchmodat2 missing_fchmodat2
32
#endif
33

34
/* ======================================================================= */
35

36
#if !HAVE_PIVOT_ROOT
37
static inline int missing_pivot_root(const char *new_root, const char *put_old) {
2,866✔
38
        return syscall(__NR_pivot_root, new_root, put_old);
2,866✔
39
}
40

41
#  define pivot_root missing_pivot_root
42
#endif
43

44
/* ======================================================================= */
45

46
#if !HAVE_IOPRIO_GET
47
static inline int missing_ioprio_get(int which, int who) {
2,088✔
48
        return syscall(__NR_ioprio_get, which, who);
2,088✔
49
}
50

51
#  define ioprio_get missing_ioprio_get
52
#endif
53

54
/* ======================================================================= */
55

56
#if !HAVE_IOPRIO_SET
57
static inline int missing_ioprio_set(int which, int who, int ioprio) {
11✔
58
        return syscall(__NR_ioprio_set, which, who, ioprio);
11✔
59
}
60

61
#  define ioprio_set missing_ioprio_set
62
#endif
63

64
/* ======================================================================= */
65

66
static inline pid_t raw_getpid(void) {
133,972✔
67
#if defined(__alpha__)
68
        return (pid_t) syscall(__NR_getxpid);
69
#else
70
        return (pid_t) syscall(__NR_getpid);
133,972✔
71
#endif
72
}
73

74
/* ======================================================================= */
75

76
#if !HAVE_KCMP
77
static inline int missing_kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) {
7,369✔
78
        return syscall(__NR_kcmp, pid1, pid2, type, idx1, idx2);
7,369✔
79
}
80

81
#  define kcmp missing_kcmp
82
#endif
83

84
/* ======================================================================= */
85

86
#if !HAVE_KEYCTL
87
static inline long missing_keyctl(int cmd, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5) {
21,993✔
88
        return syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5);
21,993✔
89

90
#  define keyctl missing_keyctl
91
}
92

93
/* ======================================================================= */
94

95
static inline key_serial_t missing_add_key(const char *type, const char *description, const void *payload, size_t plen, key_serial_t ringid) {
10,323✔
96
        return syscall(__NR_add_key, type, description, payload, plen, ringid);
10,323✔
97

98
#  define add_key missing_add_key
99
}
100

101
/* ======================================================================= */
102

103
static inline key_serial_t missing_request_key(const char *type, const char *description, const char * callout_info, key_serial_t destringid) {
12✔
104
        return syscall(__NR_request_key, type, description, callout_info, destringid);
12✔
105

106
#  define request_key missing_request_key
107
}
108
#endif
109

110
/* ======================================================================= */
111

112
#if !HAVE_BPF
113
union bpf_attr;
114

115
static inline int missing_bpf(int cmd, union bpf_attr *attr, size_t size) {
2,909✔
116
        return (int) syscall(__NR_bpf, cmd, attr, size);
2,909✔
117
}
118

119
#  define bpf missing_bpf
120
#endif
121

122
/* ======================================================================= */
123

124
#if !HAVE_SET_MEMPOLICY
125
enum {
126
        MPOL_DEFAULT,
127
        MPOL_PREFERRED,
128
        MPOL_BIND,
129
        MPOL_INTERLEAVE,
130
        MPOL_LOCAL,
131
};
132

133
static inline long missing_set_mempolicy(int mode, const unsigned long *nodemask,
17✔
134
                           unsigned long maxnode) {
135
        return syscall(__NR_set_mempolicy, mode, nodemask, maxnode);
17✔
136
}
137

138
#  define set_mempolicy missing_set_mempolicy
139
#endif
140

141
#if !HAVE_GET_MEMPOLICY
142
static inline long missing_get_mempolicy(int *mode, unsigned long *nodemask,
19✔
143
                           unsigned long maxnode, void *addr,
144
                           unsigned long flags) {
145
        return syscall(__NR_get_mempolicy, mode, nodemask, maxnode, addr, flags);
19✔
146
}
147

148
#  define get_mempolicy missing_get_mempolicy
149
#endif
150

151
/* ======================================================================= */
152

153
#if !HAVE_PIDFD_SEND_SIGNAL
154
/* since kernel v5.1 (3eb39f47934f9d5a3027fe00d906a45fe3a15fad) */
155
static inline int missing_pidfd_send_signal(int fd, int sig, siginfo_t *info, unsigned flags) {
156
        return syscall(__NR_pidfd_send_signal, fd, sig, info, flags);
157
}
158

159
#  define pidfd_send_signal missing_pidfd_send_signal
160
#endif
161

162
/* ======================================================================= */
163

164
#if !HAVE_PIDFD_OPEN
165
/* since kernel v5.3 (7615d9e1780e26e0178c93c55b73309a5dc093d7) */
166
static inline int missing_pidfd_open(pid_t pid, unsigned flags) {
167
        return syscall(__NR_pidfd_open, pid, flags);
168
}
169

170
#  define pidfd_open missing_pidfd_open
171
#endif
172

173
/* ======================================================================= */
174

175
#if !HAVE_RT_TGSIGQUEUEINFO
UNCOV
176
static inline int missing_rt_tgsigqueueinfo(pid_t tgid, pid_t tid, int sig, siginfo_t *info) {
×
UNCOV
177
        return syscall(__NR_rt_tgsigqueueinfo, tgid, tid, sig, info);
×
178
}
179

180
#  define rt_tgsigqueueinfo missing_rt_tgsigqueueinfo
181
#endif
182

183
/* ======================================================================= */
184

185
#if !HAVE_EXECVEAT
186
/* since kernel v3.19 (51f39a1f0cea1cacf8c787f652f26dfee9611874) */
187
static inline int missing_execveat(int dirfd, const char *pathname,
188
                                   char *const argv[], char *const envp[],
189
                                   int flags) {
190
        return syscall(__NR_execveat, dirfd, pathname, argv, envp, flags);
191
}
192

193
#  define execveat missing_execveat
194
#endif
195

196
/* ======================================================================= */
197

198
#if !HAVE_CLOSE_RANGE
199
/* since kernel v5.9 (9b4feb630e8e9801603f3cab3a36369e3c1cf88d) */
200
static inline int missing_close_range(unsigned first_fd, unsigned end_fd, unsigned flags) {
201
        /* Kernel-side the syscall expects fds as unsigned integers (just like close() actually), while
202
         * userspace exclusively uses signed integers for fds. glibc chose to expose it 1:1 however, hence we
203
         * do so here too, even if we end up passing signed fds to it most of the time. */
204
        return syscall(__NR_close_range,
205
                       first_fd,
206
                       end_fd,
207
                       flags);
208
}
209

210
#  define close_range missing_close_range
211
#endif
212

213
/* ======================================================================= */
214

215
#if !HAVE_SCHED_SETATTR
216
/* since kernel 3.14 (e6cfc0295c7d51b008999a8b13a44fb43f8685ea) */
217
static inline ssize_t missing_sched_setattr(pid_t pid, struct sched_attr *attr, unsigned int flags) {
218
        return syscall(__NR_sched_setattr, pid, attr, flags);
219
}
220

221
#  define sched_setattr missing_sched_setattr
222
#endif
223

224
/* ======================================================================= */
225

226
/* glibc does not provide clone() on ia64, only clone2(). Not only that, but it also doesn't provide a
227
 * prototype, only the symbol in the shared library (it provides a prototype for clone(), but not the
228
 * symbol in the shared library). */
229
#if defined(__ia64__)
230
int __clone2(int (*fn)(void *), void *stack_base, size_t stack_size, int flags, void *arg);
231
#define HAVE_CLONE 0
232
#else
233
/* We know that everywhere else clone() is available, so we don't bother with a meson check (that takes time
234
 * at build time) and just define it. Once the kernel drops ia64 support, we can drop this too. */
235
#define HAVE_CLONE 1
236
#endif
237

238
/* ======================================================================= */
239

240
#if !HAVE_QUOTACTL_FD
241
/* since kernel v5.14 (64c2c2c62f92339b176ea24403d8db16db36f9e6) */
242
static inline int missing_quotactl_fd(int fd, int cmd, int id, void *addr) {
312✔
243
        return syscall(__NR_quotactl_fd, fd, cmd, id, addr);
312✔
244
}
245

246
#  define quotactl_fd missing_quotactl_fd
247
#endif
248

249
/* ======================================================================= */
250

251
#if !HAVE_SETXATTRAT
252
/* since kernel v6.13 (6140be90ec70c39fa844741ca3cc807dd0866394) */
253
struct xattr_args {
254
        _align_(8) uint64_t value;
255
        uint32_t size;
256
        uint32_t flags;
257
};
258

259
static inline int missing_setxattrat(int fd, const char *path, int at_flags, const char *name, const struct xattr_args *args, size_t size) {
1✔
260
        return syscall(__NR_setxattrat, fd, path, at_flags, name, args, size);
1✔
261
}
262

263
#  define setxattrat missing_setxattrat
264
#endif
265

266
/* ======================================================================= */
267

268
#if !HAVE_REMOVEXATTRAT
269
/* since kernel v6.13 (6140be90ec70c39fa844741ca3cc807dd0866394) */
UNCOV
270
static inline int missing_removexattrat(int fd, const char *path, int at_flags, const char *name) {
×
UNCOV
271
        return syscall(__NR_removexattrat, fd, path, at_flags, name);
×
272
}
273

274
#  define removexattrat missing_removexattrat
275
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc