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