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
7import /init.environ.rc
8import /init.usb.rc
9import /init.${ro.hardware}.rc
10import /vendor/etc/init/hw/init.${ro.hardware}.rc
11import /init.usb.configfs.rc
12import /init.${ro.zygote}.rc
13
14on early-init
15    # Set init and its forked children's oom_adj.
16    write /proc/1/oom_score_adj -1000
17
18    # Disable sysrq from keyboard
19    write /proc/sys/kernel/sysrq 0
20
21    # Set the security context of /adb_keys if present.
22    restorecon /adb_keys
23
24    # Shouldn't be necessary, but sdcard won't start without it. http://b/22568628.
25    mkdir /mnt 0775 root system
26
27    # Set the security context of /postinstall if present.
28    restorecon /postinstall
29
30    # Mount cgroup mount point for cpu accounting
31    mount cgroup none /acct cpuacct
32    mkdir /acct/uid
33
34    # root memory control cgroup, used by lmkd
35    mkdir /dev/memcg 0700 root system
36    mount cgroup none /dev/memcg memory
37    # app mem cgroups, used by activity manager, lmkd and zygote
38    mkdir /dev/memcg/apps/ 0755 system system
39    # cgroup for system_server and surfaceflinger
40    mkdir /dev/memcg/system 0550 system system
41
42    start ueventd
43
44on init
45    sysclktz 0
46
47    # Mix device-specific information into the entropy pool
48    copy /proc/cmdline /dev/urandom
49    copy /default.prop /dev/urandom
50
51    # Backward compatibility.
52    symlink /system/etc /etc
53    symlink /sys/kernel/debug /d
54
55    # Link /vendor to /system/vendor for devices without a vendor partition.
56    symlink /system/vendor /vendor
57
58    # Create energy-aware scheduler tuning nodes
59    mkdir /dev/stune
60    mount cgroup none /dev/stune schedtune
61    mkdir /dev/stune/foreground
62    mkdir /dev/stune/background
63    mkdir /dev/stune/top-app
64    mkdir /dev/stune/rt
65    chown system system /dev/stune
66    chown system system /dev/stune/foreground
67    chown system system /dev/stune/background
68    chown system system /dev/stune/top-app
69    chown system system /dev/stune/rt
70    chown system system /dev/stune/tasks
71    chown system system /dev/stune/foreground/tasks
72    chown system system /dev/stune/background/tasks
73    chown system system /dev/stune/top-app/tasks
74    chown system system /dev/stune/rt/tasks
75    chmod 0664 /dev/stune/tasks
76    chmod 0664 /dev/stune/foreground/tasks
77    chmod 0664 /dev/stune/background/tasks
78    chmod 0664 /dev/stune/top-app/tasks
79    chmod 0664 /dev/stune/rt/tasks
80
81    # Mount staging areas for devices managed by vold
82    # See storage config details at http://source.android.com/tech/storage/
83    mount tmpfs tmpfs /mnt mode=0755,uid=0,gid=1000
84    restorecon_recursive /mnt
85
86    mount configfs none /config
87    chmod 0775 /config/sdcardfs
88    chown system package_info /config/sdcardfs
89
90    mkdir /mnt/secure 0700 root root
91    mkdir /mnt/secure/asec 0700 root root
92    mkdir /mnt/asec 0755 root system
93    mkdir /mnt/obb 0755 root system
94    mkdir /mnt/media_rw 0750 root media_rw
95    mkdir /mnt/user 0755 root root
96    mkdir /mnt/user/0 0755 root root
97    mkdir /mnt/expand 0771 system system
98    mkdir /mnt/appfuse 0711 root root
99
100    # Storage views to support runtime permissions
101    mkdir /mnt/runtime 0700 root root
102    mkdir /mnt/runtime/default 0755 root root
103    mkdir /mnt/runtime/default/self 0755 root root
104    mkdir /mnt/runtime/read 0755 root root
105    mkdir /mnt/runtime/read/self 0755 root root
106    mkdir /mnt/runtime/write 0755 root root
107    mkdir /mnt/runtime/write/self 0755 root root
108
109    # Symlink to keep legacy apps working in multi-user world
110    symlink /storage/self/primary /sdcard
111    symlink /storage/self/primary /mnt/sdcard
112    symlink /mnt/user/0/primary /mnt/runtime/default/self/primary
113
114    write /proc/sys/kernel/panic_on_oops 1
115    write /proc/sys/kernel/hung_task_timeout_secs 0
116    write /proc/cpu/alignment 4
117
118    # scheduler tunables
119    # Disable auto-scaling of scheduler tunables with hotplug. The tunables
120    # will vary across devices in unpredictable ways if allowed to scale with
121    # cpu cores.
122    write /proc/sys/kernel/sched_tunable_scaling 0
123    write /proc/sys/kernel/sched_latency_ns 10000000
124    write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
125    write /proc/sys/kernel/sched_child_runs_first 0
126
127    write /proc/sys/kernel/randomize_va_space 2
128    write /proc/sys/vm/mmap_min_addr 32768
129    write /proc/sys/net/ipv4/ping_group_range "0 2147483647"
130    write /proc/sys/net/unix/max_dgram_qlen 600
131    write /proc/sys/kernel/sched_rt_runtime_us 950000
132    write /proc/sys/kernel/sched_rt_period_us 1000000
133
134    # Assign reasonable ceiling values for socket rcv/snd buffers.
135    # These should almost always be overridden by the target per the
136    # the corresponding technology maximums.
137    write /proc/sys/net/core/rmem_max  262144
138    write /proc/sys/net/core/wmem_max  262144
139
140    # reflect fwmark from incoming packets onto generated replies
141    write /proc/sys/net/ipv4/fwmark_reflect 1
142    write /proc/sys/net/ipv6/fwmark_reflect 1
143
144    # set fwmark on accepted sockets
145    write /proc/sys/net/ipv4/tcp_fwmark_accept 1
146
147    # disable icmp redirects
148    write /proc/sys/net/ipv4/conf/all/accept_redirects 0
149    write /proc/sys/net/ipv6/conf/all/accept_redirects 0
150
151    # /proc/net/fib_trie leaks interface IP addresses
152    chmod 0400 /proc/net/fib_trie
153
154    # Create cgroup mount points for process groups
155    mkdir /dev/cpuctl
156    mount cgroup none /dev/cpuctl cpu
157    chown system system /dev/cpuctl
158    chown system system /dev/cpuctl/tasks
159    chmod 0666 /dev/cpuctl/tasks
160    write /dev/cpuctl/cpu.rt_period_us 1000000
161    write /dev/cpuctl/cpu.rt_runtime_us 950000
162
163    # sets up initial cpusets for ActivityManager
164    mkdir /dev/cpuset
165    mount cpuset none /dev/cpuset
166
167    # this ensures that the cpusets are present and usable, but the device's
168    # init.rc must actually set the correct cpus
169    mkdir /dev/cpuset/foreground
170    copy /dev/cpuset/cpus /dev/cpuset/foreground/cpus
171    copy /dev/cpuset/mems /dev/cpuset/foreground/mems
172    mkdir /dev/cpuset/foreground/boost
173    copy /dev/cpuset/cpus /dev/cpuset/foreground/boost/cpus
174    copy /dev/cpuset/mems /dev/cpuset/foreground/boost/mems
175    mkdir /dev/cpuset/background
176    copy /dev/cpuset/cpus /dev/cpuset/background/cpus
177    copy /dev/cpuset/mems /dev/cpuset/background/mems
178
179    # system-background is for system tasks that should only run on
180    # little cores, not on bigs
181    # to be used only by init, so don't change system-bg permissions
182    mkdir /dev/cpuset/system-background
183    copy /dev/cpuset/cpus /dev/cpuset/system-background/cpus
184    copy /dev/cpuset/mems /dev/cpuset/system-background/mems
185
186    mkdir /dev/cpuset/top-app
187    copy /dev/cpuset/cpus /dev/cpuset/top-app/cpus
188    copy /dev/cpuset/mems /dev/cpuset/top-app/mems
189
190    # change permissions for all cpusets we'll touch at runtime
191    chown system system /dev/cpuset
192    chown system system /dev/cpuset/foreground
193    chown system system /dev/cpuset/foreground/boost
194    chown system system /dev/cpuset/background
195    chown system system /dev/cpuset/system-background
196    chown system system /dev/cpuset/top-app
197    chown system system /dev/cpuset/tasks
198    chown system system /dev/cpuset/foreground/tasks
199    chown system system /dev/cpuset/foreground/boost/tasks
200    chown system system /dev/cpuset/background/tasks
201    chown system system /dev/cpuset/system-background/tasks
202    chown system system /dev/cpuset/top-app/tasks
203
204    # set system-background to 0775 so SurfaceFlinger can touch it
205    chmod 0775 /dev/cpuset/system-background
206
207    chmod 0664 /dev/cpuset/foreground/tasks
208    chmod 0664 /dev/cpuset/foreground/boost/tasks
209    chmod 0664 /dev/cpuset/background/tasks
210    chmod 0664 /dev/cpuset/system-background/tasks
211    chmod 0664 /dev/cpuset/top-app/tasks
212    chmod 0664 /dev/cpuset/tasks
213
214
215    # qtaguid will limit access to specific data based on group memberships.
216    #   net_bw_acct grants impersonation of socket owners.
217    #   net_bw_stats grants access to other apps' detailed tagged-socket stats.
218    chown root net_bw_acct /proc/net/xt_qtaguid/ctrl
219    chown root net_bw_stats /proc/net/xt_qtaguid/stats
220
221    # Allow everybody to read the xt_qtaguid resource tracking misc dev.
222    # This is needed by any process that uses socket tagging.
223    chmod 0644 /dev/xt_qtaguid
224
225    # Create location for fs_mgr to store abbreviated output from filesystem
226    # checker programs.
227    mkdir /dev/fscklogs 0770 root system
228
229    # pstore/ramoops previous console log
230    mount pstore pstore /sys/fs/pstore
231    chown system log /sys/fs/pstore/console-ramoops
232    chmod 0440 /sys/fs/pstore/console-ramoops
233    chown system log /sys/fs/pstore/console-ramoops-0
234    chmod 0440 /sys/fs/pstore/console-ramoops-0
235    chown system log /sys/fs/pstore/pmsg-ramoops-0
236    chmod 0440 /sys/fs/pstore/pmsg-ramoops-0
237
238    # enable armv8_deprecated instruction hooks
239    write /proc/sys/abi/swp 1
240
241    # Linux's execveat() syscall may construct paths containing /dev/fd
242    # expecting it to point to /proc/self/fd
243    symlink /proc/self/fd /dev/fd
244
245    export DOWNLOAD_CACHE /data/cache
246
247    # set RLIMIT_NICE to allow priorities from 19 to -20
248    setrlimit 13 40 40
249
250    # This allows the ledtrig-transient properties to be created here so
251    # that they can be chown'd to system:system later on boot
252    write /sys/class/leds/vibrator/trigger "transient"
253
254# Healthd can trigger a full boot from charger mode by signaling this
255# property when the power button is held.
256on property:sys.boot_from_charger_mode=1
257    class_stop charger
258    trigger late-init
259
260on load_persist_props_action
261    load_persist_props
262    start logd
263    start logd-reinit
264
265# Indicate to fw loaders that the relevant mounts are up.
266on firmware_mounts_complete
267    rm /dev/.booting
268
269# Mount filesystems and start core system services.
270on late-init
271    trigger early-fs
272
273    # Mount fstab in init.{$device}.rc by mount_all command. Optional parameter
274    # '--early' can be specified to skip entries with 'latemount'.
275    # /system and /vendor must be mounted by the end of the fs stage,
276    # while /data is optional.
277    trigger fs
278    trigger post-fs
279
280    # Mount fstab in init.{$device}.rc by mount_all with '--late' parameter
281    # to only mount entries with 'latemount'. This is needed if '--early' is
282    # specified in the previous mount_all command on the fs stage.
283    # With /system mounted and properties form /system + /factory available,
284    # some services can be started.
285    trigger late-fs
286
287    # Now we can mount /data. File encryption requires keymaster to decrypt
288    # /data, which in turn can only be loaded when system properties are present.
289    trigger post-fs-data
290
291    # Now we can start zygote for devices with file based encryption
292    trigger zygote-start
293
294    # Load persist properties and override properties (if enabled) from /data.
295    trigger load_persist_props_action
296
297    # Remove a file to wake up anything waiting for firmware.
298    trigger firmware_mounts_complete
299
300    trigger early-boot
301    trigger boot
302
303on post-fs
304    # Load properties from
305    #     /system/build.prop,
306    #     /odm/build.prop,
307    #     /vendor/build.prop and
308    #     /factory/factory.prop
309    load_system_props
310    # start essential services
311    start logd
312    start servicemanager
313    start hwservicemanager
314    start vndservicemanager
315
316    # once everything is setup, no need to modify /
317    mount rootfs rootfs / ro remount
318    # Mount shared so changes propagate into child namespaces
319    mount rootfs rootfs / shared rec
320    # Mount default storage into root namespace
321    mount none /mnt/runtime/default /storage bind rec
322    mount none none /storage slave rec
323
324    # Make sure /sys/kernel/debug (if present) is labeled properly
325    # Note that tracefs may be mounted under debug, so we need to cross filesystems
326    restorecon --recursive --cross-filesystems /sys/kernel/debug
327
328    # We chown/chmod /cache again so because mount is run as root + defaults
329    chown system cache /cache
330    chmod 0770 /cache
331    # We restorecon /cache in case the cache partition has been reset.
332    restorecon_recursive /cache
333
334    # Create /cache/recovery in case it's not there. It'll also fix the odd
335    # permissions if created by the recovery system.
336    mkdir /cache/recovery 0770 system cache
337
338    # Backup/restore mechanism uses the cache partition
339    mkdir /cache/backup_stage 0700 system system
340    mkdir /cache/backup 0700 system system
341
342    #change permissions on vmallocinfo so we can grab it from bugreports
343    chown root log /proc/vmallocinfo
344    chmod 0440 /proc/vmallocinfo
345
346    chown root log /proc/slabinfo
347    chmod 0440 /proc/slabinfo
348
349    #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
350    chown root system /proc/kmsg
351    chmod 0440 /proc/kmsg
352    chown root system /proc/sysrq-trigger
353    chmod 0220 /proc/sysrq-trigger
354    chown system log /proc/last_kmsg
355    chmod 0440 /proc/last_kmsg
356
357    # make the selinux kernel policy world-readable
358    chmod 0444 /sys/fs/selinux/policy
359
360    # create the lost+found directories, so as to enforce our permissions
361    mkdir /cache/lost+found 0770 root root
362
363on late-fs
364    # Ensure that tracefs has the correct permissions.
365    # This does not work correctly if it is called in post-fs.
366    chmod 0755 /sys/kernel/debug/tracing
367
368    # HALs required before storage encryption can get unlocked (FBE/FDE)
369    class_start early_hal
370
371on post-fs-data
372    # We chown/chmod /data again so because mount is run as root + defaults
373    chown system system /data
374    chmod 0771 /data
375    # We restorecon /data in case the userdata partition has been reset.
376    restorecon /data
377
378    # Make sure we have the device encryption key.
379    start vold
380    installkey /data
381
382    # Start bootcharting as soon as possible after the data partition is
383    # mounted to collect more data.
384    mkdir /data/bootchart 0755 shell shell
385    bootchart start
386
387    # Avoid predictable entropy pool. Carry over entropy from previous boot.
388    copy /data/system/entropy.dat /dev/urandom
389
390    # create basic filesystem structure
391    mkdir /data/misc 01771 system misc
392    mkdir /data/misc/recovery 0770 system log
393    copy /data/misc/recovery/ro.build.fingerprint /data/misc/recovery/ro.build.fingerprint.1
394    chmod 0440 /data/misc/recovery/ro.build.fingerprint.1
395    chown system log /data/misc/recovery/ro.build.fingerprint.1
396    write /data/misc/recovery/ro.build.fingerprint ${ro.build.fingerprint}
397    chmod 0440 /data/misc/recovery/ro.build.fingerprint
398    chown system log /data/misc/recovery/ro.build.fingerprint
399    mkdir /data/misc/recovery/proc 0770 system log
400    copy /data/misc/recovery/proc/version /data/misc/recovery/proc/version.1
401    chmod 0440 /data/misc/recovery/proc/version.1
402    chown system log /data/misc/recovery/proc/version.1
403    copy /proc/version /data/misc/recovery/proc/version
404    chmod 0440 /data/misc/recovery/proc/version
405    chown system log /data/misc/recovery/proc/version
406    mkdir /data/misc/bluedroid 02770 bluetooth bluetooth
407    # Fix the access permissions and group ownership for 'bt_config.conf'
408    chmod 0660 /data/misc/bluedroid/bt_config.conf
409    chown bluetooth bluetooth /data/misc/bluedroid/bt_config.conf
410    mkdir /data/misc/bluetooth 0770 bluetooth bluetooth
411    mkdir /data/misc/bluetooth/logs 0770 bluetooth bluetooth
412    mkdir /data/misc/keystore 0700 keystore keystore
413    mkdir /data/misc/gatekeeper 0700 system system
414    mkdir /data/misc/keychain 0771 system system
415    mkdir /data/misc/net 0750 root shell
416    mkdir /data/misc/radio 0770 system radio
417    mkdir /data/misc/sms 0770 system radio
418    mkdir /data/misc/zoneinfo 0775 system system
419    mkdir /data/misc/textclassifier 0771 system system
420    mkdir /data/misc/vpn 0770 system vpn
421    mkdir /data/misc/shared_relro 0771 shared_relro shared_relro
422    mkdir /data/misc/systemkeys 0700 system system
423    mkdir /data/misc/wifi 0770 wifi wifi
424    mkdir /data/misc/wifi/sockets 0770 wifi wifi
425    mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi
426    mkdir /data/misc/ethernet 0770 system system
427    mkdir /data/misc/dhcp 0770 dhcp dhcp
428    mkdir /data/misc/user 0771 root root
429    mkdir /data/misc/perfprofd 0775 root root
430    # give system access to wpa_supplicant.conf for backup and restore
431    chmod 0660 /data/misc/wifi/wpa_supplicant.conf
432    mkdir /data/local 0751 root root
433    mkdir /data/misc/media 0700 media media
434    mkdir /data/misc/audioserver 0700 audioserver audioserver
435    mkdir /data/misc/cameraserver 0700 cameraserver cameraserver
436    mkdir /data/misc/vold 0700 root root
437    mkdir /data/misc/boottrace 0771 system shell
438    mkdir /data/misc/update_engine 0700 root root
439    mkdir /data/misc/trace 0700 root root
440    mkdir /data/misc/reboot 0700 system system
441    # profile file layout
442    mkdir /data/misc/profiles 0771 system system
443    mkdir /data/misc/profiles/cur 0771 system system
444    mkdir /data/misc/profiles/ref 0771 system system
445    mkdir /data/misc/profman 0770 system shell
446    mkdir /data/misc/gcov 0770 root root
447
448    mkdir /data/vendor 0771 root root
449    mkdir /data/vendor/hardware 0771 root root
450
451    # For security reasons, /data/local/tmp should always be empty.
452    # Do not place files or directories in /data/local/tmp
453    mkdir /data/local/tmp 0771 shell shell
454    mkdir /data/data 0771 system system
455    mkdir /data/app-private 0771 system system
456    mkdir /data/app-ephemeral 0771 system system
457    mkdir /data/app-asec 0700 root root
458    mkdir /data/app-lib 0771 system system
459    mkdir /data/app 0771 system system
460    mkdir /data/property 0700 root root
461    mkdir /data/tombstones 0771 system system
462
463    # create dalvik-cache, so as to enforce our permissions
464    mkdir /data/dalvik-cache 0771 root root
465    # create the A/B OTA directory, so as to enforce our permissions
466    mkdir /data/ota 0771 root root
467
468    # create the OTA package directory. It will be accessed by GmsCore (cache
469    # group), update_engine and update_verifier.
470    mkdir /data/ota_package 0770 system cache
471
472    # create resource-cache and double-check the perms
473    mkdir /data/resource-cache 0771 system system
474    chown system system /data/resource-cache
475    chmod 0771 /data/resource-cache
476
477    # create the lost+found directories, so as to enforce our permissions
478    mkdir /data/lost+found 0770 root root
479
480    # create directory for DRM plug-ins - give drm the read/write access to
481    # the following directory.
482    mkdir /data/drm 0770 drm drm
483
484    # create directory for MediaDrm plug-ins - give drm the read/write access to
485    # the following directory.
486    mkdir /data/mediadrm 0770 mediadrm mediadrm
487
488    mkdir /data/anr 0775 system system
489
490    # Create all remaining /data root dirs so that they are made through init
491    # and get proper encryption policy installed
492    mkdir /data/backup 0700 system system
493    mkdir /data/ss 0700 system system
494
495    mkdir /data/system 0775 system system
496    mkdir /data/system/heapdump 0700 system system
497    mkdir /data/system/users 0775 system system
498
499    mkdir /data/system_de 0770 system system
500    mkdir /data/system_ce 0770 system system
501
502    mkdir /data/misc_de 01771 system misc
503    mkdir /data/misc_ce 01771 system misc
504
505    mkdir /data/user 0711 system system
506    mkdir /data/user_de 0711 system system
507    symlink /data/data /data/user/0
508
509    mkdir /data/media 0770 media_rw media_rw
510    mkdir /data/media/obb 0770 media_rw media_rw
511
512    mkdir /data/cache 0770 system cache
513    mkdir /data/cache/recovery 0770 system cache
514    mkdir /data/cache/backup_stage 0700 system system
515    mkdir /data/cache/backup 0700 system system
516
517    init_user0
518
519    # Set SELinux security contexts on upgrade or policy update.
520    restorecon --recursive --skip-ce /data
521
522    # Check any timezone data in /data is newer than the copy in /system, delete if not.
523    exec - system system -- /system/bin/tzdatacheck /system/usr/share/zoneinfo /data/misc/zoneinfo
524
525    # If there is no post-fs-data action in the init.<device>.rc file, you
526    # must uncomment this line, otherwise encrypted filesystems
527    # won't work.
528    # Set indication (checked by vold) that we have finished this action
529    #setprop vold.post_fs_data_done 1
530
531# It is recommended to put unnecessary data/ initialization from post-fs-data
532# to start-zygote in device's init.rc to unblock zygote start.
533on zygote-start && property:ro.crypto.state=unencrypted
534    # A/B update verifier that marks a successful boot.
535    exec_start update_verifier_nonencrypted
536    start netd
537    start zygote
538    start zygote_secondary
539
540on zygote-start && property:ro.crypto.state=unsupported
541    # A/B update verifier that marks a successful boot.
542    exec_start update_verifier_nonencrypted
543    start netd
544    start zygote
545    start zygote_secondary
546
547on zygote-start && property:ro.crypto.state=encrypted && property:ro.crypto.type=file
548    # A/B update verifier that marks a successful boot.
549    exec_start update_verifier_nonencrypted
550    start netd
551    start zygote
552    start zygote_secondary
553
554on boot
555    # basic network init
556    ifup lo
557    hostname localhost
558    domainname localdomain
559
560    # Memory management.  Basic kernel parameters, and allow the high
561    # level system server to be able to adjust the kernel OOM driver
562    # parameters to match how it is managing things.
563    write /proc/sys/vm/overcommit_memory 1
564    write /proc/sys/vm/min_free_order_shift 4
565    chown root system /sys/module/lowmemorykiller/parameters/adj
566    chmod 0664 /sys/module/lowmemorykiller/parameters/adj
567    chown root system /sys/module/lowmemorykiller/parameters/minfree
568    chmod 0664 /sys/module/lowmemorykiller/parameters/minfree
569
570    # Tweak background writeout
571    write /proc/sys/vm/dirty_expire_centisecs 200
572    write /proc/sys/vm/dirty_background_ratio  5
573
574    # Permissions for System Server and daemons.
575    chown radio system /sys/android_power/state
576    chown radio system /sys/android_power/request_state
577    chown radio system /sys/android_power/acquire_full_wake_lock
578    chown radio system /sys/android_power/acquire_partial_wake_lock
579    chown radio system /sys/android_power/release_wake_lock
580    chown system system /sys/power/autosleep
581    chown system system /sys/power/state
582    chown system system /sys/power/wakeup_count
583    chown radio wakelock /sys/power/wake_lock
584    chown radio wakelock /sys/power/wake_unlock
585    chmod 0660 /sys/power/state
586    chmod 0660 /sys/power/wake_lock
587    chmod 0660 /sys/power/wake_unlock
588
589    chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_rate
590    chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_rate
591    chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_slack
592    chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_slack
593    chown system system /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
594    chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
595    chown system system /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
596    chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
597    chown system system /sys/devices/system/cpu/cpufreq/interactive/target_loads
598    chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/target_loads
599    chown system system /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
600    chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
601    chown system system /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
602    chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
603    chown system system /sys/devices/system/cpu/cpufreq/interactive/boost
604    chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boost
605    chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse
606    chown system system /sys/devices/system/cpu/cpufreq/interactive/input_boost
607    chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/input_boost
608    chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration
609    chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration
610    chown system system /sys/devices/system/cpu/cpufreq/interactive/io_is_busy
611    chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/io_is_busy
612
613    # Assume SMP uses shared cpufreq policy for all CPUs
614    chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
615    chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
616
617    chown system system /sys/class/leds/vibrator/trigger
618    chown system system /sys/class/leds/vibrator/activate
619    chown system system /sys/class/leds/vibrator/brightness
620    chown system system /sys/class/leds/vibrator/duration
621    chown system system /sys/class/leds/vibrator/state
622    chown system system /sys/class/timed_output/vibrator/enable
623    chown system system /sys/class/leds/keyboard-backlight/brightness
624    chown system system /sys/class/leds/lcd-backlight/brightness
625    chown system system /sys/class/leds/button-backlight/brightness
626    chown system system /sys/class/leds/jogball-backlight/brightness
627    chown system system /sys/class/leds/red/brightness
628    chown system system /sys/class/leds/green/brightness
629    chown system system /sys/class/leds/blue/brightness
630    chown system system /sys/class/leds/red/device/grpfreq
631    chown system system /sys/class/leds/red/device/grppwm
632    chown system system /sys/class/leds/red/device/blink
633    chown system system /sys/module/sco/parameters/disable_esco
634    chown system system /sys/kernel/ipv4/tcp_wmem_min
635    chown system system /sys/kernel/ipv4/tcp_wmem_def
636    chown system system /sys/kernel/ipv4/tcp_wmem_max
637    chown system system /sys/kernel/ipv4/tcp_rmem_min
638    chown system system /sys/kernel/ipv4/tcp_rmem_def
639    chown system system /sys/kernel/ipv4/tcp_rmem_max
640    chown root radio /proc/cmdline
641
642    # Define default initial receive window size in segments.
643    setprop net.tcp.default_init_rwnd 60
644
645    # Start standard binderized HAL daemons
646    class_start hal
647
648    class_start core
649
650on nonencrypted
651    class_start main
652    class_start late_start
653
654on property:sys.init_log_level=*
655    loglevel ${sys.init_log_level}
656
657on charger
658    class_start charger
659
660on property:vold.decrypt=trigger_reset_main
661    class_reset main
662
663on property:vold.decrypt=trigger_load_persist_props
664    load_persist_props
665    start logd
666    start logd-reinit
667
668on property:vold.decrypt=trigger_post_fs_data
669    trigger post-fs-data
670
671on property:vold.decrypt=trigger_restart_min_framework
672    # A/B update verifier that marks a successful boot.
673    exec_start update_verifier
674    class_start main
675
676on property:vold.decrypt=trigger_restart_framework
677    # A/B update verifier that marks a successful boot.
678    exec_start update_verifier
679    class_start main
680    class_start late_start
681
682on property:vold.decrypt=trigger_shutdown_framework
683    class_reset late_start
684    class_reset main
685
686on property:sys.boot_completed=1
687    bootchart stop
688
689# system server cannot write to /proc/sys files,
690# and chown/chmod does not work for /proc/sys/ entries.
691# So proxy writes through init.
692on property:sys.sysctl.extra_free_kbytes=*
693    write /proc/sys/vm/extra_free_kbytes ${sys.sysctl.extra_free_kbytes}
694
695# "tcp_default_init_rwnd" Is too long!
696on property:sys.sysctl.tcp_def_init_rwnd=*
697    write /proc/sys/net/ipv4/tcp_default_init_rwnd ${sys.sysctl.tcp_def_init_rwnd}
698
699on property:security.perf_harden=0
700    write /proc/sys/kernel/perf_event_paranoid 1
701
702on property:security.perf_harden=1
703    write /proc/sys/kernel/perf_event_paranoid 3
704
705# on shutdown
706# In device's init.rc, this trigger can be used to do device-specific actions
707# before shutdown. e.g disable watchdog and mask error handling
708
709## Daemon processes to be run by init.
710##
711service ueventd /sbin/ueventd
712    class core
713    critical
714    seclabel u:r:ueventd:s0
715    shutdown critical
716
717service healthd /system/bin/healthd
718    class core
719    critical
720    group root system wakelock
721
722service console /system/bin/sh
723    class core
724    console
725    disabled
726    user shell
727    group shell log readproc
728    seclabel u:r:shell:s0
729
730on property:ro.debuggable=1
731    # Give writes to anyone for the trace folder on debug builds.
732    # The folder is used to store method traces.
733    chmod 0773 /data/misc/trace
734    start console
735
736service flash_recovery /system/bin/install-recovery.sh
737    class main
738    oneshot
739