init.rc revision d0645bf0cc76ef7be11cf77a8e1995233a1972e4
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:/system/sbin:/system/bin:/system/xbin 15 export LD_LIBRARY_PATH /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 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 22 23# Backward compatibility 24 symlink /system/etc /etc 25 symlink /sys/kernel/debug /d 26 27 28# Create cgroup mount point for cpu accounting 29 mkdir /acct 30 mount cgroup none /acct cpuacct 31 mkdir /acct/uid 32 33 mkdir /system 34 mkdir /data 0771 system system 35 mkdir /cache 0770 system cache 36 mkdir /config 0500 root root 37 38 # Directory for putting things only root should see. 39 mkdir /mnt/secure 0700 root root 40 41 # Directory for staging bindmounts 42 mkdir /mnt/secure/staging 0700 root root 43 44 # Directory-target for where the secure container 45 # imagefile directory will be bind-mounted 46 mkdir /mnt/secure/asec 0700 root root 47 48 # Secure container public mount points. 49 mkdir /mnt/asec 0700 root system 50 mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000 51 52 mount rootfs rootfs / ro remount 53 54 write /proc/sys/kernel/panic_on_oops 1 55 write /proc/sys/kernel/hung_task_timeout_secs 0 56 write /proc/cpu/alignment 4 57 write /proc/sys/kernel/sched_latency_ns 10000000 58 write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000 59 write /proc/sys/kernel/sched_compat_yield 1 60 write /proc/sys/kernel/sched_child_runs_first 0 61 62# Create cgroup mount points for process groups 63 mkdir /dev/cpuctl 64 mount cgroup none /dev/cpuctl cpu 65 chown system system /dev/cpuctl 66 chown system system /dev/cpuctl/tasks 67 chmod 0777 /dev/cpuctl/tasks 68 write /dev/cpuctl/cpu.shares 1024 69 70 mkdir /dev/cpuctl/fg_boost 71 chown system system /dev/cpuctl/fg_boost/tasks 72 chmod 0777 /dev/cpuctl/fg_boost/tasks 73 write /dev/cpuctl/fg_boost/cpu.shares 1024 74 75 mkdir /dev/cpuctl/bg_non_interactive 76 chown system system /dev/cpuctl/bg_non_interactive/tasks 77 chmod 0777 /dev/cpuctl/bg_non_interactive/tasks 78 # 5.0 % 79 write /dev/cpuctl/bg_non_interactive/cpu.shares 52 80 81on fs 82# mount mtd partitions 83 # Mount /system rw first to give the filesystem a chance to save a checkpoint 84 mount yaffs2 mtd@system /system 85 mount yaffs2 mtd@system /system ro remount 86 mount yaffs2 mtd@userdata /data nosuid nodev 87 mount yaffs2 mtd@cache /cache nosuid nodev 88 89on post-fs 90 # We chown/chmod /data again so because mount is run as root + defaults 91 chown system system /data 92 chmod 0771 /data 93 94 # Create dump dir and collect dumps. 95 # Do this before we mount cache so eventually we can use cache for 96 # storing dumps on platforms which do not have a dedicated dump partition. 97 98 mkdir /data/dontpanic 99 chown root log /data/dontpanic 100 chmod 0750 /data/dontpanic 101 102 # Collect apanic data, free resources and re-arm trigger 103 copy /proc/apanic_console /data/dontpanic/apanic_console 104 chown root log /data/dontpanic/apanic_console 105 chmod 0640 /data/dontpanic/apanic_console 106 107 copy /proc/apanic_threads /data/dontpanic/apanic_threads 108 chown root log /data/dontpanic/apanic_threads 109 chmod 0640 /data/dontpanic/apanic_threads 110 111 write /proc/apanic_console 1 112 113 # Same reason as /data above 114 chown system cache /cache 115 chmod 0770 /cache 116 117 # This may have been created by the recovery system with odd permissions 118 chown system cache /cache/recovery 119 chmod 0770 /cache/recovery 120 121 #change permissions on vmallocinfo so we can grab it from bugreports 122 chown root log /proc/vmallocinfo 123 chmod 0440 /proc/vmallocinfo 124 125 #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks 126 chown root system /proc/kmsg 127 chmod 0440 /proc/kmsg 128 chown root system /proc/sysrq-trigger 129 chmod 0220 /proc/sysrq-trigger 130 131# create basic filesystem structure 132 mkdir /data/misc 01771 system misc 133 mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth 134 mkdir /data/misc/bluetooth 0770 system system 135 mkdir /data/misc/keystore 0700 keystore keystore 136 mkdir /data/misc/vpn 0770 system system 137 mkdir /data/misc/systemkeys 0700 system system 138 mkdir /data/misc/vpn/profiles 0770 system system 139 # give system access to wpa_supplicant.conf for backup and restore 140 mkdir /data/misc/wifi 0770 wifi wifi 141 chmod 0770 /data/misc/wifi 142 chmod 0660 /data/misc/wifi/wpa_supplicant.conf 143 mkdir /data/local 0771 shell shell 144 mkdir /data/local/tmp 0771 shell shell 145 mkdir /data/data 0771 system system 146 mkdir /data/app-private 0771 system system 147 mkdir /data/app 0771 system system 148 mkdir /data/property 0700 root root 149 150 # create dalvik-cache and double-check the perms 151 mkdir /data/dalvik-cache 0771 system system 152 chown system system /data/dalvik-cache 153 chmod 0771 /data/dalvik-cache 154 155 # create the lost+found directories, so as to enforce our permissions 156 mkdir /data/lost+found 0770 157 mkdir /cache/lost+found 0770 158 159 # double check the perms, in case lost+found already exists, and set owner 160 chown root root /data/lost+found 161 chmod 0770 /data/lost+found 162 chown root root /cache/lost+found 163 chmod 0770 /cache/lost+found 164 165on boot 166# basic network init 167 ifup lo 168 hostname localhost 169 domainname localdomain 170 171# set RLIMIT_NICE to allow priorities from 19 to -20 172 setrlimit 13 40 40 173 174# Define the oom_adj values for the classes of processes that can be 175# killed by the kernel. These are used in ActivityManagerService. 176 setprop ro.FOREGROUND_APP_ADJ 0 177 setprop ro.VISIBLE_APP_ADJ 1 178 setprop ro.PERCEPTIBLE_APP_ADJ 2 179 setprop ro.HEAVY_WEIGHT_APP_ADJ 3 180 setprop ro.SECONDARY_SERVER_ADJ 4 181 setprop ro.BACKUP_APP_ADJ 5 182 setprop ro.HOME_APP_ADJ 6 183 setprop ro.HIDDEN_APP_MIN_ADJ 7 184 setprop ro.EMPTY_APP_ADJ 15 185 186# Define the memory thresholds at which the above process classes will 187# be killed. These numbers are in pages (4k). 188 setprop ro.FOREGROUND_APP_MEM 2048 189 setprop ro.VISIBLE_APP_MEM 3072 190 setprop ro.PERCEPTIBLE_APP_MEM 4096 191 setprop ro.HEAVY_WEIGHT_APP_MEM 4096 192 setprop ro.SECONDARY_SERVER_MEM 6144 193 setprop ro.BACKUP_APP_MEM 6144 194 setprop ro.HOME_APP_MEM 6144 195 setprop ro.HIDDEN_APP_MEM 7168 196 setprop ro.EMPTY_APP_MEM 8192 197 198# Write value must be consistent with the above properties. 199# Note that the driver only supports 6 slots, so we have combined some of 200# the classes into the same memory level; the associated processes of higher 201# classes will still be killed first. 202 write /sys/module/lowmemorykiller/parameters/adj 0,1,2,4,7,15 203 204 write /proc/sys/vm/overcommit_memory 1 205 write /proc/sys/vm/min_free_order_shift 4 206 write /sys/module/lowmemorykiller/parameters/minfree 2048,3072,4096,6144,7168,8192 207 208 # Set init its forked children's oom_adj. 209 write /proc/1/oom_adj -16 210 211 # Tweak background writeout 212 write /proc/sys/vm/dirty_expire_centisecs 200 213 write /proc/sys/vm/dirty_background_ratio 5 214 215 # Permissions for System Server and daemons. 216 chown radio system /sys/android_power/state 217 chown radio system /sys/android_power/request_state 218 chown radio system /sys/android_power/acquire_full_wake_lock 219 chown radio system /sys/android_power/acquire_partial_wake_lock 220 chown radio system /sys/android_power/release_wake_lock 221 chown radio system /sys/power/state 222 chown radio system /sys/power/wake_lock 223 chown radio system /sys/power/wake_unlock 224 chmod 0660 /sys/power/state 225 chmod 0660 /sys/power/wake_lock 226 chmod 0660 /sys/power/wake_unlock 227 chown system system /sys/class/timed_output/vibrator/enable 228 chown system system /sys/class/leds/keyboard-backlight/brightness 229 chown system system /sys/class/leds/lcd-backlight/brightness 230 chown system system /sys/class/leds/button-backlight/brightness 231 chown system system /sys/class/leds/jogball-backlight/brightness 232 chown system system /sys/class/leds/red/brightness 233 chown system system /sys/class/leds/green/brightness 234 chown system system /sys/class/leds/blue/brightness 235 chown system system /sys/class/leds/red/device/grpfreq 236 chown system system /sys/class/leds/red/device/grppwm 237 chown system system /sys/class/leds/red/device/blink 238 chown system system /sys/class/leds/red/brightness 239 chown system system /sys/class/leds/green/brightness 240 chown system system /sys/class/leds/blue/brightness 241 chown system system /sys/class/leds/red/device/grpfreq 242 chown system system /sys/class/leds/red/device/grppwm 243 chown system system /sys/class/leds/red/device/blink 244 chown system system /sys/class/timed_output/vibrator/enable 245 chown system system /sys/module/sco/parameters/disable_esco 246 chown system system /sys/kernel/ipv4/tcp_wmem_min 247 chown system system /sys/kernel/ipv4/tcp_wmem_def 248 chown system system /sys/kernel/ipv4/tcp_wmem_max 249 chown system system /sys/kernel/ipv4/tcp_rmem_min 250 chown system system /sys/kernel/ipv4/tcp_rmem_def 251 chown system system /sys/kernel/ipv4/tcp_rmem_max 252 chown root radio /proc/cmdline 253 254# Define TCP buffer sizes for various networks 255# ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax, 256 setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208 257 setprop net.tcp.buffersize.wifi 4095,87380,110208,4096,16384,110208 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 class_start default 263 264## Daemon processes to be run by init. 265## 266service console /system/bin/sh 267 console 268 269service ueventd /sbin/ueventd 270 critical 271 272# adbd is controlled by the persist.service.adb.enable system property 273service adbd /sbin/adbd 274 disabled 275 276# adbd on at boot in emulator 277on property:ro.kernel.qemu=1 278 start adbd 279 280on property:persist.service.adb.enable=1 281 start adbd 282 283on property:persist.service.adb.enable=0 284 stop adbd 285 286service servicemanager /system/bin/servicemanager 287 user system 288 critical 289 onrestart restart zygote 290 onrestart restart media 291 292service vold /system/bin/vold 293 socket vold stream 0660 root mount 294 ioprio be 2 295 296service netd /system/bin/netd 297 socket netd stream 0660 root system 298 299service debuggerd /system/bin/debuggerd 300 301service ril-daemon /system/bin/rild 302 socket rild stream 660 root radio 303 socket rild-debug stream 660 radio system 304 user root 305 group radio cache inet misc audio 306 307service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server 308 socket zygote stream 666 309 onrestart write /sys/android_power/request_state wake 310 onrestart write /sys/power/state on 311 onrestart restart media 312 313service media /system/bin/mediaserver 314 user media 315 group system audio camera graphics inet net_bt net_bt_admin net_raw 316 ioprio rt 4 317 318service bootanim /system/bin/bootanimation 319 user graphics 320 group graphics 321 disabled 322 oneshot 323 324service dbus /system/bin/dbus-daemon --system --nofork 325 socket dbus stream 660 bluetooth bluetooth 326 user bluetooth 327 group bluetooth net_bt_admin 328 329service bluetoothd /system/bin/bluetoothd -n 330 socket bluetooth stream 660 bluetooth bluetooth 331 socket dbus_bluetooth stream 660 bluetooth bluetooth 332 # init.rc does not yet support applying capabilities, so run as root and 333 # let bluetoothd drop uid to bluetooth with the right linux capabilities 334 group bluetooth net_bt_admin misc 335 disabled 336 337service hfag /system/bin/sdptool add --channel=10 HFAG 338 user bluetooth 339 group bluetooth net_bt_admin 340 disabled 341 oneshot 342 343service hsag /system/bin/sdptool add --channel=11 HSAG 344 user bluetooth 345 group bluetooth net_bt_admin 346 disabled 347 oneshot 348 349service opush /system/bin/sdptool add --channel=12 OPUSH 350 user bluetooth 351 group bluetooth net_bt_admin 352 disabled 353 oneshot 354 355service pbap /system/bin/sdptool add --channel=19 PBAP 356 user bluetooth 357 group bluetooth net_bt_admin 358 disabled 359 oneshot 360 361service installd /system/bin/installd 362 socket installd stream 600 system system 363 364service flash_recovery /system/etc/install-recovery.sh 365 oneshot 366 367service racoon /system/bin/racoon 368 socket racoon stream 600 system system 369 # racoon will setuid to vpn after getting necessary resources. 370 group net_admin 371 disabled 372 oneshot 373 374service mtpd /system/bin/mtpd 375 socket mtpd stream 600 system system 376 user vpn 377 group vpn net_admin net_raw 378 disabled 379 oneshot 380 381service keystore /system/bin/keystore /data/misc/keystore 382 user keystore 383 group keystore 384 socket keystore stream 666 385 386service dumpstate /system/bin/dumpstate -s 387 socket dumpstate stream 0660 shell log 388 disabled 389 oneshot 390