-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfactory_init.rc
executable file
·470 lines (368 loc) · 13.6 KB
/
factory_init.rc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
import /init.environ.rc
import init.ssd.rc
import init.no_ssd.rc
import init.ssd_nomuser.rc
import init.fon.rc
on early-init
# Set init and its forked children's oom_adj.
write /proc/1/oom_score_adj -1000
# Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls.
write /sys/fs/selinux/checkreqprot 0
# Set the security context for the init process.
# This should occur before anything else (e.g. ueventd) is started.
setcon u:r:init:s0
# Set the security context of /adb_keys if present.
restorecon /adb_keys
start ueventd
write /proc/bootprof "INIT: usr/eng build setting"
# create mountpoints
mkdir /protect_f 0771 system system
mkdir /protect_s 0771 system system
mkdir /mnt 0775 root system
mkdir /storage 0055 system sdcard_r
mkdir /storage/sdcard0 0000 system system
mkdir /storage/sdcard1 0000 system system
# for backwards compatibility
symlink /storage/sdcard0 /sdcard
symlink /storage/sdcard0 /mnt/sdcard
symlink /storage/sdcard1 /mnt/sdcard2
on init
sysclktz 0
loglevel 5
# Backward compatibility
symlink /system/etc /etc
symlink /sys/kernel/debug /d
# Right now vendor lives on the same filesystem as system,
# but someday that may change.
symlink /system/vendor /vendor
# Create cgroup mount point for cpu accounting
mkdir /acct
mount cgroup none /acct cpuacct
mkdir /acct/uid
# Backwards Compat - XXX: Going away in G*
symlink /mnt/sdcard /sdcard
mkdir /system
mkdir /data 0771 system system
mkdir /cache 0770 system cache
mkdir /config 0500 root root
# Filesystem image public mount points.
mkdir /mnt/obb 0700 root system
mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
write /proc/sys/kernel/panic_on_oops 1
write /proc/sys/kernel/hung_task_timeout_secs 0
write /proc/cpu/alignment 4
write /proc/sys/kernel/sched_latency_ns 10000000
write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
write /proc/sys/kernel/sched_compat_yield 1
write /proc/sys/kernel/sched_child_runs_first 0
# Healthd can trigger a full boot from charger mode by signaling this
# property when the power button is held.
on property:sys.boot_from_charger_mode=1
class_stop charger
trigger late-init
# Load properties from /system/ + /factory after fs mount.
on load_all_props_action
load_all_props
# Mount filesystems and start core system services.
on late-init
trigger early-fs
trigger fs
trigger post-fs
trigger post-fs-data
# Load properties from /system/ + /factory after fs mount. Place
# this in another action so that the load will be scheduled after the prior
# issued fs triggers have completed.
trigger load_all_props_action
trigger early-boot
trigger boot
on fs
write /proc/bootprof "INIT:Mount_START"
mount_all /fstab.mt6795
# change partition permissions
exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/proinfo
exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/proinfo
exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/nvram
exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/nvram
exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/para
exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/para
exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/boot
exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/boot
exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/recovery
exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/recovery
exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/secro
exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/secro
exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/seccfg
exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/seccfg
write /proc/bootprof "INIT:Mount_END"
on post-fs
chown system system /protect_f
chmod 0770 /protect_f
chown system system /protect_s
chmod 0770 /protect_s
# once everything is setup, no need to modify /
mount rootfs rootfs / ro remount
chown system system /system/data
mkdir /system/cache 0770 system cache
# We chown/chmod /data again so because mount is run as root + defaults
chown system system /system/data
chmod 0777 /system/data
# We chown/chmod /data again so because mount is run as root + defaults
chown system system /data
chmod 0771 /data
# We restorecon /data in case the userdata partition has been reset.
restorecon /data
# Same reason as /data above
chown system cache /cache
chmod 0770 /cache
# We restorecon /cache in case the cache partition has been reset.
restorecon_recursive /cache
mkdir /cache/recovery 0770 system system
# This may have been created by the recovery system with odd permissions
chown system cache /cache/recovery
chmod 0770 /cache/recovery
#change permissions on vmallocinfo so we can grab it from bugreports
chown root log /proc/vmallocinfo
chmod 0440 /proc/vmallocinfo
#change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
chown root system /proc/kmsg
chmod 0440 /proc/kmsg
# make the selinux kernel policy world-readable
chmod 0444 /sys/fs/selinux/policy
#SeLinux
restorecon_recursive /protect_f
restorecon_recursive /protect_s
on post-fs-data
# We chown/chmod /data again so because mount is run as root + defaults
chown root system /proc/sysrq-trigger
chmod 0220 /proc/sysrq-trigger
# create basic filesystem structure
mkdir /data/nvram 2770 root system
mkdir /data/misc 01771 system misc
mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
mkdir /data/misc/bluetooth 0770 system system
mkdir /data/misc/keystore 0700 keystore keystore
mkdir /data/misc/keychain 0771 system system
mkdir /data/misc/vpn 0770 system vpn
mkdir /data/misc/systemkeys 0700 system system
# give system access to wpa_supplicant.conf for backup and restore
mkdir /data/misc/wifi 0770 wifi wifi
chmod 0660 /data/misc/wifi/wpa_supplicant.conf
mkdir /data/local 0771 shell shell
mkdir /data/local/tmp 0771 shell shell
mkdir /data/data 0771 system system
mkdir /data/app-private 0771 system system
mkdir /data/app 0771 system system
mkdir /data/property 0700 root root
# create the lost+found directories, so as to enforce our permissions
mkdir /data/lost+found 0770
mkdir /cache/lost+found 0770
# double check the perms, in case lost+found already exists, and set owner
chown root root /data/lost+found
chmod 0770 /data/lost+found
chown root root /cache/lost+found
chmod 0770 /cache/lost+found
# dhcp server
mkdir /data/misc/dhcp 0770 dhcp dhcp
chown dhcp dhcp /data/misc/dhcp
# device info interface
chmod 0444 /dev/devmap
chown root system /dev/devmap
#change partition permission
exec /system/etc/partition_permission.sh
## Custom pos-fs area (START)
# Please add custom fs operation below
# Touch Panel
chown root diag /sys/module/tpd_setting/parameters/tpd_calmat
chown root diag /sys/module/tpd_setting/parameters/tpd_em_debounce_time
chown root diag /sys/module/tpd_debug/parameters/tpd_em_log
chown root diag /sys/module/tpd_debug/parameters/tpd_em_log_to_fs
chmod 0777 /dev/pmem_multimedia
chmod 0777 /dev/mt6516-isp
chmod 0777 /dev/mt6516-IDP
chmod 0777 /dev/mt9p012
chmod 0777 /dev/mt6516_jpeg
chmod 0777 /dev/FM50AF
# md32 boot
chown root system /dev/md32
chmod 0440 /dev/md32
chown root system /sys/class/misc/md32/md32_mobile_log
chmod 0660 /sys/class/misc/md32/md32_mobile_log
write /sys/class/misc/md32/md32_boot 1
# RTC
mkdir /data/misc/rtc 0770 system system
# Modem related device nodes
mkdir /data/nvram/md 0770 root system
mkdir /data/nvram/md2 0770 root system
# Build-in Modified - S
# insmod /system/lib/modules/ccci_plat.ko
# insmod /system/lib/modules/ccci.ko
# Build-in Modified - E
# chown ccci ccci /sys/class/BOOT/BOOT/boot/md
chown radio radio /sys/kernel/ccci/boot
# M4U
#insmod /system/lib/modules/m4u.ko
#mknod /dev/M4U_device c 188 0
chmod 0444 /dev/M4U_device
# Sensor
chmod 0666 /dev/hwmsensor
chmod 0666 /dev/gyroscope
chmod 0666 /dev/msensor
chmod 0666 /dev/gsensor
chmod 0666 /dev/alsps
#VideoCodec
chmod 0666 /dev/Vcodec
mkdir /data/amit/
# GPIO
chmod 0666 /dev/mtgpio
chmod 0666 /dev/exm0
#NFC
rm /data/mtknfc_server
## Custom pos_fs area (END)
# Separate location for storing security policy files on data
mkdir /data/security 0711 system system
# Reload policy from /data/security if present.
setprop selinux.reload_policy 1
# Set SELinux security contexts on upgrade or policy update.
restorecon_recursive /data
# If there is no fs-post-data action in the init.<device>.rc file, you
# must uncomment this line, otherwise encrypted filesystems
# won't work.
# Set indication (checked by vold) that we have finished this action
setprop vold.post_fs_data_done 1
on boot
# basic network init
ifup lo
hostname localhost
domainname localdomain
# Start default class, this line is very important!!
class_start default
class_start core
on nonencrypted
class_start main
class_start late_start
on property:vold.decrypt=trigger_default_encryption
start defaultcrypto
on property:vold.decrypt=trigger_encryption
start surfaceflinger
start encrypt
on property:vold.decrypt=trigger_reset_main
class_reset main
on property:vold.decrypt=trigger_load_persist_props
load_persist_props
on property:vold.decrypt=trigger_post_fs_data
trigger post-fs-data
on property:vold.decrypt=trigger_restart_min_framework
class_start main
on property:vold.decrypt=trigger_restart_framework
start nvram_daemon
class_start main
class_start late_start
start permission_check
on property:vold.decrypt=trigger_shutdown_framework
class_reset late_start
class_reset main
## Daemon processes to be run by init.
##
# Update the second boot logo
# service bootlogoupdater /system/bin/boot_logo_updater
# oneshot
service ueventd /sbin/ueventd
class core
critical
seclabel u:r:ueventd:s0
service logd /system/bin/logd
class core
socket logd stream 0666 logd logd
socket logdr seqpacket 0666 logd logd
socket logdw dgram 0222 logd logd
seclabel u:r:logd:s0
service console /system/bin/sh
class core
console
disabled
user shell
group shell log
seclabel u:r:shell:s0
on property:sys.powerctl=*
powerctl ${sys.powerctl}
on property:ro.debuggable=1
start console
# adbd is controlled via property triggers in init.<platform>.usb.rc
service adbd /sbin/adbd --root_seclabel=u:r:su:s0
class core
socket adbd stream 660 system system
disabled
seclabel u:r:adbd:s0
service vold /system/bin/vold
class core
socket vold stream 0660 root mount
ioprio be 2
# One shot invocation to deal with encrypted volume.
service defaultcrypto /system/bin/vdc --wait cryptfs mountdefaultencrypted
disabled
oneshot
# vold will set vold.decrypt to trigger_restart_framework (default
# encryption) or trigger_restart_min_framework (other encryption)
# One shot invocation to encrypt unencrypted volumes
service encrypt /system/bin/vdc --wait cryptfs enablecrypto inplace default
disabled
oneshot
# vold will set vold.decrypt to trigger_restart_framework (default
# encryption)
## Custom service area (START)
# Please add custom service below
service thermal_manager /system/bin/thermal_manager
user root
oneshot
service permission_check /system/bin/permission_check
class main
user root
group system radio
oneshot
service ccci_fsd /system/bin/ccci_fsd 0
user radio
group radio system
oneshot
service ccci_mdinit /system/bin/ccci_mdinit 0
user system
group radio system
oneshot
service nvram_daemon /system/bin/nvram_daemon
class main
user root
group system
oneshot
service installd /system/bin/installd
class main
socket installd stream 600 system system
service factory_no_image /system/bin/factory
disabled
oneshot
service factory_with_image /sbin/factory
disabled
oneshot
## Custom service area (END)
on property:sys.mtk.no.factoryimage=1
start factory_no_image
on property:sys.mtk.no.factoryimage=0
start factory_with_image
#mass_storage,adb,acm
on property:ro.boot.usbconfig=0
write /sys/class/android_usb/android0/iSerial $ro.serialno
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 0e8d
write /sys/class/android_usb/android0/idProduct 2006
write /sys/class/android_usb/android0/f_acm/instances 1
write /sys/class/android_usb/android0/functions mass_storage,adb,acm
write /sys/class/android_usb/android0/enable 1
start adbd
#acm
on property:ro.boot.usbconfig=1
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/iSerial " "
write /sys/class/android_usb/android0/idVendor 0e8d
write /sys/class/android_usb/android0/idProduct 2007
write /sys/class/android_usb/android0/f_acm/instances 1
write /sys/class/android_usb/android0/functions acm
write /sys/class/android_usb/android0/bDeviceClass 02
write /sys/class/android_usb/android0/enable 1