init.rc revision 8c5669f9f9a228efebf4059fd4ceace5cece578b
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/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.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
87on fs
88# mount mtd partitions
89    # Mount /system rw first to give the filesystem a chance to save a checkpoint
90    mount yaffs2 mtd@system /system
91    mount yaffs2 mtd@system /system ro remount
92    mount yaffs2 mtd@userdata /data nosuid nodev
93    mount yaffs2 mtd@cache /cache nosuid nodev
94
95on post-fs
96    # once everything is setup, no need to modify /
97    mount rootfs rootfs / ro remount
98
99    # We chown/chmod /data again so because mount is run as root + defaults
100    chown system system /data
101    chmod 0771 /data
102
103    # Create dump dir and collect dumps.
104    # Do this before we mount cache so eventually we can use cache for
105    # storing dumps on platforms which do not have a dedicated dump partition.
106   
107    mkdir /data/dontpanic
108    chown root log /data/dontpanic
109    chmod 0750 /data/dontpanic
110
111    # Collect apanic data, free resources and re-arm trigger
112    copy /proc/apanic_console /data/dontpanic/apanic_console
113    chown root log /data/dontpanic/apanic_console
114    chmod 0640 /data/dontpanic/apanic_console
115
116    copy /proc/apanic_threads /data/dontpanic/apanic_threads
117    chown root log /data/dontpanic/apanic_threads
118    chmod 0640 /data/dontpanic/apanic_threads
119
120    write /proc/apanic_console 1
121
122    # Same reason as /data above
123    chown system cache /cache
124    chmod 0770 /cache
125
126    # This may have been created by the recovery system with odd permissions
127    chown system cache /cache/recovery
128    chmod 0770 /cache/recovery
129
130    #change permissions on vmallocinfo so we can grab it from bugreports
131    chown root log /proc/vmallocinfo
132    chmod 0440 /proc/vmallocinfo
133
134    #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
135    chown root system /proc/kmsg
136    chmod 0440 /proc/kmsg
137    chown root system /proc/sysrq-trigger
138    chmod 0220 /proc/sysrq-trigger
139
140# create basic filesystem structure
141    mkdir /data/misc 01771 system misc
142    mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
143    mkdir /data/misc/bluetooth 0770 system system
144    mkdir /data/misc/keystore 0700 keystore keystore
145    mkdir /data/misc/vpn 0770 system system
146    mkdir /data/misc/systemkeys 0700 system system
147    mkdir /data/misc/vpn/profiles 0770 system system
148    # give system access to wpa_supplicant.conf for backup and restore
149    mkdir /data/misc/wifi 0770 wifi wifi
150    chmod 0770 /data/misc/wifi
151    chmod 0660 /data/misc/wifi/wpa_supplicant.conf
152    mkdir /data/local 0771 shell shell
153    mkdir /data/local/tmp 0771 shell shell
154    mkdir /data/data 0771 system system
155    mkdir /data/app-private 0771 system system
156    mkdir /data/app 0771 system system
157    mkdir /data/property 0700 root root
158
159    # create dalvik-cache and double-check the perms
160    mkdir /data/dalvik-cache 0771 system system
161    chown system system /data/dalvik-cache
162    chmod 0771 /data/dalvik-cache
163
164    # create the lost+found directories, so as to enforce our permissions
165    mkdir /data/lost+found 0770
166    mkdir /cache/lost+found 0770
167
168    # double check the perms, in case lost+found already exists, and set owner
169    chown root root /data/lost+found
170    chmod 0770 /data/lost+found
171    chown root root /cache/lost+found
172    chmod 0770 /cache/lost+found
173
174    # create data/drm directory
175    mkdir /data/drm 0774 drm drm
176    chown drm drm /data/drm
177    chmod 0774 /data/drm
178
179on boot
180# basic network init
181    ifup lo
182    hostname localhost
183    domainname localdomain
184
185# set RLIMIT_NICE to allow priorities from 19 to -20
186    setrlimit 13 40 40
187
188# Define the oom_adj values for the classes of processes that can be
189# killed by the kernel.  These are used in ActivityManagerService.
190    setprop ro.FOREGROUND_APP_ADJ 0
191    setprop ro.VISIBLE_APP_ADJ 1
192    setprop ro.PERCEPTIBLE_APP_ADJ 2
193    setprop ro.HEAVY_WEIGHT_APP_ADJ 3
194    setprop ro.SECONDARY_SERVER_ADJ 4
195    setprop ro.BACKUP_APP_ADJ 5
196    setprop ro.HOME_APP_ADJ 6
197    setprop ro.HIDDEN_APP_MIN_ADJ 7
198    setprop ro.EMPTY_APP_ADJ 15
199
200# Define the memory thresholds at which the above process classes will
201# be killed.  These numbers are in pages (4k).
202    setprop ro.FOREGROUND_APP_MEM 2048
203    setprop ro.VISIBLE_APP_MEM 3072
204    setprop ro.PERCEPTIBLE_APP_MEM 4096
205    setprop ro.HEAVY_WEIGHT_APP_MEM 4096
206    setprop ro.SECONDARY_SERVER_MEM 6144
207    setprop ro.BACKUP_APP_MEM 6144
208    setprop ro.HOME_APP_MEM 6144
209    setprop ro.HIDDEN_APP_MEM 7168
210    setprop ro.EMPTY_APP_MEM 8192
211
212# Write value must be consistent with the above properties.
213# Note that the driver only supports 6 slots, so we have combined some of
214# the classes into the same memory level; the associated processes of higher
215# classes will still be killed first.
216    write /sys/module/lowmemorykiller/parameters/adj 0,1,2,4,7,15
217
218    write /proc/sys/vm/overcommit_memory 1
219    write /proc/sys/vm/min_free_order_shift 4
220    write /sys/module/lowmemorykiller/parameters/minfree 2048,3072,4096,6144,7168,8192
221
222    # Set init its forked children's oom_adj.
223    write /proc/1/oom_adj -16
224
225    # Tweak background writeout
226    write /proc/sys/vm/dirty_expire_centisecs 200
227    write /proc/sys/vm/dirty_background_ratio  5
228
229    # Permissions for System Server and daemons.
230    chown radio system /sys/android_power/state
231    chown radio system /sys/android_power/request_state
232    chown radio system /sys/android_power/acquire_full_wake_lock
233    chown radio system /sys/android_power/acquire_partial_wake_lock
234    chown radio system /sys/android_power/release_wake_lock
235    chown radio system /sys/power/state
236    chown radio system /sys/power/wake_lock
237    chown radio system /sys/power/wake_unlock
238    chmod 0660 /sys/power/state
239    chmod 0660 /sys/power/wake_lock
240    chmod 0660 /sys/power/wake_unlock
241    chown system system /sys/class/timed_output/vibrator/enable
242    chown system system /sys/class/leds/keyboard-backlight/brightness
243    chown system system /sys/class/leds/lcd-backlight/brightness
244    chown system system /sys/class/leds/button-backlight/brightness
245    chown system system /sys/class/leds/jogball-backlight/brightness
246    chown system system /sys/class/leds/red/brightness
247    chown system system /sys/class/leds/green/brightness
248    chown system system /sys/class/leds/blue/brightness
249    chown system system /sys/class/leds/red/device/grpfreq
250    chown system system /sys/class/leds/red/device/grppwm
251    chown system system /sys/class/leds/red/device/blink
252    chown system system /sys/class/leds/red/brightness
253    chown system system /sys/class/leds/green/brightness
254    chown system system /sys/class/leds/blue/brightness
255    chown system system /sys/class/leds/red/device/grpfreq
256    chown system system /sys/class/leds/red/device/grppwm
257    chown system system /sys/class/leds/red/device/blink
258    chown system system /sys/class/timed_output/vibrator/enable
259    chown system system /sys/module/sco/parameters/disable_esco
260    chown system system /sys/kernel/ipv4/tcp_wmem_min
261    chown system system /sys/kernel/ipv4/tcp_wmem_def
262    chown system system /sys/kernel/ipv4/tcp_wmem_max
263    chown system system /sys/kernel/ipv4/tcp_rmem_min
264    chown system system /sys/kernel/ipv4/tcp_rmem_def
265    chown system system /sys/kernel/ipv4/tcp_rmem_max
266    chown root radio /proc/cmdline
267
268# Define TCP buffer sizes for various networks
269#   ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
270    setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
271    setprop net.tcp.buffersize.wifi    4095,87380,110208,4096,16384,110208
272    setprop net.tcp.buffersize.umts    4094,87380,110208,4096,16384,110208
273    setprop net.tcp.buffersize.edge    4093,26280,35040,4096,16384,35040
274    setprop net.tcp.buffersize.gprs    4092,8760,11680,4096,8760,11680
275
276    class_start default
277
278## Daemon processes to be run by init.
279##
280service console /system/bin/sh
281    console
282
283service ueventd /sbin/ueventd
284    critical
285
286# adbd is controlled by the persist.service.adb.enable system property
287service adbd /sbin/adbd
288    disabled
289
290# adbd on at boot in emulator
291on property:ro.kernel.qemu=1
292    start adbd
293
294on property:persist.service.adb.enable=1
295    start adbd
296
297on property:persist.service.adb.enable=0
298    stop adbd
299
300service servicemanager /system/bin/servicemanager
301    user system
302    critical
303    onrestart restart zygote
304    onrestart restart media
305
306service vold /system/bin/vold
307    socket vold stream 0660 root mount
308    ioprio be 2
309
310service netd /system/bin/netd
311    socket netd stream 0660 root system
312    socket dnsproxyd stream 0660 root inet
313
314service debuggerd /system/bin/debuggerd
315
316service ril-daemon /system/bin/rild
317    socket rild stream 660 root radio
318    socket rild-debug stream 660 radio system
319    user root
320    group radio cache inet misc audio sdcard_rw
321
322service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
323    socket zygote stream 666
324    onrestart write /sys/android_power/request_state wake
325    onrestart write /sys/power/state on
326    onrestart restart media
327    onrestart restart netd
328
329service drm /system/bin/drmserver
330    user drm
331    group system root inet
332
333service drmio /system/bin/drmioserver
334    user drmio
335
336service media /system/bin/mediaserver
337    user media
338    group system audio camera graphics inet net_bt net_bt_admin net_raw
339    ioprio rt 4
340
341service bootanim /system/bin/bootanimation
342    user graphics
343    group graphics
344    disabled
345    oneshot
346
347service dbus /system/bin/dbus-daemon --system --nofork
348    socket dbus stream 660 bluetooth bluetooth
349    user bluetooth
350    group bluetooth net_bt_admin
351
352service bluetoothd /system/bin/bluetoothd -n
353    socket bluetooth stream 660 bluetooth bluetooth
354    socket dbus_bluetooth stream 660 bluetooth bluetooth
355    # init.rc does not yet support applying capabilities, so run as root and
356    # let bluetoothd drop uid to bluetooth with the right linux capabilities
357    group bluetooth net_bt_admin misc
358    disabled
359
360service hfag /system/bin/sdptool add --channel=10 HFAG
361    user bluetooth
362    group bluetooth net_bt_admin
363    disabled
364    oneshot
365
366service hsag /system/bin/sdptool add --channel=11 HSAG
367    user bluetooth
368    group bluetooth net_bt_admin
369    disabled
370    oneshot
371
372service opush /system/bin/sdptool add --channel=12 OPUSH
373    user bluetooth
374    group bluetooth net_bt_admin
375    disabled
376    oneshot
377
378service pbap /system/bin/sdptool add --channel=19 PBAP
379    user bluetooth
380    group bluetooth net_bt_admin
381    disabled
382    oneshot
383
384service installd /system/bin/installd
385    socket installd stream 600 system system
386
387service flash_recovery /system/etc/install-recovery.sh
388    oneshot
389
390service racoon /system/bin/racoon
391    socket racoon stream 600 system system
392    # racoon will setuid to vpn after getting necessary resources.
393    group net_admin
394    disabled
395    oneshot
396
397service mtpd /system/bin/mtpd
398    socket mtpd stream 600 system system
399    user vpn
400    group vpn net_admin net_raw
401    disabled
402    oneshot
403
404service keystore /system/bin/keystore /data/misc/keystore
405    user keystore
406    group keystore
407    socket keystore stream 666
408
409service dumpstate /system/bin/dumpstate -s
410    socket dumpstate stream 0660 shell log
411    disabled
412    oneshot
413