xref: /aosp_15_r20/external/minijail/gen_constants-inl.h (revision 4b9c6d91573e8b3a96609339b46361b5476dd0f9)
1*4b9c6d91SCole Faust /* Copyright 2014 The ChromiumOS Authors
2*4b9c6d91SCole Faust  * Use of this source code is governed by a BSD-style license that can be
3*4b9c6d91SCole Faust  * found in the LICENSE file.
4*4b9c6d91SCole Faust  */
5*4b9c6d91SCole Faust 
6*4b9c6d91SCole Faust #if defined(__i386__) || defined(__x86_64__)
7*4b9c6d91SCole Faust #include <asm/prctl.h>
8*4b9c6d91SCole Faust #endif /* __i386__ || __x86_64__ */
9*4b9c6d91SCole Faust #include <errno.h>
10*4b9c6d91SCole Faust #include <fcntl.h>
11*4b9c6d91SCole Faust #include <linux/fd.h>
12*4b9c6d91SCole Faust #include <linux/fs.h>
13*4b9c6d91SCole Faust #include <linux/loop.h>
14*4b9c6d91SCole Faust #include <linux/mman.h>
15*4b9c6d91SCole Faust #include <linux/net.h>
16*4b9c6d91SCole Faust #include <linux/prctl.h>
17*4b9c6d91SCole Faust #include <linux/sched.h>
18*4b9c6d91SCole Faust #include <linux/serial.h>
19*4b9c6d91SCole Faust #include <linux/sockios.h>
20*4b9c6d91SCole Faust #include <linux/termios.h>
21*4b9c6d91SCole Faust #include <signal.h>
22*4b9c6d91SCole Faust #include <stddef.h>
23*4b9c6d91SCole Faust #include <sys/mman.h>
24*4b9c6d91SCole Faust #include <sys/resource.h>
25*4b9c6d91SCole Faust #include <sys/socket.h>
26*4b9c6d91SCole Faust #include <sys/stat.h>
27*4b9c6d91SCole Faust #include <sys/types.h>
28*4b9c6d91SCole Faust 
29*4b9c6d91SCole Faust #include "arch.h"
30*4b9c6d91SCole Faust 
31*4b9c6d91SCole Faust /* These defines use C structures that are not defined in the same headers which
32*4b9c6d91SCole Faust  * cause our CPP logic to fail w/undefined identifiers.  Remove them to avoid
33*4b9c6d91SCole Faust  * build errors on such broken systems.
34*4b9c6d91SCole Faust  */
35*4b9c6d91SCole Faust #undef BLKTRACESETUP
36*4b9c6d91SCole Faust #undef FS_IOC_FIEMAP
37*4b9c6d91SCole Faust 
38*4b9c6d91SCole Faust /* The old glibc bundled with the Android host toolchain is missing some ioctl
39*4b9c6d91SCole Faust  * definitions used by minijail policy in crosvm and other projects. Locally
40*4b9c6d91SCole Faust  * define them below.
41*4b9c6d91SCole Faust  * This UAPI is taken from sanitized bionic headers.
42*4b9c6d91SCole Faust  */
43*4b9c6d91SCole Faust 
44*4b9c6d91SCole Faust /* <linux/fs.h> */
45*4b9c6d91SCole Faust #if !defined(FS_IOC_FSGETXATTR) && !defined(FS_IOC_FSSETXATTR)
46*4b9c6d91SCole Faust struct fsxattr {
47*4b9c6d91SCole Faust 	__u32 fsx_xflags;
48*4b9c6d91SCole Faust 	__u32 fsx_extsize;
49*4b9c6d91SCole Faust 	__u32 fsx_nextents;
50*4b9c6d91SCole Faust 	__u32 fsx_projid;
51*4b9c6d91SCole Faust 	__u32 fsx_cowextsize;
52*4b9c6d91SCole Faust 	unsigned char fsx_pad[8];
53*4b9c6d91SCole Faust };
54*4b9c6d91SCole Faust #define FS_IOC_FSGETXATTR _IOR('X', 31, struct fsxattr)
55*4b9c6d91SCole Faust #define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr)
56*4b9c6d91SCole Faust #endif /* !FS_IOC_FSGETXATTR && !FS_IOC_FSSETXATTR */
57*4b9c6d91SCole Faust 
58*4b9c6d91SCole Faust /* <linux/fscrypt.h> */
59*4b9c6d91SCole Faust #if !defined(FS_IOC_SET_ENCRYPTION_POLICY) &&                                  \
60*4b9c6d91SCole Faust     !defined(FS_IOC_GET_ENCRYPTION_POLICY)
61*4b9c6d91SCole Faust #define FSCRYPT_KEY_DESCRIPTOR_SIZE 8
62*4b9c6d91SCole Faust struct fscrypt_policy_v1 {
63*4b9c6d91SCole Faust 	__u8 version;
64*4b9c6d91SCole Faust 	__u8 contents_encryption_mode;
65*4b9c6d91SCole Faust 	__u8 filenames_encryption_mode;
66*4b9c6d91SCole Faust 	__u8 flags;
67*4b9c6d91SCole Faust 	__u8 master_key_descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE];
68*4b9c6d91SCole Faust };
69*4b9c6d91SCole Faust #define fscrypt_policy fscrypt_policy_v1
70*4b9c6d91SCole Faust #define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy)
71*4b9c6d91SCole Faust #define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy)
72*4b9c6d91SCole Faust #endif /* !FS_IOC_SET_ENCRYPTION_POLICY && !FS_IOC_GET_ENCRYPTION_POLICY */
73*4b9c6d91SCole Faust #if !defined(FS_IOC_GET_ENCRYPTION_POLICY_EX)
74*4b9c6d91SCole Faust #define FS_IOC_GET_ENCRYPTION_POLICY_EX _IOWR('f', 22, __u8[9])
75*4b9c6d91SCole Faust #endif
76*4b9c6d91SCole Faust 
77*4b9c6d91SCole Faust #if !defined(MADV_FREE)
78*4b9c6d91SCole Faust #define MADV_FREE 8
79*4b9c6d91SCole Faust #endif
80