init.rc revision 3507616870acd71bbd26e045528b0cfe716d37cd
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 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 /cache again so because mount is run as root + defaults 100 chown system cache /cache 101 chmod 0770 /cache 102 103 # This may have been created by the recovery system with odd permissions 104 chown system cache /cache/recovery 105 chmod 0770 /cache/recovery 106 107 #change permissions on vmallocinfo so we can grab it from bugreports 108 chown root log /proc/vmallocinfo 109 chmod 0440 /proc/vmallocinfo 110 111 #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks 112 chown root system /proc/kmsg 113 chmod 0440 /proc/kmsg 114 chown root system /proc/sysrq-trigger 115 chmod 0220 /proc/sysrq-trigger 116 117 # create the lost+found directories, so as to enforce our permissions 118 mkdir /cache/lost+found 0770 root root 119 120on post-fs-data 121 # We chown/chmod /data again so because mount is run as root + defaults 122 chown system system /data 123 chmod 0771 /data 124 125 # Create dump dir and collect dumps. 126 # Do this before we mount cache so eventually we can use cache for 127 # storing dumps on platforms which do not have a dedicated dump partition. 128 mkdir /data/dontpanic 0750 root log 129 130 # Collect apanic data, free resources and re-arm trigger 131 copy /proc/apanic_console /data/dontpanic/apanic_console 132 chown root log /data/dontpanic/apanic_console 133 chmod 0640 /data/dontpanic/apanic_console 134 135 copy /proc/apanic_threads /data/dontpanic/apanic_threads 136 chown root log /data/dontpanic/apanic_threads 137 chmod 0640 /data/dontpanic/apanic_threads 138 139 write /proc/apanic_console 1 140 141 # create basic filesystem structure 142 mkdir /data/misc 01771 system misc 143 mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth 144 mkdir /data/misc/bluetooth 0770 system system 145 mkdir /data/misc/keystore 0700 keystore keystore 146 mkdir /data/misc/keychain 0771 system system 147 mkdir /data/misc/vpn 0770 system vpn 148 mkdir /data/misc/systemkeys 0700 system system 149 # give system access to wpa_supplicant.conf for backup and restore 150 mkdir /data/misc/wifi 0770 wifi 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, so as to enforce our permissions 160 mkdir /data/dalvik-cache 0771 system system 161 162 # create resource-cache and double-check the perms 163 mkdir /data/resource-cache 0771 system system 164 chown system system /data/resource-cache 165 chmod 0771 /data/resource-cache 166 167 # create the lost+found directories, so as to enforce our permissions 168 mkdir /data/lost+found 0770 root root 169 170 # create directory for DRM plug-ins 171 mkdir /data/drm 0774 drm drm 172 173 # If there is no fs-post-data action in the init.<device>.rc file, you 174 # must uncomment this line, otherwise encrypted filesystems 175 # won't work. 176 # Set indication (checked by vold) that we have finished this action 177 #setprop vold.post_fs_data_done 1 178 179 chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file 180 chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file 181 chown system system /sys/class/android_usb/android0/f_rndis/ethaddr 182 chmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddr 183 184on boot 185# basic network init 186 ifup lo 187 hostname localhost 188 domainname localdomain 189 190# set RLIMIT_NICE to allow priorities from 19 to -20 191 setrlimit 13 40 40 192 193# Define the oom_adj values for the classes of processes that can be 194# killed by the kernel. These are used in ActivityManagerService. 195 setprop ro.FOREGROUND_APP_ADJ 0 196 setprop ro.VISIBLE_APP_ADJ 1 197 setprop ro.PERCEPTIBLE_APP_ADJ 2 198 setprop ro.HEAVY_WEIGHT_APP_ADJ 3 199 setprop ro.SECONDARY_SERVER_ADJ 4 200 setprop ro.BACKUP_APP_ADJ 5 201 setprop ro.HOME_APP_ADJ 6 202 setprop ro.HIDDEN_APP_MIN_ADJ 7 203 setprop ro.EMPTY_APP_ADJ 15 204 205# Define the memory thresholds at which the above process classes will 206# be killed. These numbers are in pages (4k). 207 # These are currently tuned for tablets with approx 1GB RAM. 208 setprop ro.FOREGROUND_APP_MEM 8192 209 setprop ro.VISIBLE_APP_MEM 10240 210 setprop ro.PERCEPTIBLE_APP_MEM 12288 211 setprop ro.HEAVY_WEIGHT_APP_MEM 12288 212 setprop ro.SECONDARY_SERVER_MEM 14336 213 setprop ro.BACKUP_APP_MEM 14336 214 setprop ro.HOME_APP_MEM 14336 215 setprop ro.HIDDEN_APP_MEM 16384 216 setprop ro.EMPTY_APP_MEM 20480 217 218 # Old values for phones. Should probably be adjusted up for the next 219 # phone version. 220 #setprop ro.FOREGROUND_APP_MEM 2048 221 #setprop ro.VISIBLE_APP_MEM 3072 222 #setprop ro.PERCEPTIBLE_APP_MEM 4096 223 #setprop ro.HEAVY_WEIGHT_APP_MEM 4096 224 #setprop ro.SECONDARY_SERVER_MEM 6144 225 #setprop ro.BACKUP_APP_MEM 6144 226 #setprop ro.HOME_APP_MEM 6144 227 #setprop ro.HIDDEN_APP_MEM 7168 228 #setprop ro.EMPTY_APP_MEM 8192 229 230# Write value must be consistent with the above properties. 231# Note that the driver only supports 6 slots, so we have combined some of 232# the classes into the same memory level; the associated processes of higher 233# classes will still be killed first. 234 write /sys/module/lowmemorykiller/parameters/adj 0,1,2,4,7,15 235 236 write /proc/sys/vm/overcommit_memory 1 237 write /proc/sys/vm/min_free_order_shift 4 238 write /sys/module/lowmemorykiller/parameters/minfree 8192,10240,12288,14336,16384,20480 239 240 # Set init its forked children's oom_adj. 241 write /proc/1/oom_adj -16 242 243 # Tweak background writeout 244 write /proc/sys/vm/dirty_expire_centisecs 200 245 write /proc/sys/vm/dirty_background_ratio 5 246 247 # Permissions for System Server and daemons. 248 chown radio system /sys/android_power/state 249 chown radio system /sys/android_power/request_state 250 chown radio system /sys/android_power/acquire_full_wake_lock 251 chown radio system /sys/android_power/acquire_partial_wake_lock 252 chown radio system /sys/android_power/release_wake_lock 253 chown radio system /sys/power/state 254 chown radio system /sys/power/wake_lock 255 chown radio system /sys/power/wake_unlock 256 chmod 0660 /sys/power/state 257 chmod 0660 /sys/power/wake_lock 258 chmod 0660 /sys/power/wake_unlock 259 chown system system /sys/class/timed_output/vibrator/enable 260 chown system system /sys/class/leds/keyboard-backlight/brightness 261 chown system system /sys/class/leds/lcd-backlight/brightness 262 chown system system /sys/class/leds/button-backlight/brightness 263 chown system system /sys/class/leds/jogball-backlight/brightness 264 chown system system /sys/class/leds/red/brightness 265 chown system system /sys/class/leds/green/brightness 266 chown system system /sys/class/leds/blue/brightness 267 chown system system /sys/class/leds/red/device/grpfreq 268 chown system system /sys/class/leds/red/device/grppwm 269 chown system system /sys/class/leds/red/device/blink 270 chown system system /sys/class/leds/red/brightness 271 chown system system /sys/class/leds/green/brightness 272 chown system system /sys/class/leds/blue/brightness 273 chown system system /sys/class/leds/red/device/grpfreq 274 chown system system /sys/class/leds/red/device/grppwm 275 chown system system /sys/class/leds/red/device/blink 276 chown system system /sys/class/timed_output/vibrator/enable 277 chown system system /sys/module/sco/parameters/disable_esco 278 chown system system /sys/kernel/ipv4/tcp_wmem_min 279 chown system system /sys/kernel/ipv4/tcp_wmem_def 280 chown system system /sys/kernel/ipv4/tcp_wmem_max 281 chown system system /sys/kernel/ipv4/tcp_rmem_min 282 chown system system /sys/kernel/ipv4/tcp_rmem_def 283 chown system system /sys/kernel/ipv4/tcp_rmem_max 284 chown root radio /proc/cmdline 285 286# Define TCP buffer sizes for various networks 287# ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax, 288 setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208 289 setprop net.tcp.buffersize.wifi 4095,87380,110208,4096,16384,110208 290 setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208 291 setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040 292 setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680 293 294# Set this property so surfaceflinger is not started by system_init 295 setprop system_init.startsurfaceflinger 0 296 297 class_start core 298 class_start main 299 300on nonencrypted 301 class_start late_start 302 303on property:vold.decrypt=trigger_reset_main 304 class_reset main 305 306on property:vold.decrypt=trigger_load_persist_props 307 load_persist_props 308 309on property:vold.decrypt=trigger_post_fs_data 310 trigger post-fs-data 311 312on property:vold.decrypt=trigger_restart_min_framework 313 class_start main 314 315on property:vold.decrypt=trigger_restart_framework 316 class_start main 317 class_start late_start 318 319on property:vold.decrypt=trigger_shutdown_framework 320 class_reset late_start 321 class_reset main 322 323# USB accessory configuration 324on property:sys.usb.config=accessory 325 write /sys/class/android_usb/android0/enable 0 326 write /sys/class/android_usb/android0/idVendor 18d1 327 write /sys/class/android_usb/android0/idProduct 2d00 328 write /sys/class/android_usb/android0/functions $sys.usb.config 329 write /sys/class/android_usb/android0/enable 1 330 setprop sys.usb.state $sys.usb.config 331 332# USB accessory configuration, with adb 333on property:sys.usb.config=accessory,adb 334 write /sys/class/android_usb/android0/enable 0 335 write /sys/class/android_usb/android0/idVendor 18d1 336 write /sys/class/android_usb/android0/idProduct 2d01 337 write /sys/class/android_usb/android0/functions $sys.usb.config 338 write /sys/class/android_usb/android0/enable 1 339 start adbd 340 setprop sys.usb.state $sys.usb.config 341 342on property:persist.sys.usb.config=* 343 setprop sys.usb.config $persist.sys.usb.config 344 345## Daemon processes to be run by init. 346## 347service ueventd /sbin/ueventd 348 class core 349 critical 350 351service console /system/bin/sh 352 class core 353 console 354 disabled 355 user shell 356 group log 357 358on property:ro.debuggable=1 359 start console 360 361# adbd is controlled via property triggers in init.<platform>.usb.rc 362service adbd /sbin/adbd 363 class core 364 disabled 365 366# adbd on at boot in emulator 367on property:ro.kernel.qemu=1 368 start adbd 369 370# This property trigger has added to imitiate the previous behavior of "adb root". 371# The adb gadget driver used to reset the USB bus when the adbd daemon exited, 372# and the host side adb relied on this behavior to force it to reconnect with the 373# new adbd instance after init relaunches it. So now we force the USB bus to reset 374# here when adbd sets the service.adb.root property to 1. We also restart adbd here 375# rather than waiting for init to notice its death and restarting it so the timing 376# of USB resetting and adb restarting more closely matches the previous behavior. 377on property:service.adb.root=1 378 write /sys/class/android_usb/android0/enable 0 379 restart adbd 380 write /sys/class/android_usb/android0/enable 1 381 382service servicemanager /system/bin/servicemanager 383 class core 384 user system 385 group system 386 critical 387 onrestart restart zygote 388 onrestart restart media 389 390service vold /system/bin/vold 391 class core 392 socket vold stream 0660 root mount 393 ioprio be 2 394 395service netd /system/bin/netd 396 class main 397 socket netd stream 0660 root system 398 socket dnsproxyd stream 0660 root inet 399 400service debuggerd /system/bin/debuggerd 401 class main 402 403service ril-daemon /system/bin/rild 404 class main 405 socket rild stream 660 root radio 406 socket rild-debug stream 660 radio system 407 user root 408 group radio cache inet misc audio sdcard_rw 409 410service surfaceflinger /system/bin/surfaceflinger 411 class main 412 user system 413 group graphics 414 onrestart restart zygote 415 416service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server 417 class main 418 socket zygote stream 666 419 onrestart write /sys/android_power/request_state wake 420 onrestart write /sys/power/state on 421 onrestart restart media 422 onrestart restart netd 423 424service drm /system/bin/drmserver 425 class main 426 user drm 427 group system inet 428 429service media /system/bin/mediaserver 430 class main 431 user media 432 group audio camera inet net_bt net_bt_admin 433 ioprio rt 4 434 435service bootanim /system/bin/bootanimation 436 class main 437 user graphics 438 group graphics 439 disabled 440 oneshot 441 442service dbus /system/bin/dbus-daemon --system --nofork 443 class main 444 socket dbus stream 660 bluetooth bluetooth 445 user bluetooth 446 group bluetooth net_bt_admin 447 448service bluetoothd /system/bin/bluetoothd -n 449 class main 450 socket bluetooth stream 660 bluetooth bluetooth 451 socket dbus_bluetooth stream 660 bluetooth bluetooth 452 # init.rc does not yet support applying capabilities, so run as root and 453 # let bluetoothd drop uid to bluetooth with the right linux capabilities 454 group bluetooth net_bt_admin misc 455 disabled 456 457service installd /system/bin/installd 458 class main 459 socket installd stream 600 system system 460 461service flash_recovery /system/etc/install-recovery.sh 462 class main 463 oneshot 464 465service racoon /system/bin/racoon 466 class main 467 socket racoon stream 600 system system 468 # IKE uses UDP port 500. Racoon will setuid to vpn after binding the port. 469 group vpn net_admin 470 disabled 471 oneshot 472 473service mtpd /system/bin/mtpd 474 class main 475 socket mtpd stream 600 system system 476 user vpn 477 group vpn net_admin net_raw 478 disabled 479 oneshot 480 481service keystore /system/bin/keystore /data/misc/keystore 482 class main 483 user keystore 484 group keystore 485 socket keystore stream 666 486 487service dumpstate /system/bin/dumpstate -s 488 class main 489 socket dumpstate stream 0660 shell log 490 disabled 491 oneshot 492