init.rc revision 65c4df51f895b79fc599d3bfa796ddfc660d47e4
1on early-init
2    start ueventd
3
4# create mountpoints
5    mkdir /mnt 0775 root system
6
7on init
8
9sysclktz 0
10
11loglevel 3
12
13# setup the global environment
14    export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
15    export LD_LIBRARY_PATH /vendor/lib:/system/lib
16    export ANDROID_BOOTLOGO 1
17    export ANDROID_ROOT /system
18    export ANDROID_ASSETS /system/app
19    export ANDROID_DATA /data
20    export ASEC_MOUNTPOINT /mnt/asec
21    export LOOP_MOUNTPOINT /mnt/obb
22    export BOOTCLASSPATH /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/filterfw.jar
23
24# Backward compatibility
25    symlink /system/etc /etc
26    symlink /sys/kernel/debug /d
27
28# Right now vendor lives on the same filesystem as system,
29# but someday that may change.
30    symlink /system/vendor /vendor
31
32# Create cgroup mount point for cpu accounting
33    mkdir /acct
34    mount cgroup none /acct cpuacct
35    mkdir /acct/uid
36
37    mkdir /system
38    mkdir /data 0771 system system
39    mkdir /cache 0770 system cache
40    mkdir /config 0500 root root
41
42    # Directory for putting things only root should see.
43    mkdir /mnt/secure 0700 root root
44
45    # Directory for staging bindmounts
46    mkdir /mnt/secure/staging 0700 root root
47
48    # Directory-target for where the secure container
49    # imagefile directory will be bind-mounted
50    mkdir /mnt/secure/asec  0700 root root
51
52    # Secure container public mount points.
53    mkdir /mnt/asec  0700 root system
54    mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
55
56    # Filesystem image public mount points.
57    mkdir /mnt/obb 0700 root system
58    mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
59
60    write /proc/sys/kernel/panic_on_oops 1
61    write /proc/sys/kernel/hung_task_timeout_secs 0
62    write /proc/cpu/alignment 4
63    write /proc/sys/kernel/sched_latency_ns 10000000
64    write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
65    write /proc/sys/kernel/sched_compat_yield 1
66    write /proc/sys/kernel/sched_child_runs_first 0
67
68# Create cgroup mount points for process groups
69    mkdir /dev/cpuctl
70    mount cgroup none /dev/cpuctl cpu
71    chown system system /dev/cpuctl
72    chown system system /dev/cpuctl/tasks
73    chmod 0777 /dev/cpuctl/tasks
74    write /dev/cpuctl/cpu.shares 1024
75
76    mkdir /dev/cpuctl/fg_boost
77    chown system system /dev/cpuctl/fg_boost/tasks
78    chmod 0777 /dev/cpuctl/fg_boost/tasks
79    write /dev/cpuctl/fg_boost/cpu.shares 1024
80
81    mkdir /dev/cpuctl/bg_non_interactive
82    chown system system /dev/cpuctl/bg_non_interactive/tasks
83    chmod 0777 /dev/cpuctl/bg_non_interactive/tasks
84    # 5.0 %
85    write /dev/cpuctl/bg_non_interactive/cpu.shares 52
86
87# Allow everybody to read the xt_qtaguid resource tracking misc dev.
88# This is needed by any process that uses socket tagging.
89    chmod 0644 /dev/xt_qtaguid
90
91on fs
92# mount mtd partitions
93    # Mount /system rw first to give the filesystem a chance to save a checkpoint
94    mount yaffs2 mtd@system /system
95    mount yaffs2 mtd@system /system ro remount
96    mount yaffs2 mtd@userdata /data nosuid nodev
97    mount yaffs2 mtd@cache /cache nosuid nodev
98
99on post-fs
100    # once everything is setup, no need to modify /
101    mount rootfs rootfs / ro remount
102
103    # We chown/chmod /cache again so because mount is run as root + defaults
104    chown system cache /cache
105    chmod 0770 /cache
106
107    # This may have been created by the recovery system with odd permissions
108    chown system cache /cache/recovery
109    chmod 0770 /cache/recovery
110
111    #change permissions on vmallocinfo so we can grab it from bugreports
112    chown root log /proc/vmallocinfo
113    chmod 0440 /proc/vmallocinfo
114
115    #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
116    chown root system /proc/kmsg
117    chmod 0440 /proc/kmsg
118    chown root system /proc/sysrq-trigger
119    chmod 0220 /proc/sysrq-trigger
120
121    # create the lost+found directories, so as to enforce our permissions
122    mkdir /cache/lost+found 0770 root root
123
124on post-fs-data
125    # We chown/chmod /data again so because mount is run as root + defaults
126    chown system system /data
127    chmod 0771 /data
128
129    # Create dump dir and collect dumps.
130    # Do this before we mount cache so eventually we can use cache for
131    # storing dumps on platforms which do not have a dedicated dump partition.
132    mkdir /data/dontpanic 0750 root log
133
134    # Collect apanic data, free resources and re-arm trigger
135    copy /proc/apanic_console /data/dontpanic/apanic_console
136    chown root log /data/dontpanic/apanic_console
137    chmod 0640 /data/dontpanic/apanic_console
138
139    copy /proc/apanic_threads /data/dontpanic/apanic_threads
140    chown root log /data/dontpanic/apanic_threads
141    chmod 0640 /data/dontpanic/apanic_threads
142
143    write /proc/apanic_console 1
144
145    # create basic filesystem structure
146    mkdir /data/misc 01771 system misc
147    mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
148    mkdir /data/misc/bluetooth 0770 system system
149    mkdir /data/misc/keystore 0700 keystore keystore
150    mkdir /data/misc/keychain 0771 system system
151    mkdir /data/misc/vpn 0770 system vpn
152    mkdir /data/misc/systemkeys 0700 system system
153    # give system access to wpa_supplicant.conf for backup and restore
154    mkdir /data/misc/wifi 0770 wifi wifi
155    chmod 0660 /data/misc/wifi/wpa_supplicant.conf
156    mkdir /data/local 0771 shell shell
157    mkdir /data/local/tmp 0771 shell shell
158    mkdir /data/data 0771 system system
159    mkdir /data/app-private 0771 system system
160    mkdir /data/app 0771 system system
161    mkdir /data/property 0700 root root
162
163    # create dalvik-cache, so as to enforce our permissions
164    mkdir /data/dalvik-cache 0771 system system
165
166    # create resource-cache and double-check the perms
167    mkdir /data/resource-cache 0771 system system
168    chown system system /data/resource-cache
169    chmod 0771 /data/resource-cache
170
171    # create the lost+found directories, so as to enforce our permissions
172    mkdir /data/lost+found 0770 root root
173
174    # create directory for DRM plug-ins
175    mkdir /data/drm 0774 drm drm
176
177    # If there is no fs-post-data action in the init.<device>.rc file, you
178    # must uncomment this line, otherwise encrypted filesystems
179    # won't work.
180    # Set indication (checked by vold) that we have finished this action
181    #setprop vold.post_fs_data_done 1
182
183    chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file
184    chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file
185    chown system system /sys/class/android_usb/android0/f_rndis/ethaddr
186    chmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddr
187
188on boot
189# basic network init
190    ifup lo
191    hostname localhost
192    domainname localdomain
193
194# set RLIMIT_NICE to allow priorities from 19 to -20
195    setrlimit 13 40 40
196
197# Memory management.  Basic kernel parameters, and allow the high
198# level system server to be able to adjust the kernel OOM driver
199# paramters to match how it is managing things.
200    write /proc/sys/vm/overcommit_memory 1
201    write /proc/sys/vm/min_free_order_shift 4
202    chown root system /sys/module/lowmemorykiller/parameters/adj
203    chmod 0664 /sys/module/lowmemorykiller/parameters/adj
204    chown root system /sys/module/lowmemorykiller/parameters/minfree
205    chmod 0664 /sys/module/lowmemorykiller/parameters/minfree
206
207    # Set init and its forked children's oom_adj.
208    write /proc/1/oom_adj -16
209
210    # Tweak background writeout
211    write /proc/sys/vm/dirty_expire_centisecs 200
212    write /proc/sys/vm/dirty_background_ratio  5
213
214    # Permissions for System Server and daemons.
215    chown radio system /sys/android_power/state
216    chown radio system /sys/android_power/request_state
217    chown radio system /sys/android_power/acquire_full_wake_lock
218    chown radio system /sys/android_power/acquire_partial_wake_lock
219    chown radio system /sys/android_power/release_wake_lock
220    chown radio system /sys/power/state
221    chown radio system /sys/power/wake_lock
222    chown radio system /sys/power/wake_unlock
223    chmod 0660 /sys/power/state
224    chmod 0660 /sys/power/wake_lock
225    chmod 0660 /sys/power/wake_unlock
226    chown system system /sys/class/timed_output/vibrator/enable
227    chown system system /sys/class/leds/keyboard-backlight/brightness
228    chown system system /sys/class/leds/lcd-backlight/brightness
229    chown system system /sys/class/leds/button-backlight/brightness
230    chown system system /sys/class/leds/jogball-backlight/brightness
231    chown system system /sys/class/leds/red/brightness
232    chown system system /sys/class/leds/green/brightness
233    chown system system /sys/class/leds/blue/brightness
234    chown system system /sys/class/leds/red/device/grpfreq
235    chown system system /sys/class/leds/red/device/grppwm
236    chown system system /sys/class/leds/red/device/blink
237    chown system system /sys/class/leds/red/brightness
238    chown system system /sys/class/leds/green/brightness
239    chown system system /sys/class/leds/blue/brightness
240    chown system system /sys/class/leds/red/device/grpfreq
241    chown system system /sys/class/leds/red/device/grppwm
242    chown system system /sys/class/leds/red/device/blink
243    chown system system /sys/class/timed_output/vibrator/enable
244    chown system system /sys/module/sco/parameters/disable_esco
245    chown system system /sys/kernel/ipv4/tcp_wmem_min
246    chown system system /sys/kernel/ipv4/tcp_wmem_def
247    chown system system /sys/kernel/ipv4/tcp_wmem_max
248    chown system system /sys/kernel/ipv4/tcp_rmem_min
249    chown system system /sys/kernel/ipv4/tcp_rmem_def
250    chown system system /sys/kernel/ipv4/tcp_rmem_max
251    chown root radio /proc/cmdline
252
253# Define TCP buffer sizes for various networks
254#   ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
255    setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
256    setprop net.tcp.buffersize.wifi    524288,1048576,2097152,262144,524288,1048576
257    setprop net.tcp.buffersize.lte     524288,1048576,2097152,262144,524288,1048576
258    setprop net.tcp.buffersize.umts    4094,87380,110208,4096,16384,110208
259    setprop net.tcp.buffersize.edge    4093,26280,35040,4096,16384,35040
260    setprop net.tcp.buffersize.gprs    4092,8760,11680,4096,8760,11680
261
262# Set this property so surfaceflinger is not started by system_init
263    setprop system_init.startsurfaceflinger 0
264
265    class_start core
266    class_start main
267
268on nonencrypted
269    class_start late_start
270
271on charger
272    class_start charger
273
274on property:vold.decrypt=trigger_reset_main
275    class_reset main
276
277on property:vold.decrypt=trigger_load_persist_props
278    load_persist_props
279
280on property:vold.decrypt=trigger_post_fs_data
281    trigger post-fs-data
282
283on property:vold.decrypt=trigger_restart_min_framework
284    class_start main
285
286on property:vold.decrypt=trigger_restart_framework
287    class_start main
288    class_start late_start
289
290on property:vold.decrypt=trigger_shutdown_framework
291    class_reset late_start
292    class_reset main
293
294# Used to disable USB when switching states
295on property:sys.usb.config=none
296    stop adbd
297    write /sys/class/android_usb/android0/enable 0
298    write /sys/class/android_usb/android0/bDeviceClass 0
299    setprop sys.usb.state $sys.usb.config
300
301# adb only USB configuration
302# This should only be used during device bringup
303# and as a fallback if the USB manager fails to set a standard configuration
304on property:sys.usb.config=adb
305    write /sys/class/android_usb/android0/enable 0
306    write /sys/class/android_usb/android0/idVendor 18d1
307    write /sys/class/android_usb/android0/idProduct D002
308    write /sys/class/android_usb/android0/functions $sys.usb.config
309    write /sys/class/android_usb/android0/enable 1
310    start adbd
311    setprop sys.usb.state $sys.usb.config
312
313# USB accessory configuration
314on property:sys.usb.config=accessory
315    write /sys/class/android_usb/android0/enable 0
316    write /sys/class/android_usb/android0/idVendor 18d1
317    write /sys/class/android_usb/android0/idProduct 2d00
318    write /sys/class/android_usb/android0/functions $sys.usb.config
319    write /sys/class/android_usb/android0/enable 1
320    setprop sys.usb.state $sys.usb.config
321
322# USB accessory configuration, with adb
323on property:sys.usb.config=accessory,adb
324    write /sys/class/android_usb/android0/enable 0
325    write /sys/class/android_usb/android0/idVendor 18d1
326    write /sys/class/android_usb/android0/idProduct 2d01
327    write /sys/class/android_usb/android0/functions $sys.usb.config
328    write /sys/class/android_usb/android0/enable 1
329    start adbd
330    setprop sys.usb.state $sys.usb.config
331
332# Used to set USB configuration at boot and to switch the configuration
333# when changing the default configuration
334on property:persist.sys.usb.config=*
335    setprop sys.usb.config $persist.sys.usb.config
336
337## Daemon processes to be run by init.
338##
339service ueventd /sbin/ueventd
340    class core
341    critical
342
343service console /system/bin/sh
344    class core
345    console
346    disabled
347    user shell
348    group log
349
350on property:ro.debuggable=1
351    start console
352
353# adbd is controlled via property triggers in init.<platform>.usb.rc
354service adbd /sbin/adbd
355    class core
356    disabled
357
358# adbd on at boot in emulator
359on property:ro.kernel.qemu=1
360    start adbd
361
362# This property trigger has added to imitiate the previous behavior of "adb root".
363# The adb gadget driver used to reset the USB bus when the adbd daemon exited,
364# and the host side adb relied on this behavior to force it to reconnect with the
365# new adbd instance after init relaunches it. So now we force the USB bus to reset
366# here when adbd sets the service.adb.root property to 1.  We also restart adbd here
367# rather than waiting for init to notice its death and restarting it so the timing
368# of USB resetting and adb restarting more closely matches the previous behavior.
369on property:service.adb.root=1
370    write /sys/class/android_usb/android0/enable 0
371    restart adbd
372    write /sys/class/android_usb/android0/enable 1
373
374service servicemanager /system/bin/servicemanager
375    class core
376    user system
377    group system
378    critical
379    onrestart restart zygote
380    onrestart restart media
381
382service vold /system/bin/vold
383    class core
384    socket vold stream 0660 root mount
385    ioprio be 2
386
387service netd /system/bin/netd
388    class main
389    socket netd stream 0660 root system
390    socket dnsproxyd stream 0660 root inet
391
392service debuggerd /system/bin/debuggerd
393    class main
394
395service ril-daemon /system/bin/rild
396    class main
397    socket rild stream 660 root radio
398    socket rild-debug stream 660 radio system
399    user root
400    group radio cache inet misc audio sdcard_rw
401
402service surfaceflinger /system/bin/surfaceflinger
403    class main
404    user system
405    group graphics
406    onrestart restart zygote
407
408service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
409    class main
410    socket zygote stream 666
411    onrestart write /sys/android_power/request_state wake
412    onrestart write /sys/power/state on
413    onrestart restart media
414    onrestart restart netd
415
416service drm /system/bin/drmserver
417    class main
418    user drm
419    group system inet drmrpc
420
421service media /system/bin/mediaserver
422    class main
423    user media
424    group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc
425    ioprio rt 4
426
427service bootanim /system/bin/bootanimation
428    class main
429    user graphics
430    group graphics
431    disabled
432    oneshot
433
434service dbus /system/bin/dbus-daemon --system --nofork
435    class main
436    socket dbus stream 660 bluetooth bluetooth
437    user bluetooth
438    group bluetooth net_bt_admin
439
440service bluetoothd /system/bin/bluetoothd -n
441    class main
442    socket bluetooth stream 660 bluetooth bluetooth
443    socket dbus_bluetooth stream 660 bluetooth bluetooth
444    # init.rc does not yet support applying capabilities, so run as root and
445    # let bluetoothd drop uid to bluetooth with the right linux capabilities
446    group bluetooth net_bt_admin misc
447    disabled
448
449service installd /system/bin/installd
450    class main
451    socket installd stream 600 system system
452
453service flash_recovery /system/etc/install-recovery.sh
454    class main
455    oneshot
456
457service racoon /system/bin/racoon
458    class main
459    socket racoon stream 600 system system
460    # IKE uses UDP port 500. Racoon will setuid to vpn after binding the port.
461    group vpn net_admin inet
462    disabled
463    oneshot
464
465service mtpd /system/bin/mtpd
466    class main
467    socket mtpd stream 600 system system
468    user vpn
469    group vpn net_admin inet net_raw
470    disabled
471    oneshot
472
473service keystore /system/bin/keystore /data/misc/keystore
474    class main
475    user keystore
476    group keystore
477    socket keystore stream 666
478
479service dumpstate /system/bin/dumpstate -s
480    class main
481    socket dumpstate stream 0660 shell log
482    disabled
483    oneshot
484