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