12 #ifndef _LINUX_CAPABILITY_H
13 #define _LINUX_CAPABILITY_H
18 #define _KERNEL_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_3
19 #define _KERNEL_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_3
34 #define _USER_CAP_HEADER_SIZE (sizeof(struct __user_cap_header_struct))
35 #define _KERNEL_CAP_T_SIZE (sizeof(kernel_cap_t))
51 #define CAP_FOR_EACH_U32(__capi) \
52 for (__capi = 0; __capi < _KERNEL_CAPABILITY_U32S; ++__capi)
67 # define CAP_FS_MASK_B0 (CAP_TO_MASK(CAP_CHOWN) \
68 | CAP_TO_MASK(CAP_MKNOD) \
69 | CAP_TO_MASK(CAP_DAC_OVERRIDE) \
70 | CAP_TO_MASK(CAP_DAC_READ_SEARCH) \
71 | CAP_TO_MASK(CAP_FOWNER) \
72 | CAP_TO_MASK(CAP_FSETID))
74 # define CAP_FS_MASK_B1 (CAP_TO_MASK(CAP_MAC_OVERRIDE))
76 #if _KERNEL_CAPABILITY_U32S != 2
77 # error Fix up hand-coded capability macro initializers
80 # define CAP_EMPTY_SET ((kernel_cap_t){{ 0, 0 }})
81 # define CAP_FULL_SET ((kernel_cap_t){{ ~0, ~0 }})
82 # define CAP_FS_SET ((kernel_cap_t){{ CAP_FS_MASK_B0 \
83 | CAP_TO_MASK(CAP_LINUX_IMMUTABLE), \
85 # define CAP_NFSD_SET ((kernel_cap_t){{ CAP_FS_MASK_B0 \
86 | CAP_TO_MASK(CAP_SYS_RESOURCE), \
91 # define cap_clear(c) do { (c) = __cap_empty_set; } while (0)
93 #define cap_raise(c, flag) ((c).cap[CAP_TO_INDEX(flag)] |= CAP_TO_MASK(flag))
94 #define cap_lower(c, flag) ((c).cap[CAP_TO_INDEX(flag)] &= ~CAP_TO_MASK(flag))
95 #define cap_raised(c, flag) ((c).cap[CAP_TO_INDEX(flag)] & CAP_TO_MASK(flag))
97 #define CAP_BOP_ALL(c, a, b, OP) \
100 CAP_FOR_EACH_U32(__capi) { \
101 c.cap[__capi] = a.cap[__capi] OP b.cap[__capi]; \
105 #define CAP_UOP_ALL(c, a, OP) \
108 CAP_FOR_EACH_U32(__capi) { \
109 c.cap[__capi] = OP a.cap[__capi]; \
148 if (a.
cap[__capi] != 0)
164 dest = cap_drop(a,
set);
165 return cap_isclear(dest);
170 static inline int cap_is_fs_cap(
int cap)
179 return cap_drop(a, __cap_fs_set);
186 return cap_combine(a,
187 cap_intersect(permitted, __cap_fs_set));
193 return cap_drop(a, __cap_fs_set);
200 return cap_combine(a,
201 cap_intersect(permitted, __cap_nfsd_set));