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