Nick Kralevich | f3ef127 | 2012-03-14 15:22:54 -0700 | [diff] [blame] | 1 | # Copyright (C) 2012 The Android Open Source Project |
| 2 | # |
| 3 | # IMPORTANT: Do not create world writable files or directories. |
| 4 | # This is a common source of Android security bugs. |
| 5 | # |
| 6 | |
Ying Wang | 5748ee9 | 2013-07-23 18:03:37 -0700 | [diff] [blame] | 7 | import /init.environ.rc |
Tom Cherry | c9f5353 | 2019-11-04 10:30:36 -0800 | [diff] [blame] | 8 | import /system/etc/init/hw/init.usb.rc |
Mike Lockwood | 35ea5e4 | 2012-08-28 10:25:13 -0700 | [diff] [blame] | 9 | import /init.${ro.hardware}.rc |
Yueyao Zhu | f7c34ad | 2017-05-18 12:46:34 -0700 | [diff] [blame] | 10 | import /vendor/etc/init/hw/init.${ro.hardware}.rc |
Tom Cherry | c9f5353 | 2019-11-04 10:30:36 -0800 | [diff] [blame] | 11 | import /system/etc/init/hw/init.usb.configfs.rc |
| 12 | import /system/etc/init/hw/init.${ro.zygote}.rc |
Dima Zavin | 7634bf8 | 2011-12-16 14:23:22 -0800 | [diff] [blame] | 13 | |
Suren Baghdasaryan | 192aee7 | 2018-12-21 11:41:50 -0800 | [diff] [blame] | 14 | # Cgroups are mounted right before early-init using list from /etc/cgroups.json |
Colin Cross | f83d0b9 | 2010-04-21 12:04:20 -0700 | [diff] [blame] | 15 | on early-init |
Nick Kralevich | d28a535 | 2015-10-09 17:09:10 -0700 | [diff] [blame] | 16 | # Disable sysrq from keyboard |
| 17 | write /proc/sys/kernel/sysrq 0 |
| 18 | |
Eric Biggers | 843f46e | 2020-03-11 09:56:15 -0700 | [diff] [blame] | 19 | # Android doesn't need kernel module autoloading, and it causes SELinux |
| 20 | # denials. So disable it by setting modprobe to the empty string. Note: to |
| 21 | # explicitly set a sysctl to an empty string, a trailing newline is needed. |
| 22 | write /proc/sys/kernel/modprobe \n |
| 23 | |
Stephen Smalley | deb41e5 | 2013-10-01 09:21:47 -0400 | [diff] [blame] | 24 | # Set the security context of /adb_keys if present. |
| 25 | restorecon /adb_keys |
| 26 | |
Alex Deymo | bb968fb | 2016-02-29 17:23:36 -0800 | [diff] [blame] | 27 | # Set the security context of /postinstall if present. |
| 28 | restorecon /postinstall |
| 29 | |
Robert Benea | c638569 | 2017-05-31 16:07:53 -0700 | [diff] [blame] | 30 | mkdir /acct/uid |
| 31 | |
Mark Salyzyn | 64d97d8 | 2018-04-09 09:50:32 -0700 | [diff] [blame] | 32 | # memory.pressure_level used by lmkd |
| 33 | chown root system /dev/memcg/memory.pressure_level |
| 34 | chmod 0040 /dev/memcg/memory.pressure_level |
Robert Benea | c638569 | 2017-05-31 16:07:53 -0700 | [diff] [blame] | 35 | # app mem cgroups, used by activity manager, lmkd and zygote |
| 36 | mkdir /dev/memcg/apps/ 0755 system system |
Robert Benea | 3280e48 | 2017-06-27 23:09:03 -0700 | [diff] [blame] | 37 | # cgroup for system_server and surfaceflinger |
| 38 | mkdir /dev/memcg/system 0550 system system |
Robert Benea | c638569 | 2017-05-31 16:07:53 -0700 | [diff] [blame] | 39 | |
Maciej Żenczykowski | 00a21e3 | 2020-01-25 00:34:33 -0800 | [diff] [blame] | 40 | # symlink the Android specific /dev/tun to Linux expected /dev/net/tun |
| 41 | mkdir /dev/net 0755 root root |
| 42 | symlink ../tun /dev/net/tun |
| 43 | |
Tom Cherry | fdeca99 | 2019-06-06 11:05:52 -0700 | [diff] [blame] | 44 | # set RLIMIT_NICE to allow priorities from 19 to -20 |
| 45 | setrlimit nice 40 40 |
| 46 | |
| 47 | # Allow up to 32K FDs per process |
| 48 | setrlimit nofile 32768 32768 |
| 49 | |
Kiyoung Kim | e4d3f21 | 2019-12-16 14:31:04 +0900 | [diff] [blame] | 50 | # Set up linker config subdirectories based on mount namespaces |
| 51 | mkdir /linkerconfig/bootstrap 0755 |
| 52 | mkdir /linkerconfig/default 0755 |
| 53 | |
Martijn Coenen | 9226bb3 | 2019-12-16 09:59:08 +0100 | [diff] [blame] | 54 | # Disable dm-verity hash prefetching, since it doesn't help performance |
| 55 | # Read more in b/136247322 |
| 56 | write /sys/module/dm_verity/parameters/prefetch_cluster 0 |
| 57 | |
Kiyoung Kim | 74c2292 | 2019-07-08 18:59:50 +0900 | [diff] [blame] | 58 | # Generate ld.config.txt for early executed processes |
Kiyoung Kim | 03b9bca | 2020-11-30 14:49:36 +0900 | [diff] [blame] | 59 | exec -- /system/bin/bootstrap/linkerconfig --target /linkerconfig/bootstrap |
Kiyoung Kim | e4d3f21 | 2019-12-16 14:31:04 +0900 | [diff] [blame] | 60 | chmod 644 /linkerconfig/bootstrap/ld.config.txt |
| 61 | copy /linkerconfig/bootstrap/ld.config.txt /linkerconfig/default/ld.config.txt |
| 62 | chmod 644 /linkerconfig/default/ld.config.txt |
| 63 | |
| 64 | # Mount bootstrap linker configuration as current |
| 65 | mount none /linkerconfig/bootstrap /linkerconfig bind rec |
Kiyoung Kim | 74c2292 | 2019-07-08 18:59:50 +0900 | [diff] [blame] | 66 | |
Colin Cross | f83d0b9 | 2010-04-21 12:04:20 -0700 | [diff] [blame] | 67 | start ueventd |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 68 | |
Jiyong Park | dcbaf9f | 2019-02-22 22:15:25 +0900 | [diff] [blame] | 69 | # Run apexd-bootstrap so that APEXes that provide critical libraries |
| 70 | # become available. Note that this is executed as exec_start to ensure that |
| 71 | # the libraries are available to the processes started after this statement. |
| 72 | exec_start apexd-bootstrap |
| 73 | |
Kiyoung Kim | e4d3f21 | 2019-12-16 14:31:04 +0900 | [diff] [blame] | 74 | # Generate linker config based on apex mounted in bootstrap namespace |
| 75 | update_linker_config |
| 76 | |
Tobias Thierer | bda0554 | 2019-09-11 18:22:10 +0100 | [diff] [blame] | 77 | # These must already exist by the time boringssl_self_test32 / boringssl_self_test64 run. |
| 78 | mkdir /dev/boringssl 0755 root root |
| 79 | mkdir /dev/boringssl/selftest 0755 root root |
| 80 | |
Kyle Lin | 9d19a05 | 2020-04-23 23:19:25 +0800 | [diff] [blame] | 81 | # Mount tracefs |
| 82 | mount tracefs tracefs /sys/kernel/tracing |
| 83 | |
Jaegeuk Kim | 43dca3c | 2020-07-20 17:34:47 -0700 | [diff] [blame] | 84 | # create sys dirctory |
| 85 | mkdir /dev/sys 0755 system system |
| 86 | mkdir /dev/sys/fs 0755 system system |
| 87 | mkdir /dev/sys/block 0755 system system |
| 88 | |
Tobias Thierer | bda0554 | 2019-09-11 18:22:10 +0100 | [diff] [blame] | 89 | # Run boringssl self test for each ABI so that later processes can skip it. http://b/139348610 |
| 90 | on early-init && property:ro.product.cpu.abilist32=* |
Tom Cherry | 60971e6 | 2019-09-10 10:40:47 -0700 | [diff] [blame] | 91 | exec_start boringssl_self_test32 |
Tobias Thierer | bda0554 | 2019-09-11 18:22:10 +0100 | [diff] [blame] | 92 | on early-init && property:ro.product.cpu.abilist64=* |
Tom Cherry | 60971e6 | 2019-09-10 10:40:47 -0700 | [diff] [blame] | 93 | exec_start boringssl_self_test64 |
Tobias Thierer | bda0554 | 2019-09-11 18:22:10 +0100 | [diff] [blame] | 94 | on property:apexd.status=ready && property:ro.product.cpu.abilist32=* |
Tom Cherry | 60971e6 | 2019-09-10 10:40:47 -0700 | [diff] [blame] | 95 | exec_start boringssl_self_test_apex32 |
| 96 | on property:apexd.status=ready && property:ro.product.cpu.abilist64=* |
| 97 | exec_start boringssl_self_test_apex64 |
| 98 | |
| 99 | service boringssl_self_test32 /system/bin/boringssl_self_test32 |
Tobias Thierer | f0f9438 | 2019-09-13 16:51:56 +0100 | [diff] [blame] | 100 | setenv BORINGSSL_SELF_TEST_CREATE_FLAG true # Any nonempty value counts as true |
Tom Cherry | a76bfb2 | 2019-09-18 09:41:36 -0700 | [diff] [blame] | 101 | reboot_on_failure reboot,boringssl-self-check-failed |
Tom Cherry | f5e872e | 2019-09-23 16:21:31 -0700 | [diff] [blame] | 102 | stdio_to_kmsg |
Tom Cherry | 60971e6 | 2019-09-10 10:40:47 -0700 | [diff] [blame] | 103 | |
| 104 | service boringssl_self_test64 /system/bin/boringssl_self_test64 |
Tobias Thierer | f0f9438 | 2019-09-13 16:51:56 +0100 | [diff] [blame] | 105 | setenv BORINGSSL_SELF_TEST_CREATE_FLAG true # Any nonempty value counts as true |
Tom Cherry | a76bfb2 | 2019-09-18 09:41:36 -0700 | [diff] [blame] | 106 | reboot_on_failure reboot,boringssl-self-check-failed |
Tom Cherry | f5e872e | 2019-09-23 16:21:31 -0700 | [diff] [blame] | 107 | stdio_to_kmsg |
Tom Cherry | 60971e6 | 2019-09-10 10:40:47 -0700 | [diff] [blame] | 108 | |
| 109 | service boringssl_self_test_apex32 /apex/com.android.conscrypt/bin/boringssl_self_test32 |
Tobias Thierer | f0f9438 | 2019-09-13 16:51:56 +0100 | [diff] [blame] | 110 | setenv BORINGSSL_SELF_TEST_CREATE_FLAG true # Any nonempty value counts as true |
Tom Cherry | a76bfb2 | 2019-09-18 09:41:36 -0700 | [diff] [blame] | 111 | reboot_on_failure reboot,boringssl-self-check-failed |
Tom Cherry | f5e872e | 2019-09-23 16:21:31 -0700 | [diff] [blame] | 112 | stdio_to_kmsg |
Tom Cherry | 60971e6 | 2019-09-10 10:40:47 -0700 | [diff] [blame] | 113 | |
| 114 | service boringssl_self_test_apex64 /apex/com.android.conscrypt/bin/boringssl_self_test64 |
Tobias Thierer | f0f9438 | 2019-09-13 16:51:56 +0100 | [diff] [blame] | 115 | setenv BORINGSSL_SELF_TEST_CREATE_FLAG true # Any nonempty value counts as true |
Tom Cherry | a76bfb2 | 2019-09-18 09:41:36 -0700 | [diff] [blame] | 116 | reboot_on_failure reboot,boringssl-self-check-failed |
Tom Cherry | f5e872e | 2019-09-23 16:21:31 -0700 | [diff] [blame] | 117 | stdio_to_kmsg |
Tobias Thierer | bda0554 | 2019-09-11 18:22:10 +0100 | [diff] [blame] | 118 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 119 | on init |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 120 | sysclktz 0 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 121 | |
Nick Kralevich | 27cb410 | 2016-01-22 18:02:29 -0800 | [diff] [blame] | 122 | # Mix device-specific information into the entropy pool |
| 123 | copy /proc/cmdline /dev/urandom |
Wei Wang | 0d78bfb | 2019-01-25 09:31:28 -0800 | [diff] [blame] | 124 | copy /system/etc/prop.default /dev/urandom |
Nick Kralevich | 27cb410 | 2016-01-22 18:02:29 -0800 | [diff] [blame] | 125 | |
Elliott Hughes | 5a0a51b | 2018-08-22 13:21:21 -0700 | [diff] [blame] | 126 | symlink /proc/self/fd/0 /dev/stdin |
| 127 | symlink /proc/self/fd/1 /dev/stdout |
| 128 | symlink /proc/self/fd/2 /dev/stderr |
| 129 | |
Todd Kjos | ba8a475 | 2015-10-26 16:22:11 -0700 | [diff] [blame] | 130 | # Create energy-aware scheduler tuning nodes |
Todd Kjos | 11cde56 | 2016-02-23 09:00:36 -0800 | [diff] [blame] | 131 | mkdir /dev/stune/foreground |
Tim Murray | 5dcff8f | 2016-07-11 13:57:31 -0700 | [diff] [blame] | 132 | mkdir /dev/stune/background |
Tim Murray | 955694b | 2016-07-11 11:40:15 -0700 | [diff] [blame] | 133 | mkdir /dev/stune/top-app |
Joel Fernandes | f50d109 | 2016-12-19 11:01:55 -0800 | [diff] [blame] | 134 | mkdir /dev/stune/rt |
Todd Kjos | 11cde56 | 2016-02-23 09:00:36 -0800 | [diff] [blame] | 135 | chown system system /dev/stune |
| 136 | chown system system /dev/stune/foreground |
Tim Murray | 5dcff8f | 2016-07-11 13:57:31 -0700 | [diff] [blame] | 137 | chown system system /dev/stune/background |
Tim Murray | 955694b | 2016-07-11 11:40:15 -0700 | [diff] [blame] | 138 | chown system system /dev/stune/top-app |
Joel Fernandes | f50d109 | 2016-12-19 11:01:55 -0800 | [diff] [blame] | 139 | chown system system /dev/stune/rt |
Todd Kjos | 11cde56 | 2016-02-23 09:00:36 -0800 | [diff] [blame] | 140 | chown system system /dev/stune/tasks |
| 141 | chown system system /dev/stune/foreground/tasks |
Tim Murray | 5dcff8f | 2016-07-11 13:57:31 -0700 | [diff] [blame] | 142 | chown system system /dev/stune/background/tasks |
Tim Murray | 955694b | 2016-07-11 11:40:15 -0700 | [diff] [blame] | 143 | chown system system /dev/stune/top-app/tasks |
Joel Fernandes | f50d109 | 2016-12-19 11:01:55 -0800 | [diff] [blame] | 144 | chown system system /dev/stune/rt/tasks |
Todd Kjos | 11cde56 | 2016-02-23 09:00:36 -0800 | [diff] [blame] | 145 | chmod 0664 /dev/stune/tasks |
| 146 | chmod 0664 /dev/stune/foreground/tasks |
Tim Murray | 5dcff8f | 2016-07-11 13:57:31 -0700 | [diff] [blame] | 147 | chmod 0664 /dev/stune/background/tasks |
Tim Murray | 955694b | 2016-07-11 11:40:15 -0700 | [diff] [blame] | 148 | chmod 0664 /dev/stune/top-app/tasks |
Joel Fernandes | f50d109 | 2016-12-19 11:01:55 -0800 | [diff] [blame] | 149 | chmod 0664 /dev/stune/rt/tasks |
Todd Kjos | ba8a475 | 2015-10-26 16:22:11 -0700 | [diff] [blame] | 150 | |
Suren Baghdasaryan | c6baa19 | 2020-10-13 10:41:00 -0700 | [diff] [blame] | 151 | # cpuctl hierarchy for devices using utilclamp |
| 152 | mkdir /dev/cpuctl/foreground |
| 153 | mkdir /dev/cpuctl/background |
| 154 | mkdir /dev/cpuctl/top-app |
| 155 | mkdir /dev/cpuctl/rt |
Wei Wang | 77cb6a0 | 2020-11-18 16:04:08 -0800 | [diff] [blame] | 156 | mkdir /dev/cpuctl/system |
Wei Wang | ab87979 | 2020-11-24 00:26:40 -0800 | [diff] [blame] | 157 | mkdir /dev/cpuctl/system-background |
Rick Yiu | 014446d | 2021-10-20 22:52:43 +0800 | [diff] [blame] | 158 | mkdir /dev/cpuctl/dex2oat |
Suren Baghdasaryan | c6baa19 | 2020-10-13 10:41:00 -0700 | [diff] [blame] | 159 | chown system system /dev/cpuctl |
| 160 | chown system system /dev/cpuctl/foreground |
| 161 | chown system system /dev/cpuctl/background |
| 162 | chown system system /dev/cpuctl/top-app |
| 163 | chown system system /dev/cpuctl/rt |
Wei Wang | 77cb6a0 | 2020-11-18 16:04:08 -0800 | [diff] [blame] | 164 | chown system system /dev/cpuctl/system |
Wei Wang | ab87979 | 2020-11-24 00:26:40 -0800 | [diff] [blame] | 165 | chown system system /dev/cpuctl/system-background |
Rick Yiu | 014446d | 2021-10-20 22:52:43 +0800 | [diff] [blame] | 166 | chown system system /dev/cpuctl/dex2oat |
Suren Baghdasaryan | c6baa19 | 2020-10-13 10:41:00 -0700 | [diff] [blame] | 167 | chown system system /dev/cpuctl/tasks |
| 168 | chown system system /dev/cpuctl/foreground/tasks |
| 169 | chown system system /dev/cpuctl/background/tasks |
| 170 | chown system system /dev/cpuctl/top-app/tasks |
| 171 | chown system system /dev/cpuctl/rt/tasks |
Wei Wang | 77cb6a0 | 2020-11-18 16:04:08 -0800 | [diff] [blame] | 172 | chown system system /dev/cpuctl/system/tasks |
Wei Wang | ab87979 | 2020-11-24 00:26:40 -0800 | [diff] [blame] | 173 | chown system system /dev/cpuctl/system-background/tasks |
Rick Yiu | 014446d | 2021-10-20 22:52:43 +0800 | [diff] [blame] | 174 | chown system system /dev/cpuctl/dex2oat/tasks |
Suren Baghdasaryan | c6baa19 | 2020-10-13 10:41:00 -0700 | [diff] [blame] | 175 | chmod 0664 /dev/cpuctl/tasks |
| 176 | chmod 0664 /dev/cpuctl/foreground/tasks |
| 177 | chmod 0664 /dev/cpuctl/background/tasks |
| 178 | chmod 0664 /dev/cpuctl/top-app/tasks |
| 179 | chmod 0664 /dev/cpuctl/rt/tasks |
Wei Wang | 77cb6a0 | 2020-11-18 16:04:08 -0800 | [diff] [blame] | 180 | chmod 0664 /dev/cpuctl/system/tasks |
Wei Wang | ab87979 | 2020-11-24 00:26:40 -0800 | [diff] [blame] | 181 | chmod 0664 /dev/cpuctl/system-background/tasks |
Rick Yiu | 014446d | 2021-10-20 22:52:43 +0800 | [diff] [blame] | 182 | chmod 0664 /dev/cpuctl/dex2oat/tasks |
Wei Wang | 77cb6a0 | 2020-11-18 16:04:08 -0800 | [diff] [blame] | 183 | |
| 184 | # Create a cpu group for NNAPI HAL processes |
| 185 | mkdir /dev/cpuctl/nnapi-hal |
| 186 | chown system system /dev/cpuctl/nnapi-hal |
| 187 | chown system system /dev/cpuctl/nnapi-hal/tasks |
| 188 | chmod 0664 /dev/cpuctl/nnapi-hal/tasks |
| 189 | write /dev/cpuctl/nnapi-hal/cpu.uclamp.min 1 |
| 190 | write /dev/cpuctl/nnapi-hal/cpu.uclamp.latency_sensitive 1 |
| 191 | |
Rick Yiu | a983f8a | 2020-12-01 15:45:01 +0800 | [diff] [blame] | 192 | # Create a cpu group for camera daemon processes |
| 193 | mkdir /dev/cpuctl/camera-daemon |
| 194 | chown system system /dev/cpuctl/camera-daemon |
| 195 | chown system system /dev/cpuctl/camera-daemon/tasks |
| 196 | chmod 0664 /dev/cpuctl/camera-daemon/tasks |
| 197 | |
Wei Wang | 6a28572 | 2020-11-30 10:56:29 -0800 | [diff] [blame] | 198 | # Create an stune group for camera-specific processes |
| 199 | mkdir /dev/stune/camera-daemon |
| 200 | chown system system /dev/stune/camera-daemon |
| 201 | chown system system /dev/stune/camera-daemon/tasks |
| 202 | chmod 0664 /dev/stune/camera-daemon/tasks |
| 203 | |
Miao Wang | c3991a7 | 2020-02-07 15:01:24 -0800 | [diff] [blame] | 204 | # Create an stune group for NNAPI HAL processes |
| 205 | mkdir /dev/stune/nnapi-hal |
| 206 | chown system system /dev/stune/nnapi-hal |
| 207 | chown system system /dev/stune/nnapi-hal/tasks |
| 208 | chmod 0664 /dev/stune/nnapi-hal/tasks |
| 209 | write /dev/stune/nnapi-hal/schedtune.boost 1 |
| 210 | write /dev/stune/nnapi-hal/schedtune.prefer_idle 1 |
| 211 | |
Rick Yiu | c7bf1a0 | 2019-04-23 21:33:56 +0800 | [diff] [blame] | 212 | # Create blkio group and apply initial settings. |
| 213 | # This feature needs kernel to support it, and the |
| 214 | # device's init.rc must actually set the correct values. |
Rick Yiu | 2b3bf84 | 2019-02-21 14:37:36 +0800 | [diff] [blame] | 215 | mkdir /dev/blkio/background |
| 216 | chown system system /dev/blkio |
| 217 | chown system system /dev/blkio/background |
| 218 | chown system system /dev/blkio/tasks |
| 219 | chown system system /dev/blkio/background/tasks |
| 220 | chmod 0664 /dev/blkio/tasks |
| 221 | chmod 0664 /dev/blkio/background/tasks |
Rick Yiu | c7bf1a0 | 2019-04-23 21:33:56 +0800 | [diff] [blame] | 222 | write /dev/blkio/blkio.weight 1000 |
Rick Yiu | ad74d8d | 2020-06-04 14:28:19 +0800 | [diff] [blame] | 223 | write /dev/blkio/background/blkio.weight 200 |
Daeho Jeong | 272e7a6 | 2021-02-15 14:37:01 +0900 | [diff] [blame] | 224 | write /dev/blkio/background/blkio.bfq.weight 10 |
Rick Yiu | c7bf1a0 | 2019-04-23 21:33:56 +0800 | [diff] [blame] | 225 | write /dev/blkio/blkio.group_idle 0 |
| 226 | write /dev/blkio/background/blkio.group_idle 0 |
Rick Yiu | 2b3bf84 | 2019-02-21 14:37:36 +0800 | [diff] [blame] | 227 | |
Jeff Sharkey | fc00048 | 2015-03-16 10:17:47 -0700 | [diff] [blame] | 228 | restorecon_recursive /mnt |
Jeff Sharkey | 5dd0f86 | 2012-08-17 16:01:16 -0700 | [diff] [blame] | 229 | |
Luis Hector Chavez | 8774945 | 2018-02-14 08:35:01 -0800 | [diff] [blame] | 230 | mount configfs none /config nodev noexec nosuid |
Daniel Rosenberg | 7903523 | 2017-11-29 14:49:08 -0800 | [diff] [blame] | 231 | chmod 0770 /config/sdcardfs |
Daniel Rosenberg | 4edec25 | 2016-02-18 19:48:31 -0800 | [diff] [blame] | 232 | chown system package_info /config/sdcardfs |
| 233 | |
Hridya Valsaraju | b237d76 | 2020-02-03 12:33:57 -0800 | [diff] [blame] | 234 | # Mount binderfs |
| 235 | mkdir /dev/binderfs |
| 236 | mount binder binder /dev/binderfs stats=global |
| 237 | chmod 0755 /dev/binderfs |
| 238 | |
Martijn Coenen | 959dcf1 | 2020-04-28 22:27:10 +0200 | [diff] [blame] | 239 | # Mount fusectl |
| 240 | mount fusectl none /sys/fs/fuse/connections |
| 241 | |
Hridya Valsaraju | b237d76 | 2020-02-03 12:33:57 -0800 | [diff] [blame] | 242 | symlink /dev/binderfs/binder /dev/binder |
| 243 | symlink /dev/binderfs/hwbinder /dev/hwbinder |
| 244 | symlink /dev/binderfs/vndbinder /dev/vndbinder |
| 245 | |
| 246 | chmod 0666 /dev/binderfs/hwbinder |
| 247 | chmod 0666 /dev/binderfs/binder |
| 248 | chmod 0666 /dev/binderfs/vndbinder |
| 249 | |
San Mehat | 6ea3cc6 | 2010-02-19 18:25:22 -0800 | [diff] [blame] | 250 | mkdir /mnt/secure 0700 root root |
Jeff Sharkey | fc00048 | 2015-03-16 10:17:47 -0700 | [diff] [blame] | 251 | mkdir /mnt/secure/asec 0700 root root |
| 252 | mkdir /mnt/asec 0755 root system |
| 253 | mkdir /mnt/obb 0755 root system |
Zim | c1b53de | 2020-01-24 22:13:58 +0000 | [diff] [blame] | 254 | mkdir /mnt/media_rw 0750 root external_storage |
Jeff Sharkey | fc00048 | 2015-03-16 10:17:47 -0700 | [diff] [blame] | 255 | mkdir /mnt/user 0755 root root |
| 256 | mkdir /mnt/user/0 0755 root root |
Zim | c9f8e5d | 2019-08-09 20:02:49 +0100 | [diff] [blame] | 257 | mkdir /mnt/user/0/self 0755 root root |
| 258 | mkdir /mnt/user/0/emulated 0755 root root |
| 259 | mkdir /mnt/user/0/emulated/0 0755 root root |
Zim | fc64dad | 2019-09-23 14:21:27 +0100 | [diff] [blame] | 260 | |
| 261 | # Prepare directories for pass through processes |
Zim | 6ca090e | 2020-01-20 14:16:14 +0000 | [diff] [blame] | 262 | mkdir /mnt/pass_through 0700 root root |
Zim | a67b40b | 2020-01-31 16:26:13 +0000 | [diff] [blame] | 263 | mkdir /mnt/pass_through/0 0710 root media_rw |
| 264 | mkdir /mnt/pass_through/0/self 0710 root media_rw |
| 265 | mkdir /mnt/pass_through/0/emulated 0710 root media_rw |
| 266 | mkdir /mnt/pass_through/0/emulated/0 0710 root media_rw |
Zim | fc64dad | 2019-09-23 14:21:27 +0100 | [diff] [blame] | 267 | |
Jeff Sharkey | ae0a5ac | 2015-04-06 14:08:54 -0700 | [diff] [blame] | 268 | mkdir /mnt/expand 0771 system system |
Daichi Hirono | 7abc71e | 2015-12-11 13:29:04 +0900 | [diff] [blame] | 269 | mkdir /mnt/appfuse 0711 root root |
San Mehat | 6ea3cc6 | 2010-02-19 18:25:22 -0800 | [diff] [blame] | 270 | |
Jeff Sharkey | f38f29c | 2015-06-23 14:30:37 -0700 | [diff] [blame] | 271 | # Storage views to support runtime permissions |
Jeff Sharkey | b9f438f | 2015-08-06 11:39:44 -0700 | [diff] [blame] | 272 | mkdir /mnt/runtime 0700 root root |
| 273 | mkdir /mnt/runtime/default 0755 root root |
| 274 | mkdir /mnt/runtime/default/self 0755 root root |
| 275 | mkdir /mnt/runtime/read 0755 root root |
| 276 | mkdir /mnt/runtime/read/self 0755 root root |
| 277 | mkdir /mnt/runtime/write 0755 root root |
| 278 | mkdir /mnt/runtime/write/self 0755 root root |
Sudheer Shanka | 81c687d | 2019-01-16 23:25:28 -0800 | [diff] [blame] | 279 | mkdir /mnt/runtime/full 0755 root root |
| 280 | mkdir /mnt/runtime/full/self 0755 root root |
San Mehat | 6ea3cc6 | 2010-02-19 18:25:22 -0800 | [diff] [blame] | 281 | |
Jeff Sharkey | fc00048 | 2015-03-16 10:17:47 -0700 | [diff] [blame] | 282 | # Symlink to keep legacy apps working in multi-user world |
Nick Kralevich | d2f0a2c | 2016-04-12 20:36:01 -0700 | [diff] [blame] | 283 | symlink /storage/self/primary /mnt/sdcard |
Jeff Sharkey | b9f438f | 2015-08-06 11:39:44 -0700 | [diff] [blame] | 284 | symlink /mnt/user/0/primary /mnt/runtime/default/self/primary |
Kenny Root | c7858a3 | 2010-07-15 12:14:44 -0700 | [diff] [blame] | 285 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 286 | write /proc/sys/kernel/panic_on_oops 1 |
| 287 | write /proc/sys/kernel/hung_task_timeout_secs 0 |
| 288 | write /proc/cpu/alignment 4 |
Riley Andrews | e850f57 | 2015-07-20 16:01:48 -0700 | [diff] [blame] | 289 | |
| 290 | # scheduler tunables |
| 291 | # Disable auto-scaling of scheduler tunables with hotplug. The tunables |
| 292 | # will vary across devices in unpredictable ways if allowed to scale with |
| 293 | # cpu cores. |
| 294 | write /proc/sys/kernel/sched_tunable_scaling 0 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 295 | write /proc/sys/kernel/sched_latency_ns 10000000 |
| 296 | write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000 |
San Mehat | 7baff71 | 2009-09-16 13:32:23 -0700 | [diff] [blame] | 297 | write /proc/sys/kernel/sched_child_runs_first 0 |
Riley Andrews | e850f57 | 2015-07-20 16:01:48 -0700 | [diff] [blame] | 298 | |
Nick Kralevich | d707fb3 | 2011-10-06 11:47:11 -0700 | [diff] [blame] | 299 | write /proc/sys/kernel/randomize_va_space 2 |
Nick Kralevich | 27cca21 | 2011-12-05 14:48:08 -0800 | [diff] [blame] | 300 | write /proc/sys/vm/mmap_min_addr 32768 |
Nick Kralevich | be341cc | 2013-02-21 18:36:43 -0800 | [diff] [blame] | 301 | write /proc/sys/net/ipv4/ping_group_range "0 2147483647" |
Mark Salyzyn | 39944c8 | 2015-09-08 11:24:07 -0700 | [diff] [blame] | 302 | write /proc/sys/net/unix/max_dgram_qlen 600 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 303 | |
Sandeep Patil | 5fee496 | 2016-12-07 10:55:45 -0800 | [diff] [blame] | 304 | # Assign reasonable ceiling values for socket rcv/snd buffers. |
| 305 | # These should almost always be overridden by the target per the |
| 306 | # the corresponding technology maximums. |
| 307 | write /proc/sys/net/core/rmem_max 262144 |
| 308 | write /proc/sys/net/core/wmem_max 262144 |
| 309 | |
Sreeram Ramachandran | fd94922 | 2014-04-09 17:44:56 -0700 | [diff] [blame] | 310 | # reflect fwmark from incoming packets onto generated replies |
| 311 | write /proc/sys/net/ipv4/fwmark_reflect 1 |
| 312 | write /proc/sys/net/ipv6/fwmark_reflect 1 |
| 313 | |
| 314 | # set fwmark on accepted sockets |
| 315 | write /proc/sys/net/ipv4/tcp_fwmark_accept 1 |
| 316 | |
Greg Hackmann | f3fd122 | 2014-12-03 09:57:00 -0800 | [diff] [blame] | 317 | # disable icmp redirects |
| 318 | write /proc/sys/net/ipv4/conf/all/accept_redirects 0 |
| 319 | write /proc/sys/net/ipv6/conf/all/accept_redirects 0 |
| 320 | |
Nick Kralevich | 15ffc53 | 2017-08-25 12:55:52 -0700 | [diff] [blame] | 321 | # /proc/net/fib_trie leaks interface IP addresses |
| 322 | chmod 0400 /proc/net/fib_trie |
| 323 | |
Tim Murray | b769c8d | 2015-06-08 14:56:29 -0700 | [diff] [blame] | 324 | # sets up initial cpusets for ActivityManager |
Tim Murray | b769c8d | 2015-06-08 14:56:29 -0700 | [diff] [blame] | 325 | # this ensures that the cpusets are present and usable, but the device's |
| 326 | # init.rc must actually set the correct cpus |
Tim Murray | f429d37 | 2015-10-15 12:38:15 -0700 | [diff] [blame] | 327 | mkdir /dev/cpuset/foreground |
Wei Wang | 8dbd12b | 2017-04-13 18:27:35 -0700 | [diff] [blame] | 328 | copy /dev/cpuset/cpus /dev/cpuset/foreground/cpus |
| 329 | copy /dev/cpuset/mems /dev/cpuset/foreground/mems |
Tim Murray | f429d37 | 2015-10-15 12:38:15 -0700 | [diff] [blame] | 330 | mkdir /dev/cpuset/background |
Wei Wang | 8dbd12b | 2017-04-13 18:27:35 -0700 | [diff] [blame] | 331 | copy /dev/cpuset/cpus /dev/cpuset/background/cpus |
| 332 | copy /dev/cpuset/mems /dev/cpuset/background/mems |
Tim Murray | f429d37 | 2015-10-15 12:38:15 -0700 | [diff] [blame] | 333 | |
| 334 | # system-background is for system tasks that should only run on |
| 335 | # little cores, not on bigs |
Tim Murray | f429d37 | 2015-10-15 12:38:15 -0700 | [diff] [blame] | 336 | mkdir /dev/cpuset/system-background |
Wei Wang | 8dbd12b | 2017-04-13 18:27:35 -0700 | [diff] [blame] | 337 | copy /dev/cpuset/cpus /dev/cpuset/system-background/cpus |
| 338 | copy /dev/cpuset/mems /dev/cpuset/system-background/mems |
Tim Murray | f429d37 | 2015-10-15 12:38:15 -0700 | [diff] [blame] | 339 | |
Tim Murray | 658ae90 | 2018-04-13 10:15:49 -0700 | [diff] [blame] | 340 | # restricted is for system tasks that are being throttled |
| 341 | # due to screen off. |
| 342 | mkdir /dev/cpuset/restricted |
| 343 | copy /dev/cpuset/cpus /dev/cpuset/restricted/cpus |
| 344 | copy /dev/cpuset/mems /dev/cpuset/restricted/mems |
| 345 | |
Tim Murray | 6647bb5 | 2016-01-11 16:16:35 -0800 | [diff] [blame] | 346 | mkdir /dev/cpuset/top-app |
Wei Wang | 8dbd12b | 2017-04-13 18:27:35 -0700 | [diff] [blame] | 347 | copy /dev/cpuset/cpus /dev/cpuset/top-app/cpus |
| 348 | copy /dev/cpuset/mems /dev/cpuset/top-app/mems |
Tim Murray | 6647bb5 | 2016-01-11 16:16:35 -0800 | [diff] [blame] | 349 | |
Rick Yiu | a983f8a | 2020-12-01 15:45:01 +0800 | [diff] [blame] | 350 | # create a cpuset for camera daemon processes |
| 351 | mkdir /dev/cpuset/camera-daemon |
| 352 | copy /dev/cpuset/cpus /dev/cpuset/camera-daemon/cpus |
| 353 | copy /dev/cpuset/mems /dev/cpuset/camera-daemon/mems |
| 354 | |
Tim Murray | f429d37 | 2015-10-15 12:38:15 -0700 | [diff] [blame] | 355 | # change permissions for all cpusets we'll touch at runtime |
Tim Murray | b769c8d | 2015-06-08 14:56:29 -0700 | [diff] [blame] | 356 | chown system system /dev/cpuset |
| 357 | chown system system /dev/cpuset/foreground |
| 358 | chown system system /dev/cpuset/background |
Todd Kjos | ba8a475 | 2015-10-26 16:22:11 -0700 | [diff] [blame] | 359 | chown system system /dev/cpuset/system-background |
Tim Murray | 6647bb5 | 2016-01-11 16:16:35 -0800 | [diff] [blame] | 360 | chown system system /dev/cpuset/top-app |
Tim Murray | 658ae90 | 2018-04-13 10:15:49 -0700 | [diff] [blame] | 361 | chown system system /dev/cpuset/restricted |
Rick Yiu | a983f8a | 2020-12-01 15:45:01 +0800 | [diff] [blame] | 362 | chown system system /dev/cpuset/camera-daemon |
Tim Murray | b769c8d | 2015-06-08 14:56:29 -0700 | [diff] [blame] | 363 | chown system system /dev/cpuset/tasks |
| 364 | chown system system /dev/cpuset/foreground/tasks |
| 365 | chown system system /dev/cpuset/background/tasks |
Todd Kjos | ba8a475 | 2015-10-26 16:22:11 -0700 | [diff] [blame] | 366 | chown system system /dev/cpuset/system-background/tasks |
Tim Murray | 6647bb5 | 2016-01-11 16:16:35 -0800 | [diff] [blame] | 367 | chown system system /dev/cpuset/top-app/tasks |
Tim Murray | 658ae90 | 2018-04-13 10:15:49 -0700 | [diff] [blame] | 368 | chown system system /dev/cpuset/restricted/tasks |
Rick Yiu | a983f8a | 2020-12-01 15:45:01 +0800 | [diff] [blame] | 369 | chown system system /dev/cpuset/camera-daemon/tasks |
Tim Murray | 4284f9f | 2015-11-10 14:31:09 -0800 | [diff] [blame] | 370 | |
| 371 | # set system-background to 0775 so SurfaceFlinger can touch it |
| 372 | chmod 0775 /dev/cpuset/system-background |
| 373 | |
Jeff Vander Stoep | 3f62a02 | 2015-07-23 15:18:36 -0700 | [diff] [blame] | 374 | chmod 0664 /dev/cpuset/foreground/tasks |
| 375 | chmod 0664 /dev/cpuset/background/tasks |
Todd Kjos | ba8a475 | 2015-10-26 16:22:11 -0700 | [diff] [blame] | 376 | chmod 0664 /dev/cpuset/system-background/tasks |
Tim Murray | 6647bb5 | 2016-01-11 16:16:35 -0800 | [diff] [blame] | 377 | chmod 0664 /dev/cpuset/top-app/tasks |
Tim Murray | 658ae90 | 2018-04-13 10:15:49 -0700 | [diff] [blame] | 378 | chmod 0664 /dev/cpuset/restricted/tasks |
Jeff Vander Stoep | 3f62a02 | 2015-07-23 15:18:36 -0700 | [diff] [blame] | 379 | chmod 0664 /dev/cpuset/tasks |
Rick Yiu | a983f8a | 2020-12-01 15:45:01 +0800 | [diff] [blame] | 380 | chmod 0664 /dev/cpuset/camera-daemon/tasks |
Tim Murray | b769c8d | 2015-06-08 14:56:29 -0700 | [diff] [blame] | 381 | |
Tim Murray | 1504cb5 | 2019-02-15 11:51:09 -0800 | [diff] [blame] | 382 | # make the PSI monitor accessible to others |
| 383 | chown system system /proc/pressure/memory |
| 384 | chmod 0664 /proc/pressure/memory |
Tim Murray | b769c8d | 2015-06-08 14:56:29 -0700 | [diff] [blame] | 385 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 386 | # qtaguid will limit access to specific data based on group memberships. |
| 387 | # net_bw_acct grants impersonation of socket owners. |
| 388 | # net_bw_stats grants access to other apps' detailed tagged-socket stats. |
JP Abgrall | 3e54aab | 2013-01-04 14:34:58 -0800 | [diff] [blame] | 389 | chown root net_bw_acct /proc/net/xt_qtaguid/ctrl |
| 390 | chown root net_bw_stats /proc/net/xt_qtaguid/stats |
| 391 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 392 | # Allow everybody to read the xt_qtaguid resource tracking misc dev. |
| 393 | # This is needed by any process that uses socket tagging. |
JP Abgrall | 8e3ff70 | 2011-09-11 16:12:27 -0700 | [diff] [blame] | 394 | chmod 0644 /dev/xt_qtaguid |
| 395 | |
Luis Hector Chavez | f8a7e37 | 2018-02-12 11:30:46 -0800 | [diff] [blame] | 396 | mount bpf bpf /sys/fs/bpf nodev noexec nosuid |
Chenbo Feng | 2cba6f2 | 2017-10-23 11:57:59 -0700 | [diff] [blame] | 397 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 398 | # Create location for fs_mgr to store abbreviated output from filesystem |
| 399 | # checker programs. |
Ken Sumrall | 4eaf905 | 2013-09-18 17:49:21 -0700 | [diff] [blame] | 400 | mkdir /dev/fscklogs 0770 root system |
| 401 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 402 | # pstore/ramoops previous console log |
Luis Hector Chavez | f8a7e37 | 2018-02-12 11:30:46 -0800 | [diff] [blame] | 403 | mount pstore pstore /sys/fs/pstore nodev noexec nosuid |
Mark Salyzyn | 7ab805e | 2018-06-29 10:32:11 -0700 | [diff] [blame] | 404 | chown system log /sys/fs/pstore |
| 405 | chmod 0550 /sys/fs/pstore |
Todd Poynor | 479efb5 | 2013-11-21 20:23:54 -0800 | [diff] [blame] | 406 | chown system log /sys/fs/pstore/console-ramoops |
| 407 | chmod 0440 /sys/fs/pstore/console-ramoops |
Mark Salyzyn | 4eb0ba0 | 2017-06-27 09:32:32 -0700 | [diff] [blame] | 408 | chown system log /sys/fs/pstore/console-ramoops-0 |
| 409 | chmod 0440 /sys/fs/pstore/console-ramoops-0 |
Mark Salyzyn | 4b0313e | 2014-12-15 07:52:19 -0800 | [diff] [blame] | 410 | chown system log /sys/fs/pstore/pmsg-ramoops-0 |
| 411 | chmod 0440 /sys/fs/pstore/pmsg-ramoops-0 |
Todd Poynor | 479efb5 | 2013-11-21 20:23:54 -0800 | [diff] [blame] | 412 | |
Greg Hackmann | cee8757 | 2015-01-26 10:40:29 -0800 | [diff] [blame] | 413 | # enable armv8_deprecated instruction hooks |
| 414 | write /proc/sys/abi/swp 1 |
| 415 | |
Greg Hackmann | 40a96e4 | 2016-02-01 09:59:44 -0800 | [diff] [blame] | 416 | # Linux's execveat() syscall may construct paths containing /dev/fd |
| 417 | # expecting it to point to /proc/self/fd |
| 418 | symlink /proc/self/fd /dev/fd |
| 419 | |
Yueyao (Nathan) Zhu | 60c6dac | 2016-06-21 12:04:54 -0700 | [diff] [blame] | 420 | export DOWNLOAD_CACHE /data/cache |
| 421 | |
David Lin | 27b2c1e | 2017-03-08 17:36:18 -0800 | [diff] [blame] | 422 | # This allows the ledtrig-transient properties to be created here so |
| 423 | # that they can be chown'd to system:system later on boot |
| 424 | write /sys/class/leds/vibrator/trigger "transient" |
| 425 | |
Haibo Huang | d60a19b | 2018-11-04 09:50:05 -0800 | [diff] [blame] | 426 | # This is used by Bionic to select optimized routines. |
| 427 | write /dev/cpu_variant:${ro.bionic.arch} ${ro.bionic.cpu_variant} |
| 428 | chmod 0444 /dev/cpu_variant:${ro.bionic.arch} |
| 429 | write /dev/cpu_variant:${ro.bionic.2nd_arch} ${ro.bionic.2nd_cpu_variant} |
| 430 | chmod 0444 /dev/cpu_variant:${ro.bionic.2nd_arch} |
| 431 | |
Yifan Hong | c9a9d27 | 2019-04-08 13:29:07 -0700 | [diff] [blame] | 432 | # Allow system processes to read / write power state. |
| 433 | chown system system /sys/power/state |
| 434 | chown system system /sys/power/wakeup_count |
| 435 | chmod 0660 /sys/power/state |
| 436 | |
Tri Vo | c6a84e8 | 2019-07-16 14:31:55 -0700 | [diff] [blame] | 437 | chown radio wakelock /sys/power/wake_lock |
| 438 | chown radio wakelock /sys/power/wake_unlock |
| 439 | chmod 0660 /sys/power/wake_lock |
| 440 | chmod 0660 /sys/power/wake_unlock |
| 441 | |
Tom Cherry | f18b748 | 2018-10-17 13:14:55 -0700 | [diff] [blame] | 442 | # Start logd before any other services run to ensure we capture all of their logs. |
| 443 | start logd |
Suren Baghdasaryan | c29c2ba | 2019-10-22 17:18:42 -0700 | [diff] [blame] | 444 | # Start lmkd before any other services run so that it can register them |
Martin Liu | 9f8b024 | 2021-07-01 11:55:02 +0800 | [diff] [blame] | 445 | write /proc/sys/vm/watermark_boost_factor 0 |
Suren Baghdasaryan | 6898682 | 2020-02-13 16:17:10 -0800 | [diff] [blame] | 446 | chown root system /sys/module/lowmemorykiller/parameters/adj |
| 447 | chmod 0664 /sys/module/lowmemorykiller/parameters/adj |
| 448 | chown root system /sys/module/lowmemorykiller/parameters/minfree |
| 449 | chmod 0664 /sys/module/lowmemorykiller/parameters/minfree |
Suren Baghdasaryan | c29c2ba | 2019-10-22 17:18:42 -0700 | [diff] [blame] | 450 | start lmkd |
Jiyong Park | 407b000 | 2019-02-02 19:45:23 +0900 | [diff] [blame] | 451 | |
Tom Cherry | f18b748 | 2018-10-17 13:14:55 -0700 | [diff] [blame] | 452 | # Start essential services. |
| 453 | start servicemanager |
| 454 | start hwservicemanager |
| 455 | start vndservicemanager |
| 456 | |
Riley Andrews | e4b7b29 | 2014-06-16 15:06:21 -0700 | [diff] [blame] | 457 | # Healthd can trigger a full boot from charger mode by signaling this |
| 458 | # property when the power button is held. |
| 459 | on property:sys.boot_from_charger_mode=1 |
| 460 | class_stop charger |
| 461 | trigger late-init |
| 462 | |
Riley Andrews | 80c7a5e | 2014-07-11 15:05:23 -0700 | [diff] [blame] | 463 | # Indicate to fw loaders that the relevant mounts are up. |
| 464 | on firmware_mounts_complete |
| 465 | rm /dev/.booting |
| 466 | |
Riley Andrews | e4b7b29 | 2014-06-16 15:06:21 -0700 | [diff] [blame] | 467 | # Mount filesystems and start core system services. |
| 468 | on late-init |
| 469 | trigger early-fs |
Wei Wang | abfbec3 | 2016-08-23 11:58:09 -0700 | [diff] [blame] | 470 | |
| 471 | # Mount fstab in init.{$device}.rc by mount_all command. Optional parameter |
| 472 | # '--early' can be specified to skip entries with 'latemount'. |
| 473 | # /system and /vendor must be mounted by the end of the fs stage, |
| 474 | # while /data is optional. |
Riley Andrews | e4b7b29 | 2014-06-16 15:06:21 -0700 | [diff] [blame] | 475 | trigger fs |
| 476 | trigger post-fs |
Riley Andrews | e4b7b29 | 2014-06-16 15:06:21 -0700 | [diff] [blame] | 477 | |
Wei Wang | abfbec3 | 2016-08-23 11:58:09 -0700 | [diff] [blame] | 478 | # Mount fstab in init.{$device}.rc by mount_all with '--late' parameter |
| 479 | # to only mount entries with 'latemount'. This is needed if '--early' is |
| 480 | # specified in the previous mount_all command on the fs stage. |
| 481 | # With /system mounted and properties form /system + /factory available, |
| 482 | # some services can be started. |
| 483 | trigger late-fs |
| 484 | |
Paul Lawrence | 948410a | 2015-07-01 14:40:56 -0700 | [diff] [blame] | 485 | # Now we can mount /data. File encryption requires keymaster to decrypt |
Wei Wang | abfbec3 | 2016-08-23 11:58:09 -0700 | [diff] [blame] | 486 | # /data, which in turn can only be loaded when system properties are present. |
Paul Lawrence | 948410a | 2015-07-01 14:40:56 -0700 | [diff] [blame] | 487 | trigger post-fs-data |
Wei Wang | abfbec3 | 2016-08-23 11:58:09 -0700 | [diff] [blame] | 488 | |
Maciej Żenczykowski | 6c72c16 | 2020-06-22 01:11:24 -0700 | [diff] [blame] | 489 | # Should be before netd, but after apex, properties and logging is available. |
| 490 | trigger load_bpf_programs |
| 491 | |
Wei Wang | fa14d21 | 2018-09-05 10:12:40 -0700 | [diff] [blame] | 492 | # Now we can start zygote for devices with file based encryption |
| 493 | trigger zygote-start |
| 494 | |
Riley Andrews | 67cb1ae | 2014-07-15 20:39:41 -0700 | [diff] [blame] | 495 | # Remove a file to wake up anything waiting for firmware. |
| 496 | trigger firmware_mounts_complete |
| 497 | |
Riley Andrews | e4b7b29 | 2014-06-16 15:06:21 -0700 | [diff] [blame] | 498 | trigger early-boot |
| 499 | trigger boot |
| 500 | |
Daniel Rosenberg | 1be83e3 | 2019-06-17 13:23:05 -0700 | [diff] [blame] | 501 | on early-fs |
| 502 | # Once metadata has been mounted, we'll need vold to deal with userdata checkpointing |
Daniel Rosenberg | 6156b9b | 2018-10-11 15:35:07 -0700 | [diff] [blame] | 503 | start vold |
Daniel Rosenberg | 1be83e3 | 2019-06-17 13:23:05 -0700 | [diff] [blame] | 504 | |
| 505 | on post-fs |
Daniel Rosenberg | 6156b9b | 2018-10-11 15:35:07 -0700 | [diff] [blame] | 506 | exec - system system -- /system/bin/vdc checkpoint markBootAttempt |
Steven Moreland | d627502 | 2017-03-24 16:23:07 +0000 | [diff] [blame] | 507 | |
Luis Hector Chavez | 30780a7 | 2018-02-14 08:36:16 -0800 | [diff] [blame] | 508 | # Once everything is setup, no need to modify /. |
Luis Hector Chavez | d07d094 | 2018-07-11 08:13:34 -0700 | [diff] [blame] | 509 | # The bind+remount combination allows this to work in containers. |
| 510 | mount rootfs rootfs / remount bind ro nodev |
Brian Swetland | 56de7a1 | 2010-09-08 15:06:45 -0700 | [diff] [blame] | 511 | |
Zim | c46c235 | 2020-09-11 11:06:29 +0100 | [diff] [blame] | 512 | # Mount default storage into root namespace |
| 513 | mount none /mnt/user/0 /storage bind rec |
| 514 | mount none none /storage slave rec |
| 515 | |
Nick Kralevich | 715c4dc | 2015-12-07 16:57:08 -0800 | [diff] [blame] | 516 | # Make sure /sys/kernel/debug (if present) is labeled properly |
Paul Lawrence | a8d8434 | 2016-11-14 15:40:18 -0800 | [diff] [blame] | 517 | # Note that tracefs may be mounted under debug, so we need to cross filesystems |
| 518 | restorecon --recursive --cross-filesystems /sys/kernel/debug |
Paul Lawrence | d2abcbd | 2016-11-02 14:23:31 -0700 | [diff] [blame] | 519 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 520 | # We chown/chmod /cache again so because mount is run as root + defaults |
| 521 | chown system cache /cache |
| 522 | chmod 0770 /cache |
Stephen Smalley | 1eee419 | 2012-01-13 08:54:34 -0500 | [diff] [blame] | 523 | # We restorecon /cache in case the cache partition has been reset. |
Nick Kralevich | e169591 | 2014-07-09 12:39:21 -0700 | [diff] [blame] | 524 | restorecon_recursive /cache |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 525 | |
Tao Bao | e48aed0 | 2015-05-11 14:08:18 -0700 | [diff] [blame] | 526 | # Create /cache/recovery in case it's not there. It'll also fix the odd |
| 527 | # permissions if created by the recovery system. |
| 528 | mkdir /cache/recovery 0770 system cache |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 529 | |
Christopher Tate | 63c463f | 2016-01-28 17:09:42 -0800 | [diff] [blame] | 530 | # Backup/restore mechanism uses the cache partition |
| 531 | mkdir /cache/backup_stage 0700 system system |
| 532 | mkdir /cache/backup 0700 system system |
| 533 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 534 | #change permissions on vmallocinfo so we can grab it from bugreports |
| 535 | chown root log /proc/vmallocinfo |
| 536 | chmod 0440 /proc/vmallocinfo |
| 537 | |
Dima Zavin | 9481266 | 2012-09-25 14:22:02 -0700 | [diff] [blame] | 538 | chown root log /proc/slabinfo |
| 539 | chmod 0440 /proc/slabinfo |
| 540 | |
Martin Liu | 0abd0d6 | 2020-06-14 17:21:13 +0800 | [diff] [blame] | 541 | chown root log /proc/pagetypeinfo |
| 542 | chmod 0440 /proc/pagetypeinfo |
| 543 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 544 | #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks |
| 545 | chown root system /proc/kmsg |
| 546 | chmod 0440 /proc/kmsg |
| 547 | chown root system /proc/sysrq-trigger |
| 548 | chmod 0220 /proc/sysrq-trigger |
Colin Cross | b35e36e | 2012-08-02 18:14:33 -0700 | [diff] [blame] | 549 | chown system log /proc/last_kmsg |
| 550 | chmod 0440 /proc/last_kmsg |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 551 | |
dcashman | 5822a4a | 2014-03-25 16:31:07 -0700 | [diff] [blame] | 552 | # make the selinux kernel policy world-readable |
| 553 | chmod 0444 /sys/fs/selinux/policy |
| 554 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 555 | # create the lost+found directories, so as to enforce our permissions |
Chia-chi Yeh | ea74414 | 2011-07-08 16:52:18 -0700 | [diff] [blame] | 556 | mkdir /cache/lost+found 0770 root root |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 557 | |
Paul Crowley | fe305ab | 2018-05-17 10:12:34 -0700 | [diff] [blame] | 558 | restorecon_recursive /metadata |
| 559 | mkdir /metadata/vold |
| 560 | chmod 0700 /metadata/vold |
David Anderson | 0664f31 | 2019-03-05 22:16:36 -0800 | [diff] [blame] | 561 | mkdir /metadata/password_slots 0771 root system |
Mark Salyzyn | ee016ce | 2019-05-23 10:00:34 -0700 | [diff] [blame] | 562 | mkdir /metadata/bootstat 0750 system log |
David Anderson | 001747e | 2019-07-03 15:10:53 -0700 | [diff] [blame] | 563 | mkdir /metadata/ota 0700 root system |
David Anderson | 456e501 | 2019-08-01 14:37:35 -0700 | [diff] [blame] | 564 | mkdir /metadata/ota/snapshots 0700 root system |
Gavin Corkery | 8c92256 | 2020-05-11 14:10:09 +0100 | [diff] [blame] | 565 | mkdir /metadata/userspacereboot 0770 root system |
Gavin Corkery | badf396 | 2020-12-05 17:25:09 +0000 | [diff] [blame] | 566 | mkdir /metadata/watchdog 0770 root system |
Paul Crowley | fe305ab | 2018-05-17 10:12:34 -0700 | [diff] [blame] | 567 | |
Martijn Coenen | 4517e57 | 2019-03-12 22:05:20 +0100 | [diff] [blame] | 568 | mkdir /metadata/apex 0700 root system |
| 569 | mkdir /metadata/apex/sessions 0700 root system |
Nikita Ioffe | a462044 | 2020-06-22 17:47:23 +0100 | [diff] [blame] | 570 | # On some devices we see a weird behaviour in which /metadata/apex doesn't |
| 571 | # have a correct label. To workaround this bug, explicitly call restorecon |
| 572 | # on /metadata/apex. For most of the boot sequences /metadata/apex will |
| 573 | # already have a correct selinux label, meaning that this call will be a |
| 574 | # no-op. |
| 575 | restorecon_recursive /metadata/apex |
| 576 | |
Mohammad Samiul Islam | d192d54 | 2020-05-07 15:52:48 +0100 | [diff] [blame] | 577 | mkdir /metadata/staged-install 0770 root system |
Janis Danisevskis | 1ad8d21 | 2017-04-06 12:44:59 -0700 | [diff] [blame] | 578 | on late-fs |
Joel Galenson | d48c4cf | 2017-06-13 10:15:05 -0700 | [diff] [blame] | 579 | # Ensure that tracefs has the correct permissions. |
| 580 | # This does not work correctly if it is called in post-fs. |
Alistair Delva | ebb5b3b | 2020-01-29 09:10:47 -0800 | [diff] [blame] | 581 | chmod 0755 /sys/kernel/tracing |
Joel Galenson | d48c4cf | 2017-06-13 10:15:05 -0700 | [diff] [blame] | 582 | chmod 0755 /sys/kernel/debug/tracing |
| 583 | |
Janis Danisevskis | 1ad8d21 | 2017-04-06 12:44:59 -0700 | [diff] [blame] | 584 | # HALs required before storage encryption can get unlocked (FBE/FDE) |
| 585 | class_start early_hal |
| 586 | |
Martijn Coenen | 3b68bf2 | 2020-11-30 10:05:40 +0100 | [diff] [blame] | 587 | # Load trusted keys from dm-verity protected partitions |
| 588 | exec -- /system/bin/fsverity_init --load-verified-keys |
| 589 | |
Alexander Potapenko | 53cd1e9 | 2021-09-29 13:30:02 +0000 | [diff] [blame] | 590 | # Only enable the bootreceiver tracing instance for kernels 5.10 and above. |
| 591 | on late-fs && property:ro.kernel.version=4.9 |
| 592 | setprop bootreceiver.enable 0 |
| 593 | on late-fs && property:ro.kernel.version=4.14 |
| 594 | setprop bootreceiver.enable 0 |
| 595 | on late-fs && property:ro.kernel.version=4.19 |
| 596 | setprop bootreceiver.enable 0 |
| 597 | on late-fs && property:ro.kernel.version=5.4 |
| 598 | setprop bootreceiver.enable 0 |
| 599 | on late-fs |
| 600 | # Bootreceiver tracing instance is enabled by default. |
| 601 | setprop bootreceiver.enable ${bootreceiver.enable:-1} |
| 602 | |
| 603 | on property:ro.product.cpu.abilist64=* && property:bootreceiver.enable=1 |
Alexander Potapenko | 439608b | 2021-03-02 16:50:16 +0100 | [diff] [blame] | 604 | # Set up a tracing instance for system_server to monitor error_report_end events. |
| 605 | # These are sent by kernel tools like KASAN and KFENCE when a memory corruption |
Alexander Potapenko | ec37ba8 | 2021-08-03 07:47:40 +0000 | [diff] [blame] | 606 | # is detected. This is only needed for 64-bit systems. |
Alexander Potapenko | 439608b | 2021-03-02 16:50:16 +0100 | [diff] [blame] | 607 | mkdir /sys/kernel/tracing/instances/bootreceiver 0700 system system |
| 608 | restorecon_recursive /sys/kernel/tracing/instances/bootreceiver |
| 609 | write /sys/kernel/tracing/instances/bootreceiver/buffer_size_kb 1 |
| 610 | write /sys/kernel/tracing/instances/bootreceiver/trace_options disable_on_free |
| 611 | write /sys/kernel/tracing/instances/bootreceiver/events/error_report/error_report_end/enable 1 |
| 612 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 613 | on post-fs-data |
Martijn Coenen | e94b366 | 2021-03-09 10:57:00 +0100 | [diff] [blame] | 614 | |
Martijn Coenen | f0bc58a | 2019-04-23 16:26:01 +0200 | [diff] [blame] | 615 | mark_post_data |
| 616 | |
Paul Lawrence | b920cb4 | 2018-10-04 08:37:17 -0700 | [diff] [blame] | 617 | # Start checkpoint before we touch data |
Paul Lawrence | b920cb4 | 2018-10-04 08:37:17 -0700 | [diff] [blame] | 618 | exec - system system -- /system/bin/vdc checkpoint prepareCheckpoint |
| 619 | |
Colin Cross | 31712be | 2010-04-09 12:26:06 -0700 | [diff] [blame] | 620 | # We chown/chmod /data again so because mount is run as root + defaults |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 621 | chown system system /data |
| 622 | chmod 0771 /data |
Stephen Smalley | 1eee419 | 2012-01-13 08:54:34 -0500 | [diff] [blame] | 623 | # We restorecon /data in case the userdata partition has been reset. |
| 624 | restorecon /data |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 625 | |
Elliott Hughes | 2f74a5d | 2016-02-02 09:15:59 -0800 | [diff] [blame] | 626 | # Make sure we have the device encryption key. |
Paul Lawrence | 806d10b | 2015-04-28 22:07:10 +0000 | [diff] [blame] | 627 | installkey /data |
| 628 | |
Yongqin Liu | a197ff1 | 2014-12-05 13:45:02 +0800 | [diff] [blame] | 629 | # Start bootcharting as soon as possible after the data partition is |
| 630 | # mounted to collect more data. |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 631 | mkdir /data/bootchart 0755 shell shell encryption=Require |
Elliott Hughes | a3641af | 2016-11-10 17:43:47 -0800 | [diff] [blame] | 632 | bootchart start |
Yongqin Liu | a197ff1 | 2014-12-05 13:45:02 +0800 | [diff] [blame] | 633 | |
Paul Crowley | 7583da1 | 2021-04-08 17:04:43 +0000 | [diff] [blame] | 634 | # Avoid predictable entropy pool. Carry over entropy from previous boot. |
| 635 | copy /data/system/entropy.dat /dev/urandom |
| 636 | |
Tom Cherry | 2c9c8eb | 2020-10-16 10:02:40 -0700 | [diff] [blame] | 637 | mkdir /data/vendor 0771 root root encryption=Require |
| 638 | mkdir /data/vendor_ce 0771 root root encryption=None |
| 639 | mkdir /data/vendor_de 0771 root root encryption=None |
| 640 | mkdir /data/vendor/hardware 0771 root root |
| 641 | |
Josh Gao | 81c94cd | 2020-10-01 13:01:15 -0700 | [diff] [blame] | 642 | # Start tombstoned early to be able to store tombstones. |
Kevin Brodsky | 13d86ad | 2020-12-17 15:32:50 +0000 | [diff] [blame] | 643 | mkdir /data/anr 0775 system system encryption=Require |
Josh Gao | 81c94cd | 2020-10-01 13:01:15 -0700 | [diff] [blame] | 644 | mkdir /data/tombstones 0771 system system encryption=Require |
| 645 | mkdir /data/vendor/tombstones 0771 root root |
| 646 | mkdir /data/vendor/tombstones/wifi 0771 wifi wifi |
| 647 | start tombstoned |
| 648 | |
Kevin Brodsky | 13d86ad | 2020-12-17 15:32:50 +0000 | [diff] [blame] | 649 | # Make sure that apexd is started in the default namespace |
| 650 | enter_default_mount_ns |
| 651 | |
Paul Crowley | 7583da1 | 2021-04-08 17:04:43 +0000 | [diff] [blame] | 652 | # set up keystore directory structure first so that we can end early boot |
| 653 | # and start apexd |
| 654 | mkdir /data/misc 01771 system misc encryption=Require |
| 655 | mkdir /data/misc/keystore 0700 keystore keystore |
| 656 | # work around b/183668221 |
| 657 | restorecon /data/misc /data/misc/keystore |
| 658 | |
| 659 | # Boot level 30 |
| 660 | # odsign signing keys have MAX_BOOT_LEVEL=30 |
| 661 | # This is currently the earliest boot level, but we start at 30 |
| 662 | # to leave room for earlier levels. |
| 663 | setprop keystore.boot_level 30 |
| 664 | |
| 665 | # Now that /data is mounted and we have created /data/misc/keystore, |
| 666 | # we can tell keystore to stop allowing use of early-boot keys, |
| 667 | # and access its database for the first time to support creation and |
| 668 | # use of MAX_BOOT_LEVEL keys. |
| 669 | exec - system system -- /system/bin/vdc keymaster earlyBootEnded |
| 670 | |
Daniel Norman | ebaa3e5 | 2021-11-16 20:28:29 +0000 | [diff] [blame^] | 671 | # Multi-installed APEXes are selected using persist props. |
| 672 | # Load persist properties and override properties (if enabled) from /data, |
| 673 | # before starting apexd. |
| 674 | load_persist_props |
| 675 | start logd |
| 676 | start logd-reinit |
| 677 | # Some existing vendor rc files use 'on load_persist_props_action' to know |
| 678 | # when persist props are ready. These are difficult to change due to GRF, |
| 679 | # so continue triggering this action here even though props are already loaded |
| 680 | # by the 'load_persist_props' call above. |
| 681 | trigger load_persist_props_action |
| 682 | |
Jiyong Park | dcbaf9f | 2019-02-22 22:15:25 +0900 | [diff] [blame] | 683 | # /data/apex is now available. Start apexd to scan and activate APEXes. |
Eric Biggers | 915b8d7 | 2021-04-28 10:15:38 -0700 | [diff] [blame] | 684 | # |
| 685 | # To handle userspace reboots as well as devices that use FDE, make sure |
| 686 | # that apexd is started cleanly here (set apexd.status="") and that it is |
| 687 | # restarted if it's already running. |
Nikita Ioffe | b8591b5 | 2020-04-21 20:50:53 +0100 | [diff] [blame] | 688 | mkdir /data/apex 0755 root system encryption=None |
| 689 | mkdir /data/apex/active 0755 root system |
Jiyong Park | dcbaf9f | 2019-02-22 22:15:25 +0900 | [diff] [blame] | 690 | mkdir /data/apex/backup 0700 root system |
Mohammad Samiul Islam | 60e30a5 | 2021-04-27 21:44:10 +0100 | [diff] [blame] | 691 | mkdir /data/apex/decompressed 0755 root system encryption=Require |
Jooyung Han | baa7c13 | 2019-04-18 11:01:35 +0900 | [diff] [blame] | 692 | mkdir /data/apex/hashtree 0700 root system |
Jiyong Park | dcbaf9f | 2019-02-22 22:15:25 +0900 | [diff] [blame] | 693 | mkdir /data/apex/sessions 0700 root system |
Mohammad Samiul Islam | 64fe2c6 | 2020-12-09 21:05:28 +0000 | [diff] [blame] | 694 | mkdir /data/app-staging 0751 system system encryption=DeleteIfNecessary |
Kelvin Zhang | 1f455c8 | 2021-02-10 09:32:17 -0500 | [diff] [blame] | 695 | mkdir /data/apex/ota_reserved 0700 root system encryption=Require |
Eric Biggers | 915b8d7 | 2021-04-28 10:15:38 -0700 | [diff] [blame] | 696 | setprop apexd.status "" |
| 697 | restart apexd |
Martijn Coenen | 3848e1b | 2018-08-17 13:52:25 +0200 | [diff] [blame] | 698 | |
Paul Crowley | 7583da1 | 2021-04-08 17:04:43 +0000 | [diff] [blame] | 699 | # create rest of basic filesystem structure |
Mark Salyzyn | 9339403 | 2017-07-14 10:37:57 -0700 | [diff] [blame] | 700 | mkdir /data/misc/recovery 0770 system log |
Siqi Lin | b9b76de | 2017-07-26 13:18:15 -0700 | [diff] [blame] | 701 | copy /data/misc/recovery/ro.build.fingerprint /data/misc/recovery/ro.build.fingerprint.1 |
| 702 | chmod 0440 /data/misc/recovery/ro.build.fingerprint.1 |
| 703 | chown system log /data/misc/recovery/ro.build.fingerprint.1 |
| 704 | write /data/misc/recovery/ro.build.fingerprint ${ro.build.fingerprint} |
| 705 | chmod 0440 /data/misc/recovery/ro.build.fingerprint |
| 706 | chown system log /data/misc/recovery/ro.build.fingerprint |
Mark Salyzyn | 9339403 | 2017-07-14 10:37:57 -0700 | [diff] [blame] | 707 | mkdir /data/misc/recovery/proc 0770 system log |
| 708 | copy /data/misc/recovery/proc/version /data/misc/recovery/proc/version.1 |
| 709 | chmod 0440 /data/misc/recovery/proc/version.1 |
| 710 | chown system log /data/misc/recovery/proc/version.1 |
| 711 | copy /proc/version /data/misc/recovery/proc/version |
| 712 | chmod 0440 /data/misc/recovery/proc/version |
| 713 | chown system log /data/misc/recovery/proc/version |
Ajay Panicker | 604208e | 2016-09-20 11:52:14 -0700 | [diff] [blame] | 714 | mkdir /data/misc/bluedroid 02770 bluetooth bluetooth |
Pavlin Radoslavov | 8175bb2 | 2015-06-19 19:12:46 -0700 | [diff] [blame] | 715 | # Fix the access permissions and group ownership for 'bt_config.conf' |
| 716 | chmod 0660 /data/misc/bluedroid/bt_config.conf |
Ajay Panicker | 604208e | 2016-09-20 11:52:14 -0700 | [diff] [blame] | 717 | chown bluetooth bluetooth /data/misc/bluedroid/bt_config.conf |
| 718 | mkdir /data/misc/bluetooth 0770 bluetooth bluetooth |
| 719 | mkdir /data/misc/bluetooth/logs 0770 bluetooth bluetooth |
Jack Yu | 6097da8 | 2020-07-08 17:08:16 +0800 | [diff] [blame] | 720 | mkdir /data/misc/nfc 0770 nfc nfc |
| 721 | mkdir /data/misc/nfc/logs 0770 nfc nfc |
David Zeuthen | e83f386 | 2019-10-28 13:42:14 -0400 | [diff] [blame] | 722 | mkdir /data/misc/credstore 0700 credstore credstore |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 723 | mkdir /data/misc/gatekeeper 0700 system system |
Brian Carlstrom | 0491893 | 2011-06-30 22:50:29 -0700 | [diff] [blame] | 724 | mkdir /data/misc/keychain 0771 system system |
Sreeram Ramachandran | b46efdb | 2014-07-07 22:09:54 -0700 | [diff] [blame] | 725 | mkdir /data/misc/net 0750 root shell |
Robert Greenwalt | 2aa33a3 | 2013-07-16 09:46:17 -0700 | [diff] [blame] | 726 | mkdir /data/misc/radio 0770 system radio |
Robert Greenwalt | d6d4780 | 2012-09-26 16:04:27 -0700 | [diff] [blame] | 727 | mkdir /data/misc/sms 0770 system radio |
fionaxu | 06b8e2e | 2017-11-21 12:31:57 -0800 | [diff] [blame] | 728 | mkdir /data/misc/carrierid 0770 system radio |
Niklas Lindgren | fd66538 | 2018-05-21 16:53:00 +0200 | [diff] [blame] | 729 | mkdir /data/misc/apns 0770 system radio |
Shuo Qian | f0e65d8 | 2019-10-14 13:24:58 -0700 | [diff] [blame] | 730 | mkdir /data/misc/emergencynumberdb 0770 system radio |
Elliott Hughes | f820e85 | 2012-10-19 18:10:05 -0700 | [diff] [blame] | 731 | mkdir /data/misc/zoneinfo 0775 system system |
Ricky Wai | 88d5dcb | 2017-10-27 16:35:35 +0100 | [diff] [blame] | 732 | mkdir /data/misc/network_watchlist 0774 system system |
Abodunrinwa Toki | d6ab645 | 2017-04-27 18:46:59 +0100 | [diff] [blame] | 733 | mkdir /data/misc/textclassifier 0771 system system |
Chia-chi Yeh | 9bb4d41 | 2011-07-08 20:03:03 -0700 | [diff] [blame] | 734 | mkdir /data/misc/vpn 0770 system vpn |
Torne (Richard Coles) | 234f696 | 2014-05-22 18:40:21 +0100 | [diff] [blame] | 735 | mkdir /data/misc/shared_relro 0771 shared_relro shared_relro |
Oscar Montemayor | d0aa32c | 2010-01-06 13:18:12 -0800 | [diff] [blame] | 736 | mkdir /data/misc/systemkeys 0700 system system |
Mike Lockwood | 48d116e | 2009-07-08 18:42:08 -0400 | [diff] [blame] | 737 | mkdir /data/misc/wifi 0770 wifi wifi |
Stephen Smalley | 82e87ed | 2014-01-29 13:53:03 -0500 | [diff] [blame] | 738 | mkdir /data/misc/wifi/sockets 0770 wifi wifi |
Stephen Smalley | 82e87ed | 2014-01-29 13:53:03 -0500 | [diff] [blame] | 739 | mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi |
Jaewan Kim | 373d9fa | 2014-03-10 17:13:07 +0900 | [diff] [blame] | 740 | mkdir /data/misc/ethernet 0770 system system |
Stephen Smalley | 82e87ed | 2014-01-29 13:53:03 -0500 | [diff] [blame] | 741 | mkdir /data/misc/dhcp 0770 dhcp dhcp |
Robin Lee | 3094f82 | 2014-04-25 15:21:35 +0100 | [diff] [blame] | 742 | mkdir /data/misc/user 0771 root root |
Stephen Smalley | 82e87ed | 2014-01-29 13:53:03 -0500 | [diff] [blame] | 743 | # give system access to wpa_supplicant.conf for backup and restore |
Amith Yamasani | eefef32 | 2009-07-02 12:08:13 -0700 | [diff] [blame] | 744 | chmod 0660 /data/misc/wifi/wpa_supplicant.conf |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 745 | mkdir /data/local 0751 root root encryption=Require |
Glenn Kasten | b0f908a | 2013-02-22 14:54:45 -0800 | [diff] [blame] | 746 | mkdir /data/misc/media 0700 media media |
Glenn Kasten | 845a4ff | 2016-02-23 15:23:46 -0800 | [diff] [blame] | 747 | mkdir /data/misc/audioserver 0700 audioserver audioserver |
Keun Soo Yim | be54c54 | 2016-03-01 12:45:27 -0800 | [diff] [blame] | 748 | mkdir /data/misc/cameraserver 0700 cameraserver cameraserver |
Paul Crowley | f8a6fa5 | 2015-06-03 13:33:43 +0100 | [diff] [blame] | 749 | mkdir /data/misc/vold 0700 root root |
Yasuhiro Matsuda | f93db4b | 2015-06-15 18:49:35 +0900 | [diff] [blame] | 750 | mkdir /data/misc/boottrace 0771 system shell |
David Zeuthen | 1591478 | 2015-10-07 14:00:55 -0400 | [diff] [blame] | 751 | mkdir /data/misc/update_engine 0700 root root |
Tianjie Xu | 74fa3ca | 2017-11-03 10:59:36 -0700 | [diff] [blame] | 752 | mkdir /data/misc/update_engine_log 02750 root log |
Calin Juravle | 9b3e5d5 | 2015-11-10 19:16:43 +0000 | [diff] [blame] | 753 | mkdir /data/misc/trace 0700 root root |
Vishnu Nair | d09ab7a | 2017-11-27 09:54:31 -0800 | [diff] [blame] | 754 | # create location to store surface and window trace files |
| 755 | mkdir /data/misc/wmtrace 0700 system system |
Hongming Jin | 87f55fe | 2021-02-09 11:54:46 -0800 | [diff] [blame] | 756 | # create location to store accessibility trace files |
| 757 | mkdir /data/misc/a11ytrace 0700 system system |
Calin Juravle | 807f23a | 2016-02-01 19:27:01 +0000 | [diff] [blame] | 758 | # profile file layout |
| 759 | mkdir /data/misc/profiles 0771 system system |
| 760 | mkdir /data/misc/profiles/cur 0771 system system |
Calin Juravle | 11197dd | 2021-05-14 11:28:04 -0700 | [diff] [blame] | 761 | mkdir /data/misc/profiles/ref 0771 system system |
David Sehr | 0eb24e1 | 2016-05-28 14:10:38 -0700 | [diff] [blame] | 762 | mkdir /data/misc/profman 0770 system shell |
Ryan Campbell | 0b36473 | 2017-02-21 17:27:02 -0800 | [diff] [blame] | 763 | mkdir /data/misc/gcov 0770 root root |
Paul Crowley | 26aabfd | 2019-08-16 12:39:17 -0700 | [diff] [blame] | 764 | mkdir /data/misc/installd 0700 root root |
Oli Lan | 90c523b | 2020-01-17 11:41:04 +0000 | [diff] [blame] | 765 | mkdir /data/misc/apexdata 0711 root root |
Oli Lan | 4370ff5 | 2019-12-02 18:24:12 +0000 | [diff] [blame] | 766 | mkdir /data/misc/apexrollback 0700 root root |
Andrei Onea | 3c50588 | 2020-12-23 15:26:11 +0000 | [diff] [blame] | 767 | mkdir /data/misc/appcompat/ 0700 system system |
Yifan Hong | 7d28688 | 2020-02-08 16:38:56 -0800 | [diff] [blame] | 768 | mkdir /data/misc/snapshotctl_log 0755 root root |
Jerry Chang | aedac7e | 2020-01-02 10:57:30 +0800 | [diff] [blame] | 769 | # create location to store pre-reboot information |
| 770 | mkdir /data/misc/prereboot 0700 system system |
Orion Hodson | 44bedf6 | 2021-04-09 15:04:15 +0100 | [diff] [blame] | 771 | # directory used for on-device refresh metrics file. |
| 772 | mkdir /data/misc/odrefresh 0777 system system |
Martijn Coenen | 00e51a4 | 2020-11-27 12:21:34 +0100 | [diff] [blame] | 773 | # directory used for on-device signing key blob |
| 774 | mkdir /data/misc/odsign 0700 root root |
Andrew Walbran | 1f885ae | 2021-07-14 13:39:13 +0000 | [diff] [blame] | 775 | # Directory for VirtualizationService temporary image files. |
Andrew Walbran | 2934ee0 | 2021-05-19 17:09:44 +0000 | [diff] [blame] | 776 | mkdir /data/misc/virtualizationservice 0700 virtualizationservice virtualizationservice |
Stephen Smalley | deb41e5 | 2013-10-01 09:21:47 -0400 | [diff] [blame] | 777 | |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 778 | mkdir /data/preloads 0775 system system encryption=None |
Anton Hansson | c38a636 | 2018-10-24 15:29:16 +0100 | [diff] [blame] | 779 | |
Nick Kralevich | f3ef127 | 2012-03-14 15:22:54 -0700 | [diff] [blame] | 780 | # For security reasons, /data/local/tmp should always be empty. |
| 781 | # Do not place files or directories in /data/local/tmp |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 782 | mkdir /data/local/tmp 0771 shell shell |
Max Bires | 181d11c | 2018-01-18 14:23:51 -0800 | [diff] [blame] | 783 | mkdir /data/local/traces 0777 shell shell |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 784 | mkdir /data/data 0771 system system encryption=None |
| 785 | mkdir /data/app-private 0771 system system encryption=Require |
| 786 | mkdir /data/app-ephemeral 0771 system system encryption=Require |
| 787 | mkdir /data/app-asec 0700 root root encryption=Require |
| 788 | mkdir /data/app-lib 0771 system system encryption=Require |
| 789 | mkdir /data/app 0771 system system encryption=Require |
| 790 | mkdir /data/property 0700 root root encryption=Require |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 791 | |
Seigo Nonaka | 18e4372 | 2020-11-17 20:06:49 -0800 | [diff] [blame] | 792 | # create directory for updated font files. |
| 793 | mkdir /data/fonts/ 0771 root root encryption=Require |
| 794 | mkdir /data/fonts/files 0771 system system |
| 795 | mkdir /data/fonts/config 0770 system system |
| 796 | |
Colin Cross | 7201ef8 | 2020-08-31 16:15:28 -0700 | [diff] [blame] | 797 | # Create directories to push tests to for each linker namespace. |
| 798 | # Create the subdirectories in case the first test is run as root |
| 799 | # so it doesn't end up owned by root. |
Christopher Ferris | 2163bbb | 2021-09-08 12:36:24 -0700 | [diff] [blame] | 800 | # Set directories to be executable by any process so that debuggerd, |
| 801 | # aka crash_dump, can read any executables/shared libraries. |
| 802 | mkdir /data/local/tests 0701 shell shell |
| 803 | mkdir /data/local/tests/product 0701 shell shell |
| 804 | mkdir /data/local/tests/system 0701 shell shell |
| 805 | mkdir /data/local/tests/unrestricted 0701 shell shell |
| 806 | mkdir /data/local/tests/vendor 0701 shell shell |
Colin Cross | 7201ef8 | 2020-08-31 16:15:28 -0700 | [diff] [blame] | 807 | |
Chia-chi Yeh | ea74414 | 2011-07-08 16:52:18 -0700 | [diff] [blame] | 808 | # create dalvik-cache, so as to enforce our permissions |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 809 | mkdir /data/dalvik-cache 0771 root root encryption=Require |
Andreas Gampe | 7dfcc92 | 2015-12-08 09:33:07 -0800 | [diff] [blame] | 810 | # create the A/B OTA directory, so as to enforce our permissions |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 811 | mkdir /data/ota 0771 root root encryption=Require |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 812 | |
Tao Bao | 380d6b1 | 2016-05-25 16:41:08 -0700 | [diff] [blame] | 813 | # create the OTA package directory. It will be accessed by GmsCore (cache |
| 814 | # group), update_engine and update_verifier. |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 815 | mkdir /data/ota_package 0770 system cache encryption=Require |
Tao Bao | 380d6b1 | 2016-05-25 16:41:08 -0700 | [diff] [blame] | 816 | |
Mårten Kongstad | b45280d | 2011-05-30 10:24:54 +0200 | [diff] [blame] | 817 | # create resource-cache and double-check the perms |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 818 | mkdir /data/resource-cache 0771 system system encryption=Require |
Mårten Kongstad | b45280d | 2011-05-30 10:24:54 +0200 | [diff] [blame] | 819 | chown system system /data/resource-cache |
| 820 | chmod 0771 /data/resource-cache |
| 821 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 822 | # create the lost+found directories, so as to enforce our permissions |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 823 | mkdir /data/lost+found 0770 root root encryption=None |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 824 | |
James Dong | 09cdc0e | 2012-01-06 15:19:26 -0800 | [diff] [blame] | 825 | # create directory for DRM plug-ins - give drm the read/write access to |
| 826 | # the following directory. |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 827 | mkdir /data/drm 0770 drm drm encryption=Require |
aimitakeshi | e572d59 | 2010-07-27 08:38:35 +0900 | [diff] [blame] | 828 | |
Jeff Tinker | 08d6430 | 2013-04-23 19:54:17 -0700 | [diff] [blame] | 829 | # create directory for MediaDrm plug-ins - give drm the read/write access to |
| 830 | # the following directory. |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 831 | mkdir /data/mediadrm 0770 mediadrm mediadrm encryption=Require |
Jeff Tinker | 08d6430 | 2013-04-23 19:54:17 -0700 | [diff] [blame] | 832 | |
Tom Cherry | c319310 | 2017-11-21 10:40:25 -0800 | [diff] [blame] | 833 | # NFC: create data/nfc for nv storage |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 834 | mkdir /data/nfc 0770 nfc nfc encryption=Require |
Tom Cherry | c319310 | 2017-11-21 10:40:25 -0800 | [diff] [blame] | 835 | mkdir /data/nfc/param 0770 nfc nfc |
| 836 | |
Paul Lawrence | c410b3b | 2015-03-26 15:49:42 +0000 | [diff] [blame] | 837 | # Create all remaining /data root dirs so that they are made through init |
| 838 | # and get proper encryption policy installed |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 839 | mkdir /data/backup 0700 system system encryption=Require |
| 840 | mkdir /data/ss 0700 system system encryption=Require |
Jeff Sharkey | 1170586 | 2015-11-09 17:07:35 -0800 | [diff] [blame] | 841 | |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 842 | mkdir /data/system 0775 system system encryption=Require |
Artur Satayev | 441e6b9 | 2021-03-30 11:49:05 +0100 | [diff] [blame] | 843 | mkdir /data/system/environ 0700 system system |
| 844 | # b/183861600 attempt to fix selinux label before running derive_classpath service |
| 845 | restorecon /data/system/environ |
Jeff Vander Stoep | 148dea7 | 2018-04-16 16:04:38 -0700 | [diff] [blame] | 846 | mkdir /data/system/dropbox 0700 system system |
Nick Kralevich | 9c0437f | 2015-04-07 16:44:08 -0700 | [diff] [blame] | 847 | mkdir /data/system/heapdump 0700 system system |
Jeff Sharkey | c9b84a3 | 2016-04-14 21:09:34 -0600 | [diff] [blame] | 848 | mkdir /data/system/users 0775 system system |
Jeff Sharkey | 3b9c83a | 2016-02-03 14:44:44 -0700 | [diff] [blame] | 849 | |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 850 | mkdir /data/system_de 0770 system system encryption=None |
| 851 | mkdir /data/system_ce 0770 system system encryption=None |
Jeff Sharkey | 3b9c83a | 2016-02-03 14:44:44 -0700 | [diff] [blame] | 852 | |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 853 | mkdir /data/misc_de 01771 system misc encryption=None |
| 854 | mkdir /data/misc_ce 01771 system misc encryption=None |
Jeff Sharkey | 1170586 | 2015-11-09 17:07:35 -0800 | [diff] [blame] | 855 | |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 856 | mkdir /data/user 0711 system system encryption=None |
| 857 | mkdir /data/user_de 0711 system system encryption=None |
Ricky Wai | 3cca270 | 2019-12-12 12:55:03 +0000 | [diff] [blame] | 858 | |
| 859 | # Unlink /data/user/0 if we previously symlink it to /data/data |
| 860 | rm /data/user/0 |
| 861 | |
| 862 | # Bind mount /data/user/0 to /data/data |
| 863 | mkdir /data/user/0 0700 system system encryption=None |
| 864 | mount none /data/data /data/user/0 bind rec |
Paul Lawrence | c410b3b | 2015-03-26 15:49:42 +0000 | [diff] [blame] | 865 | |
Ricky Wai | 3cca270 | 2019-12-12 12:55:03 +0000 | [diff] [blame] | 866 | # A tmpfs directory, which will contain all apps CE DE data directory that |
| 867 | # bind mount from the original source. |
Ricky Wai | 1a5ae50 | 2020-03-04 13:30:09 +0000 | [diff] [blame] | 868 | mount tmpfs tmpfs /data_mirror nodev noexec nosuid mode=0700,uid=0,gid=1000 |
Ricky Wai | 3cca270 | 2019-12-12 12:55:03 +0000 | [diff] [blame] | 869 | restorecon /data_mirror |
| 870 | mkdir /data_mirror/data_ce 0700 root root |
| 871 | mkdir /data_mirror/data_de 0700 root root |
| 872 | |
| 873 | # Create CE and DE data directory for default volume |
| 874 | mkdir /data_mirror/data_ce/null 0700 root root |
| 875 | mkdir /data_mirror/data_de/null 0700 root root |
| 876 | |
| 877 | # Bind mount CE and DE data directory to mirror's default volume directory |
| 878 | mount none /data/user /data_mirror/data_ce/null bind rec |
| 879 | mount none /data/user_de /data_mirror/data_de/null bind rec |
| 880 | |
Ricky Wai | fdc0986 | 2019-12-13 17:32:18 +0000 | [diff] [blame] | 881 | # Create mirror directory for jit profiles |
| 882 | mkdir /data_mirror/cur_profiles 0700 root root |
| 883 | mount none /data/misc/profiles/cur /data_mirror/cur_profiles bind rec |
Ricky Wai | 420830f | 2021-06-08 12:15:14 +0100 | [diff] [blame] | 884 | mkdir /data_mirror/ref_profiles 0700 root root |
| 885 | mount none /data/misc/profiles/ref /data_mirror/ref_profiles bind rec |
Ricky Wai | fdc0986 | 2019-12-13 17:32:18 +0000 | [diff] [blame] | 886 | |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 887 | mkdir /data/cache 0770 system cache encryption=Require |
Yueyao (Nathan) Zhu | 60c6dac | 2016-06-21 12:04:54 -0700 | [diff] [blame] | 888 | mkdir /data/cache/recovery 0770 system cache |
| 889 | mkdir /data/cache/backup_stage 0700 system system |
| 890 | mkdir /data/cache/backup 0700 system system |
| 891 | |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 892 | # Delete these if need be, per b/139193659 |
| 893 | mkdir /data/rollback 0700 system system encryption=DeleteIfNecessary |
| 894 | mkdir /data/rollback-observer 0700 system system encryption=DeleteIfNecessary |
JW Wang | 5fc74a4 | 2020-11-13 15:45:49 +0800 | [diff] [blame] | 895 | mkdir /data/rollback-history 0700 system system encryption=DeleteIfNecessary |
Paul Crowley | 8184d7c | 2019-08-09 14:13:41 -0700 | [diff] [blame] | 896 | |
Songchun Fan | 2849624 | 2019-12-17 12:41:34 -0800 | [diff] [blame] | 897 | # Create root dir for Incremental Service |
Songchun Fan | 73d9e7d | 2019-12-19 16:04:11 -0800 | [diff] [blame] | 898 | mkdir /data/incremental 0771 system system encryption=Require |
Songchun Fan | 2849624 | 2019-12-17 12:41:34 -0800 | [diff] [blame] | 899 | |
Jeffrey Huang | 8dccf3f | 2020-02-19 10:56:17 -0800 | [diff] [blame] | 900 | # Create directories for statsd |
Jeffrey Huang | 8dccf3f | 2020-02-19 10:56:17 -0800 | [diff] [blame] | 901 | mkdir /data/misc/stats-active-metric/ 0770 statsd system |
Jeffrey Huang | 58c8861 | 2020-03-05 08:53:11 -0800 | [diff] [blame] | 902 | mkdir /data/misc/stats-data/ 0770 statsd system |
| 903 | mkdir /data/misc/stats-metadata/ 0770 statsd system |
| 904 | mkdir /data/misc/stats-service/ 0770 statsd system |
Jeffrey Huang | 8dccf3f | 2020-02-19 10:56:17 -0800 | [diff] [blame] | 905 | mkdir /data/misc/train-info/ 0770 statsd system |
| 906 | |
Jiyong Park | dcbaf9f | 2019-02-22 22:15:25 +0900 | [diff] [blame] | 907 | # Wait for apexd to finish activating APEXes before starting more processes. |
Oli Lan | 3cb185e | 2020-02-06 11:55:51 +0000 | [diff] [blame] | 908 | wait_for_prop apexd.status activated |
Oli Lan | 13e51e7 | 2019-11-19 18:08:45 +0000 | [diff] [blame] | 909 | perform_apex_config |
| 910 | |
Daniel Rosenberg | ebfe359 | 2019-12-20 13:17:19 -0800 | [diff] [blame] | 911 | # Special-case /data/media/obb per b/64566063 |
| 912 | mkdir /data/media 0770 media_rw media_rw encryption=None |
| 913 | exec - media_rw media_rw -- /system/bin/chattr +F /data/media |
| 914 | mkdir /data/media/obb 0770 media_rw media_rw encryption=Attempt |
| 915 | |
Anton Hansson | 3c5cc31 | 2019-12-05 15:38:37 +0000 | [diff] [blame] | 916 | exec_start derive_sdk |
Jiyong Park | dcbaf9f | 2019-02-22 22:15:25 +0900 | [diff] [blame] | 917 | |
Paul Crowley | 5949745 | 2016-02-01 16:37:13 +0000 | [diff] [blame] | 918 | init_user0 |
| 919 | |
Martijn Coenen | c7a26dc | 2021-01-18 11:14:22 +0100 | [diff] [blame] | 920 | # Set SELinux security contexts on upgrade or policy update. |
| 921 | restorecon --recursive --skip-ce /data |
| 922 | |
Artur Satayev | 7df7997 | 2021-03-30 11:56:40 +0100 | [diff] [blame] | 923 | # Define and export *CLASSPATH variables |
| 924 | # Must start before 'odsign', as odsign depends on *CLASSPATH variables |
| 925 | exec_start derive_classpath |
| 926 | load_exports /data/system/environ/classpath |
Artur Satayev | 7df7997 | 2021-03-30 11:56:40 +0100 | [diff] [blame] | 927 | |
Martijn Coenen | 00e51a4 | 2020-11-27 12:21:34 +0100 | [diff] [blame] | 928 | # Start the on-device signing daemon, and wait for it to finish, to ensure |
| 929 | # ART artifacts are generated if needed. |
satayev | 52cc896 | 2021-03-19 11:08:49 +0000 | [diff] [blame] | 930 | # Must start after 'derive_classpath' to have *CLASSPATH variables set. |
Martijn Coenen | 648dec6 | 2021-03-17 08:44:55 +0100 | [diff] [blame] | 931 | start odsign |
| 932 | |
| 933 | # Before we can lock keys and proceed to the next boot stage, wait for |
| 934 | # odsign to be done with the key |
| 935 | wait_for_prop odsign.key.done 1 |
Martijn Coenen | 00e51a4 | 2020-11-27 12:21:34 +0100 | [diff] [blame] | 936 | |
Martijn Coenen | c7a26dc | 2021-01-18 11:14:22 +0100 | [diff] [blame] | 937 | # Lock the fs-verity keyring, so no more keys can be added |
| 938 | exec -- /system/bin/fsverity_init --lock |
| 939 | |
Paul Crowley | 7583da1 | 2021-04-08 17:04:43 +0000 | [diff] [blame] | 940 | # Bump the boot level to 1000000000; this prevents further on-device signing. |
| 941 | # This is a special value that shuts down the thread which listens for |
| 942 | # further updates. |
| 943 | setprop keystore.boot_level 1000000000 |
Martijn Coenen | e94b366 | 2021-03-09 10:57:00 +0100 | [diff] [blame] | 944 | |
Oli Lan | a466ca8 | 2020-01-23 19:52:42 +0000 | [diff] [blame] | 945 | # Allow apexd to snapshot and restore device encrypted apex data in the case |
| 946 | # of a rollback. This should be done immediately after DE_user data keys |
| 947 | # are loaded. APEXes should not access this data until this has been |
Oli Lan | 3cb185e | 2020-02-06 11:55:51 +0000 | [diff] [blame] | 948 | # completed and apexd.status becomes "ready". |
Oli Lan | a466ca8 | 2020-01-23 19:52:42 +0000 | [diff] [blame] | 949 | exec_start apexd-snapshotde |
| 950 | |
Neil Fuller | 09bdb32 | 2019-06-06 15:18:36 +0100 | [diff] [blame] | 951 | # Check any timezone data in /data is newer than the copy in the time zone data |
| 952 | # module, delete if not. |
| 953 | exec - system system -- /system/bin/tzdatacheck /apex/com.android.tzdata/etc/tz /data/misc/zoneinfo |
Neil Fuller | ada7e49 | 2019-02-22 14:05:40 +0000 | [diff] [blame] | 954 | |
Steven Moreland | f38aab4 | 2017-01-25 10:52:15 -0800 | [diff] [blame] | 955 | # If there is no post-fs-data action in the init.<device>.rc file, you |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 956 | # must uncomment this line, otherwise encrypted filesystems |
| 957 | # won't work. |
| 958 | # Set indication (checked by vold) that we have finished this action |
| 959 | #setprop vold.post_fs_data_done 1 |
| 960 | |
Joel Fernandes | ae7f052 | 2019-01-31 19:27:23 -0500 | [diff] [blame] | 961 | # sys.memfd_use set to false by default, which keeps it disabled |
| 962 | # until it is confirmed that apps and vendor processes don't make |
| 963 | # IOCTLs on ashmem fds any more. |
| 964 | setprop sys.use_memfd false |
| 965 | |
Wei Wang | ec78cca | 2019-04-19 10:58:39 -0700 | [diff] [blame] | 966 | # Set fscklog permission |
| 967 | chown root system /dev/fscklogs/log |
| 968 | chmod 0770 /dev/fscklogs/log |
| 969 | |
Zim | 8dacabe | 2020-02-10 20:24:40 +0000 | [diff] [blame] | 970 | # Enable FUSE by default |
| 971 | setprop persist.sys.fuse true |
| 972 | |
Wei Wang | 53842e7 | 2017-04-20 14:37:55 -0700 | [diff] [blame] | 973 | # It is recommended to put unnecessary data/ initialization from post-fs-data |
| 974 | # to start-zygote in device's init.rc to unblock zygote start. |
| 975 | on zygote-start && property:ro.crypto.state=unencrypted |
Martijn Coenen | 648dec6 | 2021-03-17 08:44:55 +0100 | [diff] [blame] | 976 | wait_for_prop odsign.verification.done 1 |
Wei Wang | 53842e7 | 2017-04-20 14:37:55 -0700 | [diff] [blame] | 977 | # A/B update verifier that marks a successful boot. |
| 978 | exec_start update_verifier_nonencrypted |
Keun young Park | 6423ccd | 2020-06-23 20:32:54 -0700 | [diff] [blame] | 979 | start statsd |
Wei Wang | 53842e7 | 2017-04-20 14:37:55 -0700 | [diff] [blame] | 980 | start netd |
| 981 | start zygote |
| 982 | start zygote_secondary |
| 983 | |
| 984 | on zygote-start && property:ro.crypto.state=unsupported |
Martijn Coenen | 648dec6 | 2021-03-17 08:44:55 +0100 | [diff] [blame] | 985 | wait_for_prop odsign.verification.done 1 |
Wei Wang | 53842e7 | 2017-04-20 14:37:55 -0700 | [diff] [blame] | 986 | # A/B update verifier that marks a successful boot. |
| 987 | exec_start update_verifier_nonencrypted |
Keun young Park | 6423ccd | 2020-06-23 20:32:54 -0700 | [diff] [blame] | 988 | start statsd |
Wei Wang | 53842e7 | 2017-04-20 14:37:55 -0700 | [diff] [blame] | 989 | start netd |
| 990 | start zygote |
| 991 | start zygote_secondary |
| 992 | |
Wei Wang | bae9ba3 | 2017-03-09 12:35:02 -0800 | [diff] [blame] | 993 | on zygote-start && property:ro.crypto.state=encrypted && property:ro.crypto.type=file |
Martijn Coenen | 648dec6 | 2021-03-17 08:44:55 +0100 | [diff] [blame] | 994 | wait_for_prop odsign.verification.done 1 |
Wei Wang | 53842e7 | 2017-04-20 14:37:55 -0700 | [diff] [blame] | 995 | # A/B update verifier that marks a successful boot. |
| 996 | exec_start update_verifier_nonencrypted |
Keun young Park | 6423ccd | 2020-06-23 20:32:54 -0700 | [diff] [blame] | 997 | start statsd |
Wei Wang | 53842e7 | 2017-04-20 14:37:55 -0700 | [diff] [blame] | 998 | start netd |
| 999 | start zygote |
| 1000 | start zygote_secondary |
Wei Wang | bae9ba3 | 2017-03-09 12:35:02 -0800 | [diff] [blame] | 1001 | |
Jaegeuk Kim | 58ff507 | 2019-04-02 07:01:43 -0700 | [diff] [blame] | 1002 | on boot && property:ro.config.low_ram=true |
| 1003 | # Tweak background writeout |
| 1004 | write /proc/sys/vm/dirty_expire_centisecs 200 |
| 1005 | write /proc/sys/vm/dirty_background_ratio 5 |
| 1006 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1007 | on boot |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 1008 | # basic network init |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1009 | ifup lo |
| 1010 | hostname localhost |
| 1011 | domainname localdomain |
| 1012 | |
Benedict Wong | 00308f8 | 2018-03-12 19:00:50 -0700 | [diff] [blame] | 1013 | # IPsec SA default expiration length |
| 1014 | write /proc/sys/net/core/xfrm_acq_expires 3600 |
| 1015 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 1016 | # Memory management. Basic kernel parameters, and allow the high |
| 1017 | # level system server to be able to adjust the kernel OOM driver |
| 1018 | # parameters to match how it is managing things. |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1019 | write /proc/sys/vm/overcommit_memory 1 |
The Android Open Source Project | e037fd7 | 2009-03-13 13:04:37 -0700 | [diff] [blame] | 1020 | write /proc/sys/vm/min_free_order_shift 4 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1021 | |
Srinivas Paladugu | 3a63283 | 2019-01-09 11:28:59 -0800 | [diff] [blame] | 1022 | # System server manages zram writeback |
| 1023 | chown root system /sys/block/zram0/idle |
| 1024 | chmod 0664 /sys/block/zram0/idle |
| 1025 | chown root system /sys/block/zram0/writeback |
| 1026 | chmod 0664 /sys/block/zram0/writeback |
| 1027 | |
Jaegeuk Kim | 43dca3c | 2020-07-20 17:34:47 -0700 | [diff] [blame] | 1028 | # to access F2FS sysfs on dm-<num> directly |
| 1029 | mkdir /dev/sys/fs/by-name 0755 system system |
Guo Weichao | bcefbb1 | 2021-05-26 11:12:11 +0800 | [diff] [blame] | 1030 | symlink /sys/fs/f2fs/${dev.mnt.dev.data} /dev/sys/fs/by-name/userdata |
Jaegeuk Kim | 43dca3c | 2020-07-20 17:34:47 -0700 | [diff] [blame] | 1031 | |
| 1032 | # to access dm-<num> sysfs |
| 1033 | mkdir /dev/sys/block/by-name 0755 system system |
Guo Weichao | bcefbb1 | 2021-05-26 11:12:11 +0800 | [diff] [blame] | 1034 | symlink /sys/devices/virtual/block/${dev.mnt.dev.data} /dev/sys/block/by-name/userdata |
Jaegeuk Kim | 43dca3c | 2020-07-20 17:34:47 -0700 | [diff] [blame] | 1035 | |
Jaegeuk Kim | 58ff507 | 2019-04-02 07:01:43 -0700 | [diff] [blame] | 1036 | # F2FS tuning. Set cp_interval larger than dirty_expire_centisecs, 30 secs, |
Jaegeuk Kim | f65df96 | 2019-03-29 09:16:51 -0700 | [diff] [blame] | 1037 | # to avoid power consumption when system becomes mostly idle. Be careful |
| 1038 | # to make it too large, since it may bring userdata loss, if they |
| 1039 | # are not aware of using fsync()/sync() to prepare sudden power-cut. |
Jaegeuk Kim | 43dca3c | 2020-07-20 17:34:47 -0700 | [diff] [blame] | 1040 | write /dev/sys/fs/by-name/userdata/cp_interval 200 |
| 1041 | write /dev/sys/fs/by-name/userdata/gc_urgent_sleep_time 50 |
| 1042 | write /dev/sys/fs/by-name/userdata/iostat_enable 1 |
Jaegeuk Kim | f65df96 | 2019-03-29 09:16:51 -0700 | [diff] [blame] | 1043 | |
Jaegeuk Kim | fe9e8a3 | 2019-11-27 15:42:10 -0800 | [diff] [blame] | 1044 | # limit discard size to 128MB in order to avoid long IO latency |
| 1045 | # for filesystem tuning first (dm or sda) |
| 1046 | # Note that, if dm-<num> is used, sda/mmcblk0 should be tuned in vendor/init.rc |
Jaegeuk Kim | 43dca3c | 2020-07-20 17:34:47 -0700 | [diff] [blame] | 1047 | write /dev/sys/block/by-name/userdata/queue/discard_max_bytes 134217728 |
Jaegeuk Kim | fe9e8a3 | 2019-11-27 15:42:10 -0800 | [diff] [blame] | 1048 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1049 | # Permissions for System Server and daemons. |
Arve Hjønnevåg | 70a163f | 2012-05-02 17:57:50 -0700 | [diff] [blame] | 1050 | chown system system /sys/power/autosleep |
Todd Poynor | 0653b97 | 2012-04-11 14:48:51 -0700 | [diff] [blame] | 1051 | |
| 1052 | chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_rate |
| 1053 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_rate |
Todd Poynor | 2b5b3bb | 2012-12-20 18:52:03 -0800 | [diff] [blame] | 1054 | chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_slack |
| 1055 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_slack |
Todd Poynor | 0653b97 | 2012-04-11 14:48:51 -0700 | [diff] [blame] | 1056 | chown system system /sys/devices/system/cpu/cpufreq/interactive/min_sample_time |
| 1057 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/min_sample_time |
| 1058 | chown system system /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq |
| 1059 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq |
Todd Poynor | 2b5b3bb | 2012-12-20 18:52:03 -0800 | [diff] [blame] | 1060 | chown system system /sys/devices/system/cpu/cpufreq/interactive/target_loads |
| 1061 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/target_loads |
Todd Poynor | 0653b97 | 2012-04-11 14:48:51 -0700 | [diff] [blame] | 1062 | chown system system /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load |
| 1063 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load |
Todd Poynor | f35c203 | 2012-04-19 13:17:24 -0700 | [diff] [blame] | 1064 | chown system system /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay |
| 1065 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay |
Todd Poynor | 8d3ea1d | 2012-04-24 15:37:13 -0700 | [diff] [blame] | 1066 | chown system system /sys/devices/system/cpu/cpufreq/interactive/boost |
| 1067 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boost |
Todd Poynor | 4ff10e6 | 2012-05-03 15:20:48 -0700 | [diff] [blame] | 1068 | chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse |
Todd Poynor | 33045a6 | 2012-04-27 20:21:18 -0700 | [diff] [blame] | 1069 | chown system system /sys/devices/system/cpu/cpufreq/interactive/input_boost |
| 1070 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/input_boost |
Todd Poynor | 4f247d7 | 2012-12-19 17:43:06 -0800 | [diff] [blame] | 1071 | chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration |
| 1072 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration |
Todd Poynor | 6b5de1c | 2013-03-25 13:17:13 -0700 | [diff] [blame] | 1073 | chown system system /sys/devices/system/cpu/cpufreq/interactive/io_is_busy |
| 1074 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/io_is_busy |
Todd Poynor | 0653b97 | 2012-04-11 14:48:51 -0700 | [diff] [blame] | 1075 | |
| 1076 | # Assume SMP uses shared cpufreq policy for all CPUs |
| 1077 | chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq |
| 1078 | chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq |
| 1079 | |
David Lin | 27b2c1e | 2017-03-08 17:36:18 -0800 | [diff] [blame] | 1080 | chown system system /sys/class/leds/vibrator/trigger |
| 1081 | chown system system /sys/class/leds/vibrator/activate |
| 1082 | chown system system /sys/class/leds/vibrator/brightness |
| 1083 | chown system system /sys/class/leds/vibrator/duration |
| 1084 | chown system system /sys/class/leds/vibrator/state |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1085 | chown system system /sys/class/timed_output/vibrator/enable |
| 1086 | chown system system /sys/class/leds/keyboard-backlight/brightness |
| 1087 | chown system system /sys/class/leds/lcd-backlight/brightness |
| 1088 | chown system system /sys/class/leds/button-backlight/brightness |
The Android Open Source Project | f614d64 | 2009-03-18 17:39:49 -0700 | [diff] [blame] | 1089 | chown system system /sys/class/leds/jogball-backlight/brightness |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1090 | chown system system /sys/class/leds/red/brightness |
| 1091 | chown system system /sys/class/leds/green/brightness |
| 1092 | chown system system /sys/class/leds/blue/brightness |
| 1093 | chown system system /sys/class/leds/red/device/grpfreq |
| 1094 | chown system system /sys/class/leds/red/device/grppwm |
| 1095 | chown system system /sys/class/leds/red/device/blink |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1096 | chown system system /sys/module/sco/parameters/disable_esco |
| 1097 | chown system system /sys/kernel/ipv4/tcp_wmem_min |
| 1098 | chown system system /sys/kernel/ipv4/tcp_wmem_def |
| 1099 | chown system system /sys/kernel/ipv4/tcp_wmem_max |
| 1100 | chown system system /sys/kernel/ipv4/tcp_rmem_min |
| 1101 | chown system system /sys/kernel/ipv4/tcp_rmem_def |
| 1102 | chown system system /sys/kernel/ipv4/tcp_rmem_max |
| 1103 | chown root radio /proc/cmdline |
| 1104 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 1105 | # Define default initial receive window size in segments. |
paulhu | f8cdebf | 2021-03-17 13:59:02 +0800 | [diff] [blame] | 1106 | setprop net.tcp_def_init_rwnd 60 |
JP Abgrall | 7c862c8 | 2014-02-21 12:05:01 -0800 | [diff] [blame] | 1107 | |
Bowgo Tsai | 5998c74 | 2021-10-21 21:24:16 +0800 | [diff] [blame] | 1108 | # Update dm-verity state and set partition.*.verified properties. |
| 1109 | verity_update_state |
| 1110 | |
Steven Moreland | d627502 | 2017-03-24 16:23:07 +0000 | [diff] [blame] | 1111 | # Start standard binderized HAL daemons |
| 1112 | class_start hal |
| 1113 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 1114 | class_start core |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 1115 | |
| 1116 | on nonencrypted |
Paul Lawrence | 13d5bb4 | 2014-01-30 10:43:52 -0800 | [diff] [blame] | 1117 | class_start main |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 1118 | class_start late_start |
| 1119 | |
Riley Andrews | 1bbef88 | 2014-06-26 13:55:03 -0700 | [diff] [blame] | 1120 | on property:sys.init_log_level=* |
| 1121 | loglevel ${sys.init_log_level} |
| 1122 | |
Dima Zavin | ca47cef | 2011-08-24 15:28:23 -0700 | [diff] [blame] | 1123 | on charger |
| 1124 | class_start charger |
| 1125 | |
Ken Sumrall | c5c5103 | 2011-03-08 17:01:29 -0800 | [diff] [blame] | 1126 | on property:vold.decrypt=trigger_load_persist_props |
| 1127 | load_persist_props |
Mark Salyzyn | 5c39e0a | 2015-04-20 08:55:02 -0700 | [diff] [blame] | 1128 | start logd |
Mark Salyzyn | 48d0606 | 2015-03-11 14:45:05 -0700 | [diff] [blame] | 1129 | start logd-reinit |
Ken Sumrall | c5c5103 | 2011-03-08 17:01:29 -0800 | [diff] [blame] | 1130 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 1131 | on property:vold.decrypt=trigger_post_fs_data |
| 1132 | trigger post-fs-data |
Paul Lawrence | 7fdcbdf | 2018-04-13 12:28:42 -0700 | [diff] [blame] | 1133 | trigger zygote-start |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 1134 | |
Ken Sumrall | e434915 | 2011-01-17 14:26:34 -0800 | [diff] [blame] | 1135 | on property:vold.decrypt=trigger_restart_min_framework |
Tao Bao | 97df395 | 2015-12-04 17:45:43 -0800 | [diff] [blame] | 1136 | # A/B update verifier that marks a successful boot. |
Tom Cherry | aaeb792 | 2017-03-28 13:28:38 -0700 | [diff] [blame] | 1137 | exec_start update_verifier |
Ken Sumrall | e434915 | 2011-01-17 14:26:34 -0800 | [diff] [blame] | 1138 | class_start main |
| 1139 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 1140 | on property:vold.decrypt=trigger_restart_framework |
Tao Bao | 97df395 | 2015-12-04 17:45:43 -0800 | [diff] [blame] | 1141 | # A/B update verifier that marks a successful boot. |
Tom Cherry | aaeb792 | 2017-03-28 13:28:38 -0700 | [diff] [blame] | 1142 | exec_start update_verifier |
Martijn Coenen | f0bc58a | 2019-04-23 16:26:01 +0200 | [diff] [blame] | 1143 | class_start_post_data hal |
| 1144 | class_start_post_data core |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 1145 | class_start main |
| 1146 | class_start late_start |
Isaac Lee | f32c201 | 2018-07-26 17:07:25 +0800 | [diff] [blame] | 1147 | setprop service.bootanim.exit 0 |
Nicolas Geoffray | e106f0a | 2020-12-15 18:34:47 +0000 | [diff] [blame] | 1148 | setprop service.bootanim.progress 0 |
Isaac Lee | f32c201 | 2018-07-26 17:07:25 +0800 | [diff] [blame] | 1149 | start bootanim |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 1150 | |
| 1151 | on property:vold.decrypt=trigger_shutdown_framework |
| 1152 | class_reset late_start |
| 1153 | class_reset main |
Martijn Coenen | f0bc58a | 2019-04-23 16:26:01 +0200 | [diff] [blame] | 1154 | class_reset_post_data core |
| 1155 | class_reset_post_data hal |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1156 | |
Elliott Hughes | a3641af | 2016-11-10 17:43:47 -0800 | [diff] [blame] | 1157 | on property:sys.boot_completed=1 |
| 1158 | bootchart stop |
Paul Crowley | 570d20d | 2019-09-11 15:02:44 -0700 | [diff] [blame] | 1159 | # Setup per_boot directory so other .rc could start to use it on boot_completed |
| 1160 | exec - system system -- /bin/rm -rf /data/per_boot |
Paul Crowley | 68258e8 | 2019-10-28 07:55:03 -0700 | [diff] [blame] | 1161 | mkdir /data/per_boot 0700 system system encryption=Require key=per_boot_ref |
Elliott Hughes | a3641af | 2016-11-10 17:43:47 -0800 | [diff] [blame] | 1162 | |
JP Abgrall | 7c862c8 | 2014-02-21 12:05:01 -0800 | [diff] [blame] | 1163 | # system server cannot write to /proc/sys files, |
| 1164 | # and chown/chmod does not work for /proc/sys/ entries. |
| 1165 | # So proxy writes through init. |
Colin Cross | 57fdb5c | 2013-07-25 10:34:30 -0700 | [diff] [blame] | 1166 | on property:sys.sysctl.extra_free_kbytes=* |
Suren Baghdasaryan | 92cb2e8 | 2021-07-21 15:16:20 -0700 | [diff] [blame] | 1167 | exec -- /system/bin/extra_free_kbytes.sh ${sys.sysctl.extra_free_kbytes} |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 1168 | |
Michael Rosenfeld | e853d37 | 2021-02-10 18:38:05 -0800 | [diff] [blame] | 1169 | # Allow users to drop caches |
| 1170 | on property:perf.drop_caches=3 |
| 1171 | write /proc/sys/vm/drop_caches 3 |
| 1172 | setprop perf.drop_caches 0 |
| 1173 | |
JP Abgrall | 7c862c8 | 2014-02-21 12:05:01 -0800 | [diff] [blame] | 1174 | # "tcp_default_init_rwnd" Is too long! |
Chiachang Wang | 7396fed | 2020-10-15 21:09:25 +0800 | [diff] [blame] | 1175 | on property:net.tcp_def_init_rwnd=* |
| 1176 | write /proc/sys/net/ipv4/tcp_default_init_rwnd ${net.tcp_def_init_rwnd} |
JP Abgrall | 7c862c8 | 2014-02-21 12:05:01 -0800 | [diff] [blame] | 1177 | |
Ryan Savitski | f0f7e70 | 2020-01-14 22:02:53 +0000 | [diff] [blame] | 1178 | # perf_event_open syscall security: |
| 1179 | # Newer kernels have the ability to control the use of the syscall via SELinux |
| 1180 | # hooks. init tests for this, and sets sys_init.perf_lsm_hooks to 1 if the |
| 1181 | # kernel has the hooks. In this case, the system-wide perf_event_paranoid |
| 1182 | # sysctl is set to -1 (unrestricted use), and the SELinux policy is used for |
| 1183 | # controlling access. On older kernels, the paranoid value is the only means of |
| 1184 | # controlling access. It is normally 3 (allow only root), but the shell user |
| 1185 | # can lower it to 1 (allowing thread-scoped pofiling) via security.perf_harden. |
| 1186 | on property:sys.init.perf_lsm_hooks=1 |
| 1187 | write /proc/sys/kernel/perf_event_paranoid -1 |
| 1188 | on property:security.perf_harden=0 && property:sys.init.perf_lsm_hooks="" |
Daniel Micay | 2b22a66 | 2015-09-04 16:23:01 -0400 | [diff] [blame] | 1189 | write /proc/sys/kernel/perf_event_paranoid 1 |
Ryan Savitski | f0f7e70 | 2020-01-14 22:02:53 +0000 | [diff] [blame] | 1190 | on property:security.perf_harden=1 && property:sys.init.perf_lsm_hooks="" |
| 1191 | write /proc/sys/kernel/perf_event_paranoid 3 |
| 1192 | |
| 1193 | # Additionally, simpleperf profiler uses debug.* and security.perf_harden |
| 1194 | # sysprops to be able to indirectly set these sysctls. |
| 1195 | on property:security.perf_harden=0 |
Yabin Cui | 4f0da7c | 2018-06-29 14:52:47 -0700 | [diff] [blame] | 1196 | write /proc/sys/kernel/perf_event_max_sample_rate ${debug.perf_event_max_sample_rate:-100000} |
| 1197 | write /proc/sys/kernel/perf_cpu_time_max_percent ${debug.perf_cpu_time_max_percent:-25} |
| 1198 | write /proc/sys/kernel/perf_event_mlock_kb ${debug.perf_event_mlock_kb:-516} |
Ryan Savitski | f0f7e70 | 2020-01-14 22:02:53 +0000 | [diff] [blame] | 1199 | # Default values. |
Daniel Micay | 2b22a66 | 2015-09-04 16:23:01 -0400 | [diff] [blame] | 1200 | on property:security.perf_harden=1 |
Ryan Savitski | f0f7e70 | 2020-01-14 22:02:53 +0000 | [diff] [blame] | 1201 | write /proc/sys/kernel/perf_event_max_sample_rate 100000 |
| 1202 | write /proc/sys/kernel/perf_cpu_time_max_percent 25 |
| 1203 | write /proc/sys/kernel/perf_event_mlock_kb 516 |
| 1204 | |
Primiano Tucci | 253289f | 2020-10-09 13:59:41 +0100 | [diff] [blame] | 1205 | # This property can be set only on userdebug/eng. See neverallow rule in |
| 1206 | # /system/sepolicy/private/property.te . |
| 1207 | on property:security.lower_kptr_restrict=1 |
| 1208 | write /proc/sys/kernel/kptr_restrict 0 |
| 1209 | |
| 1210 | on property:security.lower_kptr_restrict=0 |
| 1211 | write /proc/sys/kernel/kptr_restrict 2 |
| 1212 | |
Colin Cross | 57fdb5c | 2013-07-25 10:34:30 -0700 | [diff] [blame] | 1213 | |
Wei Wang | eeab491 | 2017-06-27 22:08:45 -0700 | [diff] [blame] | 1214 | # on shutdown |
| 1215 | # In device's init.rc, this trigger can be used to do device-specific actions |
| 1216 | # before shutdown. e.g disable watchdog and mask error handling |
| 1217 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1218 | ## Daemon processes to be run by init. |
| 1219 | ## |
Tom Cherry | 3143848 | 2018-07-20 14:57:00 -0700 | [diff] [blame] | 1220 | service ueventd /system/bin/ueventd |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 1221 | class core |
Colin Cross | f83d0b9 | 2010-04-21 12:04:20 -0700 | [diff] [blame] | 1222 | critical |
Stephen Smalley | 1eee419 | 2012-01-13 08:54:34 -0500 | [diff] [blame] | 1223 | seclabel u:r:ueventd:s0 |
Keun-young Park | cccb34f | 2017-07-05 11:38:44 -0700 | [diff] [blame] | 1224 | shutdown critical |
Colin Cross | f83d0b9 | 2010-04-21 12:04:20 -0700 | [diff] [blame] | 1225 | |
Brian Swetland | b4d6539 | 2010-10-27 15:40:23 -0700 | [diff] [blame] | 1226 | service console /system/bin/sh |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 1227 | class core |
Brian Swetland | b4d6539 | 2010-10-27 15:40:23 -0700 | [diff] [blame] | 1228 | console |
| 1229 | disabled |
| 1230 | user shell |
Nick Kralevich | c39ba5a | 2015-11-07 16:52:17 -0800 | [diff] [blame] | 1231 | group shell log readproc |
Stephen Smalley | 610653f | 2013-12-23 14:11:02 -0500 | [diff] [blame] | 1232 | seclabel u:r:shell:s0 |
Dmitry Shmidt | d0fb251 | 2017-10-11 11:18:51 -0700 | [diff] [blame] | 1233 | setenv HOSTNAME console |
Brian Swetland | b4d6539 | 2010-10-27 15:40:23 -0700 | [diff] [blame] | 1234 | |
Mike Lockwood | d49b4ef | 2010-11-19 09:12:27 -0500 | [diff] [blame] | 1235 | on property:ro.debuggable=1 |
Calin Juravle | 9b3e5d5 | 2015-11-10 19:16:43 +0000 | [diff] [blame] | 1236 | # Give writes to anyone for the trace folder on debug builds. |
| 1237 | # The folder is used to store method traces. |
| 1238 | chmod 0773 /data/misc/trace |
Vishnu Nair | d09ab7a | 2017-11-27 09:54:31 -0800 | [diff] [blame] | 1239 | # Give reads to anyone for the window trace folder on debug builds. |
| 1240 | chmod 0775 /data/misc/wmtrace |
Hongming Jin | 87f55fe | 2021-02-09 11:54:46 -0800 | [diff] [blame] | 1241 | # Give reads to anyone for the accessibility trace folder on debug builds. |
| 1242 | chmod 0775 /data/misc/a11ytrace |
Tom Cherry | 71c3ef1 | 2019-08-27 14:57:32 -0700 | [diff] [blame] | 1243 | |
| 1244 | on init && property:ro.debuggable=1 |
Brian Swetland | b4d6539 | 2010-10-27 15:40:23 -0700 | [diff] [blame] | 1245 | start console |
Nikita Ioffe | ba6968e | 2019-10-07 16:26:33 +0100 | [diff] [blame] | 1246 | |
Nikita Ioffe | ac69214 | 2019-11-01 20:56:33 +0000 | [diff] [blame] | 1247 | on userspace-reboot-requested |
Nikita Ioffe | ba6968e | 2019-10-07 16:26:33 +0100 | [diff] [blame] | 1248 | # TODO(b/135984674): reset all necessary properties here. |
Nikita Ioffe | 018ddd7 | 2019-12-20 16:34:48 +0000 | [diff] [blame] | 1249 | setprop sys.boot_completed "" |
Nikita Ioffe | c2bc1a3 | 2020-02-07 17:42:27 +0000 | [diff] [blame] | 1250 | setprop dev.bootcomplete "" |
Nikita Ioffe | 018ddd7 | 2019-12-20 16:34:48 +0000 | [diff] [blame] | 1251 | setprop sys.init.updatable_crashing "" |
| 1252 | setprop sys.init.updatable_crashing_process_name "" |
Nikita Ioffe | 018ddd7 | 2019-12-20 16:34:48 +0000 | [diff] [blame] | 1253 | setprop sys.user.0.ce_available "" |
Nikita Ioffe | 1131a21 | 2019-12-30 16:05:11 +0000 | [diff] [blame] | 1254 | setprop sys.shutdown.requested "" |
Nikita Ioffe | 764c1ac | 2020-01-27 17:14:46 +0000 | [diff] [blame] | 1255 | setprop service.bootanim.exit "" |
Nicolas Geoffray | e106f0a | 2020-12-15 18:34:47 +0000 | [diff] [blame] | 1256 | setprop service.bootanim.progress "" |
Nikita Ioffe | ba6968e | 2019-10-07 16:26:33 +0100 | [diff] [blame] | 1257 | |
Nikita Ioffe | 12a3607 | 2019-10-23 20:11:32 +0100 | [diff] [blame] | 1258 | on userspace-reboot-fs-remount |
| 1259 | # Make sure that vold is running. |
| 1260 | # This is mostly a precaution measure in case vold for some reason wasn't running when |
| 1261 | # userspace reboot was initiated. |
| 1262 | start vold |
| 1263 | exec - system system -- /system/bin/vdc checkpoint resetCheckpoint |
| 1264 | exec - system system -- /system/bin/vdc checkpoint markBootAttempt |
Nikita Ioffe | bf66f43 | 2020-04-07 00:26:15 +0100 | [diff] [blame] | 1265 | # Unmount /data_mirror mounts in the reverse order of corresponding mounts. |
| 1266 | umount /data_mirror/data_ce/null/0 |
| 1267 | umount /data_mirror/data_ce/null |
| 1268 | umount /data_mirror/data_de/null |
| 1269 | umount /data_mirror/cur_profiles |
Ricky Wai | 420830f | 2021-06-08 12:15:14 +0100 | [diff] [blame] | 1270 | umount /data_mirror/ref_profiles |
Nikita Ioffe | bf66f43 | 2020-04-07 00:26:15 +0100 | [diff] [blame] | 1271 | umount /data_mirror |
Nikita Ioffe | 12a3607 | 2019-10-23 20:11:32 +0100 | [diff] [blame] | 1272 | remount_userdata |
Nikita Ioffe | 764c1ac | 2020-01-27 17:14:46 +0000 | [diff] [blame] | 1273 | start bootanim |
Nikita Ioffe | 12a3607 | 2019-10-23 20:11:32 +0100 | [diff] [blame] | 1274 | |
Nikita Ioffe | 3f4b0d6 | 2019-10-09 15:23:02 +0100 | [diff] [blame] | 1275 | on userspace-reboot-resume |
Nikita Ioffe | 12a3607 | 2019-10-23 20:11:32 +0100 | [diff] [blame] | 1276 | trigger userspace-reboot-fs-remount |
Nikita Ioffe | ba6968e | 2019-10-07 16:26:33 +0100 | [diff] [blame] | 1277 | trigger post-fs-data |
| 1278 | trigger zygote-start |
| 1279 | trigger early-boot |
| 1280 | trigger boot |
Nikita Ioffe | c0df187 | 2019-11-13 21:47:06 +0000 | [diff] [blame] | 1281 | |
| 1282 | on property:sys.boot_completed=1 && property:sys.init.userspace_reboot.in_progress=1 |
Nikita Ioffe | 85ff4ab | 2020-02-06 23:33:42 +0000 | [diff] [blame] | 1283 | setprop sys.init.userspace_reboot.in_progress "" |