blob: c7e88747c45f0355a636a4dfa2b5a067f0e2d2f8 [file] [log] [blame]
Captain Throwback1f127752016-01-19 17:30:20 -05001import /init.recovery.logd.rc
Captain Throwback170964d2019-10-21 19:42:50 -04002import /init.recovery.ldconfig.rc
Captain Throwback5ab59642019-02-07 17:22:49 -05003import /init.recovery.mksh.rc
Matt Mowerec009e82015-01-30 13:00:49 -06004import /init.recovery.usb.rc
Ethan Yonkerf1179622016-08-25 15:32:21 -05005import /init.recovery.service.rc
nkk7171c6c502017-01-05 23:55:05 +02006import /init.recovery.vold_decrypt.rc
Matt Mower556411f2013-02-17 16:52:44 -06007import /init.recovery.${ro.hardware}.rc
8
Colin Crossdd6a0412010-05-14 13:42:20 -07009on early-init
Alex Deymo080f5222016-03-02 14:21:02 -080010 # Set the security context of /postinstall if present.
11 restorecon /postinstall
12
Andreas Schneidera4e510e2020-03-11 19:19:12 +010013 # ueventd wants to write to /acct
14 mount cgroup none /acct cpuacct
15 mkdir /acct/uid
Kiyoung Kimea2b6832019-12-17 15:05:54 +090016 # Copy prebuilt ld.config.txt into linkerconfig directory
17 copy /system/etc/ld.config.txt /linkerconfig/ld.config.txt
Kiyoung Kim3a88a172019-12-09 19:27:57 +090018 chmod 444 /linkerconfig/ld.config.txt
19
Colin Crossdd6a0412010-05-14 13:42:20 -070020 start ueventd
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080021
bigbiff91bd7a72021-01-03 17:33:01 -050022 setprop sys.usb.configfs 0
23
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080024on init
Doug Zongker55d65422014-01-14 09:50:35 -080025 export PATH /sbin:/system/bin
bigbiffa957f072021-03-07 18:20:29 -050026 export LD_LIBRARY_PATH /system/lib64:/vendor/lib64/hw
Ethan Yonker34ae4832016-08-24 15:32:18 -050027
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080028 export ANDROID_ROOT /system
29 export ANDROID_DATA /data
30 export EXTERNAL_STORAGE /sdcard
31
Elliott Hughesa4495b52018-08-23 08:31:59 -070032 symlink /proc/self/fd/0 /dev/stdin
33 symlink /proc/self/fd/1 /dev/stdout
34 symlink /proc/self/fd/2 /dev/stderr
35
Elliott Hughes4dca6f12017-12-06 08:41:50 -080036 symlink /system/bin /bin
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080037 symlink /system/etc /etc
38
Elliott Hughes48ebb072016-06-15 15:15:15 -070039 mount cgroup none /acct cpuacct
40 mkdir /acct/uid
41
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080042 mkdir /sdcard
43 mkdir /system
44 mkdir /data
bigbiffaed1bdf2021-08-03 18:21:39 -040045 symlink /data/cache /cache
Doug Zongker075ad802014-06-26 15:35:51 -070046 mkdir /sideload
Jiyong Park8b7af4c2018-06-01 11:58:54 +090047 mkdir /mnt/system
Doug Zongker55d65422014-01-14 09:50:35 -080048 mount tmpfs tmpfs /tmp
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080049
Matt Mower556411f2013-02-17 16:52:44 -060050 chown root shell /tmp
51 chmod 0775 /tmp
bigbiffdf53b6c2022-01-17 19:31:52 -050052 mkdir /tmp/misc
53 mkdir /tmp/misc/keystore/
Matt Mower556411f2013-02-17 16:52:44 -060054
Colin Cross22bcf972014-06-24 13:43:39 -070055 write /proc/sys/kernel/panic_on_oops 1
Jesse Zhao5bf74b22015-01-08 15:59:23 -080056 write /proc/sys/vm/max_map_count 1000000
Colin Cross22bcf972014-06-24 13:43:39 -070057
nebrassycd79c902021-01-19 09:55:04 +010058 mkdir /dev/binderfs
59 mount binder binder /dev/binderfs stats=global
60 chmod 0755 /dev/binderfs
61 chmod 0666 /dev/binderfs/hwbinder
62 chmod 0666 /dev/binderfs/binder
63 chmod 0666 /dev/binderfs/vndbinder
64 symlink /dev/binderfs/binder /dev/binder
65 symlink /dev/binderfs/hwbinder /dev/hwbinder
66 symlink /dev/binderfs/vndbinder /dev/vndbinder
67
Captain Throwback692a9e12021-10-14 13:20:06 -040068 # Create location for fs_mgr to store abbreviated output from filesystem
69 # checker programs.
70 mkdir /dev/fscklogs 0770 root system
71
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080072on boot
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080073 ifup lo
74 hostname localhost
75 domainname localdomain
76
77 class_start default
Yifan Hong0fa17072021-11-13 01:34:16 -080078 class_start hal
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080079
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070080on firmware_mounts_complete
Matt Mower4251a9b2015-11-13 14:01:49 -060081 rm /dev/.booting
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070082
Riley Andrewse739d7e2014-06-24 16:29:16 -070083# Mount filesystems and start core system services.
84on late-init
85 trigger early-fs
86 trigger fs
87 trigger post-fs
88 trigger post-fs-data
89
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070090 # Remove a file to wake up anything waiting for firmware
91 trigger firmware_mounts_complete
92
Riley Andrewse739d7e2014-06-24 16:29:16 -070093 trigger early-boot
94 trigger boot
95
Captain Throwback692a9e12021-10-14 13:20:06 -040096on post-fs-data
97 # Set fscklog permission
98 chown root system /dev/fscklogs/log
99 chmod 0770 /dev/fscklogs/log
100
bigbiffad58e1b2020-07-06 20:24:34 -0400101service ueventd /system/bin/ueventd
Colin Crossdd6a0412010-05-14 13:42:20 -0700102 critical
Stephen Smalley2c9d5b22014-01-13 09:44:42 -0500103 seclabel u:r:ueventd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800104
bigbiffad58e1b2020-07-06 20:24:34 -0400105service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
Kenny Rootecc76ba2010-06-28 09:01:22 -0700106 disabled
Doug Zongkercc2958f2013-09-11 13:24:32 -0700107 socket adbd stream 660 system system
Stephen Smalley2c9d5b22014-01-13 09:44:42 -0500108 seclabel u:r:adbd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800109
Mike Lockwood718a2f72011-06-29 10:22:04 -0400110# Always start adbd on userdebug and eng builds
111on property:ro.debuggable=1
Dees_Troy0cd4cc22013-06-09 20:56:38 +0000112 #write /sys/class/android_usb/android0/enable 1
113 #start adbd
Dees_Troy51a0e822012-09-05 15:24:24 -0400114 setprop service.adb.root 1
bigbiffd58ba182020-03-23 10:02:29 -0400115
bigbiff91bd7a72021-01-03 17:33:01 -0500116# Always start adbd on userdebug and eng builds
117on fs && property:ro.debuggable=1
118 setprop sys.usb.config adb
119
bigbiffad58e1b2020-07-06 20:24:34 -0400120service fastbootd /system/bin/fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700121 disabled
122 group system
123 seclabel u:r:fastbootd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800124
Mike Lockwood718a2f72011-06-29 10:22:04 -0400125# Restart adbd so it can run as root
Doug Zongkerfb04b872011-06-23 15:30:34 -0700126on property:service.adb.root=1
Doug Zongkerfb04b872011-06-23 15:30:34 -0700127 restart adbd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700128
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700129on fs && property:sys.usb.configfs=1
130 mount configfs none /config
131 mkdir /config/usb_gadget/g1 0770 shell shell
132 write /config/usb_gadget/g1/idVendor 0x18D1
133 mkdir /config/usb_gadget/g1/strings/0x409 0770
134 write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
135 write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer}
136 write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model}
137 mkdir /config/usb_gadget/g1/functions/ffs.adb
138 mkdir /config/usb_gadget/g1/functions/ffs.fastboot
139 mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell
140 mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell
141
142on fs && property:sys.usb.configfs=0
143 write /sys/class/android_usb/android0/f_ffs/aliases adb,fastboot
144 write /sys/class/android_usb/android0/idVendor 18D1
145 write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
146 write /sys/class/android_usb/android0/iProduct ${ro.product.model}
147 write /sys/class/android_usb/android0/iSerial ${ro.serialno}
148
149on fs
Captain Throwback82c66932020-10-13 15:03:11 -0400150 mount pstore pstore /sys/fs/pstore
151 mkdir /dev/usb-ffs 0770 shell shell
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700152 mkdir /dev/usb-ffs/adb 0770 shell shell
153 mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
154 mkdir /dev/usb-ffs/fastboot 0770 system system
155 mount functionfs fastboot /dev/usb-ffs/fastboot rmode=0770,fmode=0660,uid=1000,gid=1000
156
157on property:sys.usb.config=adb
158 start adbd
159
160on property:sys.usb.config=fastboot
161 start fastbootd
162
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700163on property:sys.usb.config=none && property:sys.usb.configfs=0
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700164 stop adbd
Dmytro Prokopchukdf354052019-11-13 13:30:17 +0200165 stop fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700166 write /sys/class/android_usb/android0/enable 0
167 setprop sys.usb.state ${sys.usb.config}
168
169on property:sys.usb.config=adb && property:sys.usb.configfs=0
170 write /sys/class/android_usb/android0/idProduct D001
171 write /sys/class/android_usb/android0/functions adb
Benoit Goby689e06b2014-02-19 17:41:02 -0800172 write /sys/class/android_usb/android0/enable 1
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700173 setprop sys.usb.state ${sys.usb.config}
174
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700175on property:sys.usb.config=sideload && property:sys.usb.configfs=0
176 write /sys/class/android_usb/android0/idProduct D001
177 write /sys/class/android_usb/android0/functions adb
178 write /sys/class/android_usb/android0/enable 1
179 setprop sys.usb.state ${sys.usb.config}
180
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700181on property:sys.usb.config=fastboot && property:sys.usb.configfs=0
182 write /sys/class/android_usb/android0/idProduct 4EE0
183 write /sys/class/android_usb/android0/functions fastboot
184 write /sys/class/android_usb/android0/enable 1
185 setprop sys.usb.state ${sys.usb.config}
186
187# Configfs triggers
188on property:sys.usb.config=none && property:sys.usb.configfs=1
189 write /config/usb_gadget/g1/UDC "none"
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700190 stop adbd
191 stop fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700192 setprop sys.usb.ffs.ready 0
193 rm /config/usb_gadget/g1/configs/b.1/f1
194 setprop sys.usb.state ${sys.usb.config}
195
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700196on property:sys.usb.config=sideload && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
197 write /config/usb_gadget/g1/idProduct 0xD001
198 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
199 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
200 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
201 setprop sys.usb.state ${sys.usb.config}
202
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700203on property:sys.usb.config=adb && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
204 write /config/usb_gadget/g1/idProduct 0xD001
205 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
206 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
207 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
208 setprop sys.usb.state ${sys.usb.config}
209
210on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
211 write /config/usb_gadget/g1/idProduct 0x4EE0
212 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "fastboot"
213 symlink /config/usb_gadget/g1/functions/ffs.fastboot /config/usb_gadget/g1/configs/b.1/f1
214 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
215 setprop sys.usb.state ${sys.usb.config}