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