]>
Commit | Line | Data |
---|---|---|
03467c88 | 1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
15ae422b | 2 | |
c2f1db8f | 3 | #pragma once |
b9f880f4 | 4 | |
15ae422b LP |
5 | /*** |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2010 Lennart Poettering | |
9 | ||
10 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
11 | under the terms of the GNU Lesser General Public License as published by |
12 | the Free Software Foundation; either version 2.1 of the License, or | |
15ae422b LP |
13 | (at your option) any later version. |
14 | ||
15 | systemd is distributed in the hope that it will be useful, but | |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 18 | Lesser General Public License for more details. |
15ae422b | 19 | |
5430f7f2 | 20 | You should have received a copy of the GNU Lesser General Public License |
15ae422b LP |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
22 | ***/ | |
23 | ||
b9f880f4 LP |
24 | /* Missing glibc definitions to access certain kernel APIs */ |
25 | ||
26 | #include <sys/resource.h> | |
15ae422b | 27 | #include <sys/syscall.h> |
16c42ce1 | 28 | #include <fcntl.h> |
82c121a4 | 29 | #include <unistd.h> |
dd6c17b1 LP |
30 | #include <linux/oom.h> |
31 | ||
32 | #ifdef HAVE_AUDIT | |
33 | #include <libaudit.h> | |
34 | #endif | |
b9f880f4 | 35 | |
ad780f19 LP |
36 | #include "macro.h" |
37 | ||
d59d0a2b | 38 | #ifdef ARCH_MIPS |
39 | #include <asm/sgidefs.h> | |
40 | #endif | |
41 | ||
b9f880f4 LP |
42 | #ifndef RLIMIT_RTTIME |
43 | #define RLIMIT_RTTIME 15 | |
44 | #endif | |
45 | ||
4fd5948e LP |
46 | #ifndef F_LINUX_SPECIFIC_BASE |
47 | #define F_LINUX_SPECIFIC_BASE 1024 | |
48 | #endif | |
49 | ||
50 | #ifndef F_SETPIPE_SZ | |
51 | #define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7) | |
52 | #endif | |
53 | ||
54 | #ifndef F_GETPIPE_SZ | |
55 | #define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8) | |
56 | #endif | |
57 | ||
16c42ce1 KS |
58 | #ifndef IP_FREEBIND |
59 | #define IP_FREEBIND 15 | |
60 | #endif | |
61 | ||
dd6c17b1 LP |
62 | #ifndef OOM_SCORE_ADJ_MIN |
63 | #define OOM_SCORE_ADJ_MIN (-1000) | |
64 | #endif | |
65 | ||
66 | #ifndef OOM_SCORE_ADJ_MAX | |
67 | #define OOM_SCORE_ADJ_MAX 1000 | |
68 | #endif | |
15ae422b | 69 | |
4927fcae | 70 | #ifndef AUDIT_SERVICE_START |
dd6c17b1 | 71 | #define AUDIT_SERVICE_START 1130 /* Service (daemon) start */ |
4927fcae LP |
72 | #endif |
73 | ||
74 | #ifndef AUDIT_SERVICE_STOP | |
dd6c17b1 | 75 | #define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */ |
4927fcae LP |
76 | #endif |
77 | ||
6ea832a2 LP |
78 | #ifndef TIOCVHANGUP |
79 | #define TIOCVHANGUP 0x5437 | |
80 | #endif | |
81 | ||
b90865ba KS |
82 | #ifndef IP_TRANSPARENT |
83 | #define IP_TRANSPARENT 19 | |
84 | #endif | |
85 | ||
a8348796 | 86 | #if !HAVE_DECL_PIVOT_ROOT |
dd6c17b1 LP |
87 | static inline int pivot_root(const char *new_root, const char *put_old) { |
88 | return syscall(SYS_pivot_root, new_root, put_old); | |
89 | } | |
a8348796 | 90 | #endif |
dd6c17b1 | 91 | |
22be093f | 92 | #ifdef __x86_64__ |
d59d0a2b | 93 | # ifndef __NR_fanotify_init |
94 | # define __NR_fanotify_init 300 | |
95 | # endif | |
96 | # ifndef __NR_fanotify_mark | |
97 | # define __NR_fanotify_mark 301 | |
98 | # endif | |
99 | #elif defined _MIPS_SIM | |
100 | # if _MIPS_SIM == _MIPS_SIM_ABI32 | |
101 | # ifndef __NR_fanotify_init | |
102 | # define __NR_fanotify_init 4336 | |
103 | # endif | |
104 | # ifndef __NR_fanotify_mark | |
105 | # define __NR_fanotify_mark 4337 | |
106 | # endif | |
107 | # elif _MIPS_SIM == _MIPS_SIM_NABI32 | |
108 | # ifndef __NR_fanotify_init | |
109 | # define __NR_fanotify_init 6300 | |
110 | # endif | |
111 | # ifndef __NR_fanotify_mark | |
112 | # define __NR_fanotify_mark 6301 | |
113 | # endif | |
114 | # elif _MIPS_SIM == _MIPS_SIM_ABI64 | |
115 | # ifndef __NR_fanotify_init | |
116 | # define __NR_fanotify_init 5295 | |
117 | # endif | |
118 | # ifndef __NR_fanotify_mark | |
119 | # define __NR_fanotify_mark 5296 | |
120 | # endif | |
121 | # endif | |
22be093f | 122 | #else |
d59d0a2b | 123 | # ifndef __NR_fanotify_init |
124 | # define __NR_fanotify_init 338 | |
125 | # endif | |
126 | # ifndef __NR_fanotify_mark | |
127 | # define __NR_fanotify_mark 339 | |
128 | # endif | |
22be093f LP |
129 | #endif |
130 | ||
a8348796 | 131 | #ifndef HAVE_FANOTIFY_INIT |
22be093f | 132 | static inline int fanotify_init(unsigned int flags, unsigned int event_f_flags) { |
05115020 | 133 | return syscall(__NR_fanotify_init, flags, event_f_flags); |
22be093f | 134 | } |
a8348796 | 135 | #endif |
22be093f | 136 | |
a8348796 | 137 | #ifndef HAVE_FANOTIFY_MARK |
05115020 | 138 | static inline int fanotify_mark(int fanotify_fd, unsigned int flags, uint64_t mask, |
22be093f | 139 | int dfd, const char *pathname) { |
990478a0 | 140 | #if defined _MIPS_SIM && _MIPS_SIM == _MIPS_SIM_ABI32 || defined __powerpc__ && !defined __powerpc64__ |
373c23b2 | 141 | union { |
142 | uint64_t _64; | |
143 | uint32_t _32[2]; | |
144 | } _mask; | |
145 | _mask._64 = mask; | |
146 | ||
147 | return syscall(__NR_fanotify_mark, fanotify_fd, flags, | |
148 | _mask._32[0], _mask._32[1], dfd, pathname); | |
149 | #else | |
05115020 | 150 | return syscall(__NR_fanotify_mark, fanotify_fd, flags, mask, dfd, pathname); |
373c23b2 | 151 | #endif |
22be093f | 152 | } |
a8348796 | 153 | #endif |
22be093f | 154 | |
746f8906 LP |
155 | #ifndef BTRFS_IOCTL_MAGIC |
156 | #define BTRFS_IOCTL_MAGIC 0x94 | |
157 | #endif | |
158 | ||
159 | #ifndef BTRFS_PATH_NAME_MAX | |
160 | #define BTRFS_PATH_NAME_MAX 4087 | |
161 | #endif | |
162 | ||
163 | struct btrfs_ioctl_vol_args { | |
164 | int64_t fd; | |
165 | char name[BTRFS_PATH_NAME_MAX + 1]; | |
166 | }; | |
167 | ||
168 | #ifndef BTRFS_IOC_DEFRAG | |
169 | #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, struct btrfs_ioctl_vol_args) | |
170 | #endif | |
171 | ||
172 | #ifndef BTRFS_SUPER_MAGIC | |
173 | #define BTRFS_SUPER_MAGIC 0x9123683E | |
174 | #endif | |
175 | ||
94d82985 LP |
176 | #ifndef MS_MOVE |
177 | #define MS_MOVE 8192 | |
178 | #endif | |
179 | ||
7cb1094a HH |
180 | #ifndef MS_PRIVATE |
181 | #define MS_PRIVATE (1 << 18) | |
182 | #endif | |
183 | ||
a8348796 | 184 | #if !HAVE_DECL_GETTID |
4d14be09 LP |
185 | static inline pid_t gettid(void) { |
186 | return (pid_t) syscall(SYS_gettid); | |
187 | } | |
a8348796 | 188 | #endif |
4d14be09 | 189 | |
54ecda32 LP |
190 | #ifndef SCM_SECURITY |
191 | #define SCM_SECURITY 0x03 | |
192 | #endif | |
193 | ||
48ac500b LP |
194 | #ifndef MS_STRICTATIME |
195 | #define MS_STRICTATIME (1<<24) | |
196 | #endif | |
197 | ||
8351ceae LP |
198 | #ifndef PR_SET_NO_NEW_PRIVS |
199 | #define PR_SET_NO_NEW_PRIVS 38 | |
200 | #endif | |
d4447f4d AK |
201 | |
202 | #ifndef PR_SET_CHILD_SUBREAPER | |
203 | #define PR_SET_CHILD_SUBREAPER 36 | |
204 | #endif | |
a8348796 LP |
205 | |
206 | #ifndef MAX_HANDLE_SZ | |
207 | #define MAX_HANDLE_SZ 128 | |
208 | #endif | |
209 | ||
210 | #ifdef __x86_64__ | |
211 | # ifndef __NR_name_to_handle | |
212 | # define __NR_name_to_handle 303 | |
213 | # endif | |
214 | #else | |
215 | # ifndef __NR_name_to_handle | |
216 | # define __NR_name_to_handle 341 | |
217 | # endif | |
218 | #endif | |
219 | ||
220 | #ifndef HAVE_NAME_TO_HANDLE_AT | |
221 | ||
222 | struct file_handle { | |
223 | unsigned int handle_bytes; | |
224 | int handle_type; | |
225 | unsigned char f_handle[0]; | |
226 | }; | |
227 | ||
228 | static inline int name_to_handle_at(int fd, const char *name, struct file_handle *handle, int *mnt_id, int flags) { | |
229 | return syscall(__NR_name_to_handle_at, fd, name, handle, mnt_id, flags); | |
230 | } | |
231 | #endif |