]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/macro.h
3 * Copyright © 2018 Christian Brauner <christian.brauner@ubuntu.com>.
4 * Copyright © 2018 Canonical Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 /* Define __S_ISTYPE if missing from the C library. */
25 #define __S_ISTYPE(mode, mask) (((mode)&S_IFMT) == (mask))
30 #define CAP_SETFCAP 31
33 #ifndef CAP_MAC_OVERRIDE
34 #define CAP_MAC_OVERRIDE 32
38 #define CAP_MAC_ADMIN 33
42 #ifndef PR_CAPBSET_DROP
43 #define PR_CAPBSET_DROP 24
46 #ifndef LO_FLAGS_AUTOCLEAR
47 #define LO_FLAGS_AUTOCLEAR 4
58 /* needed for cgroup automount checks, regardless of whether we
59 * have included linux/capability.h or not */
61 #define CAP_SYS_ADMIN 21
64 #ifndef CGROUP_SUPER_MAGIC
65 #define CGROUP_SUPER_MAGIC 0x27e0eb
68 #ifndef CGROUP2_SUPER_MAGIC
69 #define CGROUP2_SUPER_MAGIC 0x63677270
73 #define NSFS_MAGIC 0x6e736673
77 /* Maximum number for 64 bit integer is a string with 21 digits: 2^64 - 1 = 21 */
78 #define LXC_NUMSTRLEN64 21
79 #define LXC_LINELEN 4096
80 #define LXC_IDMAPLEN 4096
81 #define LXC_MAX_BUFFER 4096
84 * <pid-as-str> = LXC_NUMSTRLEN64
88 * <fd-as-str> = LXC_NUMSTRLEN64
92 #define LXC_PROC_PID_FD_LEN (6 + LXC_NUMSTRLEN64 + 4 + LXC_NUMSTRLEN64 + 1)
95 #ifndef LO_FLAGS_AUTOCLEAR
96 #define LO_FLAGS_AUTOCLEAR 4
99 #ifndef LOOP_CTL_GET_FREE
100 #define LOOP_CTL_GET_FREE 0x4C82
105 #define MFD_CLOEXEC 0x0001U
108 #ifndef MFD_ALLOW_SEALING
109 #define MFD_ALLOW_SEALING 0x0002U
113 * BUILD_BUG_ON - break compile if a condition is true.
114 * @condition: the condition which the compiler should know is false.
116 * If you have some code which relies on certain constants being equal, or
117 * other compile-time-evaluated condition, you should use BUILD_BUG_ON to
118 * detect if someone changes it.
120 * The implementation uses gcc's reluctance to create a negative array, but
121 * gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments
122 * to inline functions). So as a fallback we use the optimizer; if it can't
123 * prove the condition is false, it will cause a link error on the undefined
124 * "__build_bug_on_failed". This error message can be harder to track down
125 * though, hence the two different methods.
128 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
130 extern int __build_bug_on_failed
;
131 #define BUILD_BUG_ON(condition) \
133 ((void)sizeof(char[1 - 2*!!(condition)])); \
134 if (condition) __build_bug_on_failed = 1; \
138 #define lxc_iterate_parts(__iterator, __splitme, __separators) \
139 for (char *__p = NULL, *__it = strtok_r(__splitme, __separators, &__p); \
140 (__iterator = __it); \
141 __iterator = __it = strtok_r(NULL, __separators, &__p))
143 #define prctl_arg(x) ((unsigned long)x)
146 #ifndef IFLA_LINKMODE
147 #define IFLA_LINKMODE 17
150 #ifndef IFLA_LINKINFO
151 #define IFLA_LINKINFO 18
154 #ifndef IFLA_NET_NS_PID
155 #define IFLA_NET_NS_PID 19
158 #ifndef IFLA_INFO_KIND
159 #define IFLA_INFO_KIND 1
163 #define IFLA_VLAN_ID 1
166 #ifndef IFLA_INFO_DATA
167 #define IFLA_INFO_DATA 2
170 #ifndef VETH_INFO_PEER
171 #define VETH_INFO_PEER 1
174 #ifndef IFLA_MACVLAN_MODE
175 #define IFLA_MACVLAN_MODE 1
178 #ifndef IFLA_NEW_NETNSID
179 #define IFLA_NEW_NETNSID 45
182 #ifndef IFLA_IF_NETNSID
183 #define IFLA_IF_NETNSID 46
186 #endif /* __LXC_MACRO_H */