1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*
18  * Taken from linux/capability.h, with minor modifications
19  */
20 
21 #ifndef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_FILESYSTEM_CAPABILITY_H
22 #define _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_FILESYSTEM_CAPABILITY_H
23 
24 #include <stdint.h>
25 
26 #define __user
27 #define __u32 uint32_t
28 #define __le32 uint32_t
29 
30 #define _LINUX_CAPABILITY_VERSION_1 0x19980330
31 #define _LINUX_CAPABILITY_U32S_1 1
32 #define _LINUX_CAPABILITY_VERSION_2 0x20071026
33 #define _LINUX_CAPABILITY_U32S_2 2
34 #define _LINUX_CAPABILITY_VERSION_3 0x20080522
35 #define _LINUX_CAPABILITY_U32S_3 2
36 
37 typedef struct __user_cap_header_struct {
38  __u32 version;
39  int pid;
40 } __user *cap_user_header_t;
41 
42 typedef struct __user_cap_data_struct {
43  __u32 effective;
44  __u32 permitted;
45  __u32 inheritable;
46 } __user *cap_user_data_t;
47 
48 #define VFS_CAP_REVISION_MASK 0xFF000000
49 #define VFS_CAP_REVISION_SHIFT 24
50 #define VFS_CAP_FLAGS_MASK ~VFS_CAP_REVISION_MASK
51 #define VFS_CAP_FLAGS_EFFECTIVE 0x000001
52 #define VFS_CAP_REVISION_1 0x01000000
53 #define VFS_CAP_U32_1 1
54 #define XATTR_CAPS_SZ_1 (sizeof(__le32)*(1 + 2*VFS_CAP_U32_1))
55 #define VFS_CAP_REVISION_2 0x02000000
56 #define VFS_CAP_U32_2 2
57 #define XATTR_CAPS_SZ_2 (sizeof(__le32)*(1 + 2*VFS_CAP_U32_2))
58 #define XATTR_CAPS_SZ XATTR_CAPS_SZ_2
59 #define VFS_CAP_U32 VFS_CAP_U32_2
60 #define VFS_CAP_REVISION VFS_CAP_REVISION_2
61 
62 struct vfs_cap_data {
63  __le32 magic_etc;
64  struct {
65  __le32 permitted;
66  __le32 inheritable;
67  } data[VFS_CAP_U32];
68 };
69 
70 #define _LINUX_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_1
71 #define _LINUX_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_1
72 #define CAP_CHOWN 0
73 #define CAP_DAC_OVERRIDE 1
74 #define CAP_DAC_READ_SEARCH 2
75 #define CAP_FOWNER 3
76 #define CAP_FSETID 4
77 #define CAP_KILL 5
78 #define CAP_SETGID 6
79 #define CAP_SETUID 7
80 #define CAP_SETPCAP 8
81 #define CAP_LINUX_IMMUTABLE 9
82 #define CAP_NET_BIND_SERVICE 10
83 #define CAP_NET_BROADCAST 11
84 #define CAP_NET_ADMIN 12
85 #define CAP_NET_RAW 13
86 #define CAP_IPC_LOCK 14
87 #define CAP_IPC_OWNER 15
88 #define CAP_SYS_MODULE 16
89 #define CAP_SYS_RAWIO 17
90 #define CAP_SYS_CHROOT 18
91 #define CAP_SYS_PTRACE 19
92 #define CAP_SYS_PACCT 20
93 #define CAP_SYS_ADMIN 21
94 #define CAP_SYS_BOOT 22
95 #define CAP_SYS_NICE 23
96 #define CAP_SYS_RESOURCE 24
97 #define CAP_SYS_TIME 25
98 #define CAP_SYS_TTY_CONFIG 26
99 #define CAP_MKNOD 27
100 #define CAP_LEASE 28
101 #define CAP_AUDIT_WRITE 29
102 #define CAP_AUDIT_CONTROL 30
103 #define CAP_SETFCAP 31
104 #define CAP_MAC_OVERRIDE 32
105 #define CAP_MAC_ADMIN 33
106 #define CAP_SYSLOG 34
107 #define CAP_WAKE_ALARM 35
108 #define CAP_BLOCK_SUSPEND 36
109 #define CAP_AUDIT_READ 37
110 #define CAP_LAST_CAP CAP_AUDIT_READ
111 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
112 #define CAP_TO_INDEX(x) ((x) >> 5)
113 #define CAP_TO_MASK(x) (1 << ((x) & 31))
114 
115 #undef __user
116 #undef __u32
117 #undef __le32
118 
119 #endif
120