Home | History | Annotate | Download | only in rootdir
      1 on early-init
      2     start ueventd
      3 
      4 # create mountpoints
      5     mkdir /mnt 0775 root system
      6 
      7 on init
      8 
      9 sysclktz 0
     10 
     11 loglevel 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 
     87 # Allow everybody to read the xt_qtaguid resource tracking misc dev.
     88 # This is needed by any process that uses socket tagging.
     89     chmod 0644 /dev/xt_qtaguid
     90 
     91 on fs
     92 # mount mtd partitions
     93     # Mount /system rw first to give the filesystem a chance to save a checkpoint
     94     mount yaffs2 mtd@system /system
     95     mount yaffs2 mtd@system /system ro remount
     96     mount yaffs2 mtd@userdata /data nosuid nodev
     97     mount yaffs2 mtd@cache /cache nosuid nodev
     98 
     99 on post-fs
    100     # once everything is setup, no need to modify /
    101     mount rootfs rootfs / ro remount
    102 
    103     # We chown/chmod /cache again so because mount is run as root + defaults
    104     chown system cache /cache
    105     chmod 0770 /cache
    106 
    107     # This may have been created by the recovery system with odd permissions
    108     chown system cache /cache/recovery
    109     chmod 0770 /cache/recovery
    110 
    111     #change permissions on vmallocinfo so we can grab it from bugreports
    112     chown root log /proc/vmallocinfo
    113     chmod 0440 /proc/vmallocinfo
    114 
    115     #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
    116     chown root system /proc/kmsg
    117     chmod 0440 /proc/kmsg
    118     chown root system /proc/sysrq-trigger
    119     chmod 0220 /proc/sysrq-trigger
    120 
    121     # create the lost+found directories, so as to enforce our permissions
    122     mkdir /cache/lost+found 0770 root root
    123 
    124 on post-fs-data
    125     # We chown/chmod /data again so because mount is run as root + defaults
    126     chown system system /data
    127     chmod 0771 /data
    128 
    129     # Create dump dir and collect dumps.
    130     # Do this before we mount cache so eventually we can use cache for
    131     # storing dumps on platforms which do not have a dedicated dump partition.
    132     mkdir /data/dontpanic 0750 root log
    133 
    134     # Collect apanic data, free resources and re-arm trigger
    135     copy /proc/apanic_console /data/dontpanic/apanic_console
    136     chown root log /data/dontpanic/apanic_console
    137     chmod 0640 /data/dontpanic/apanic_console
    138 
    139     copy /proc/apanic_threads /data/dontpanic/apanic_threads
    140     chown root log /data/dontpanic/apanic_threads
    141     chmod 0640 /data/dontpanic/apanic_threads
    142 
    143     write /proc/apanic_console 1
    144 
    145     # create basic filesystem structure
    146     mkdir /data/misc 01771 system misc
    147     mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
    148     mkdir /data/misc/bluetooth 0770 system system
    149     mkdir /data/misc/keystore 0700 keystore keystore
    150     mkdir /data/misc/keychain 0771 system system
    151     mkdir /data/misc/vpn 0770 system vpn
    152     mkdir /data/misc/systemkeys 0700 system system
    153     # give system access to wpa_supplicant.conf for backup and restore
    154     mkdir /data/misc/wifi 0770 wifi wifi
    155     chmod 0660 /data/misc/wifi/wpa_supplicant.conf
    156     mkdir /data/local 0771 shell shell
    157     mkdir /data/local/tmp 0771 shell shell
    158     mkdir /data/data 0771 system system
    159     mkdir /data/app-private 0771 system system
    160     mkdir /data/app 0771 system system
    161     mkdir /data/property 0700 root root
    162 
    163     # create dalvik-cache, so as to enforce our permissions
    164     mkdir /data/dalvik-cache 0771 system system
    165 
    166     # create resource-cache and double-check the perms
    167     mkdir /data/resource-cache 0771 system system
    168     chown system system /data/resource-cache
    169     chmod 0771 /data/resource-cache
    170 
    171     # create the lost+found directories, so as to enforce our permissions
    172     mkdir /data/lost+found 0770 root root
    173 
    174     # create directory for DRM plug-ins
    175     mkdir /data/drm 0774 drm drm
    176 
    177     # If there is no fs-post-data action in the init.<device>.rc file, you
    178     # must uncomment this line, otherwise encrypted filesystems
    179     # won't work.
    180     # Set indication (checked by vold) that we have finished this action
    181     #setprop vold.post_fs_data_done 1
    182 
    183     chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file
    184     chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file
    185     chown system system /sys/class/android_usb/android0/f_rndis/ethaddr
    186     chmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddr
    187 
    188 on boot
    189 # basic network init
    190     ifup lo
    191     hostname localhost
    192     domainname localdomain
    193 
    194 # set RLIMIT_NICE to allow priorities from 19 to -20
    195     setrlimit 13 40 40
    196 
    197 # Memory management.  Basic kernel parameters, and allow the high
    198 # level system server to be able to adjust the kernel OOM driver
    199 # paramters to match how it is managing things.
    200     write /proc/sys/vm/overcommit_memory 1
    201     write /proc/sys/vm/min_free_order_shift 4
    202     chown root system /sys/module/lowmemorykiller/parameters/adj
    203     chmod 0664 /sys/module/lowmemorykiller/parameters/adj
    204     chown root system /sys/module/lowmemorykiller/parameters/minfree
    205     chmod 0664 /sys/module/lowmemorykiller/parameters/minfree
    206 
    207     # Set init and its forked children's oom_adj.
    208     write /proc/1/oom_adj -16
    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 
    269 on nonencrypted
    270     class_start late_start
    271 
    272 on charger
    273     class_start charger
    274 
    275 on property:vold.decrypt=trigger_reset_main
    276     class_reset main
    277 
    278 on property:vold.decrypt=trigger_load_persist_props
    279     load_persist_props
    280 
    281 on property:vold.decrypt=trigger_post_fs_data
    282     trigger post-fs-data
    283 
    284 on property:vold.decrypt=trigger_restart_min_framework
    285     class_start main
    286 
    287 on property:vold.decrypt=trigger_restart_framework
    288     class_start main
    289     class_start late_start
    290 
    291 on property:vold.decrypt=trigger_shutdown_framework
    292     class_reset late_start
    293     class_reset main
    294 
    295 # Used to disable USB when switching states
    296 on 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
    305 on 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
    315 on 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
    324 on 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
    335 on property:persist.sys.usb.config=*
    336     setprop sys.usb.config $persist.sys.usb.config
    337 
    338 ## Daemon processes to be run by init.
    339 ##
    340 service ueventd /sbin/ueventd
    341     class core
    342     critical
    343 
    344 service console /system/bin/sh
    345     class core
    346     console
    347     disabled
    348     user shell
    349     group log
    350 
    351 on property:ro.debuggable=1
    352     start console
    353 
    354 # adbd is controlled via property triggers in init.<platform>.usb.rc
    355 service adbd /sbin/adbd
    356     class core
    357     disabled
    358 
    359 # adbd on at boot in emulator
    360 on 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.
    370 on 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 
    375 service servicemanager /system/bin/servicemanager
    376     class core
    377     user system
    378     group system
    379     critical
    380     onrestart restart zygote
    381     onrestart restart media
    382 
    383 service vold /system/bin/vold
    384     class core
    385     socket vold stream 0660 root mount
    386     ioprio be 2
    387 
    388 service netd /system/bin/netd
    389     class main
    390     socket netd stream 0660 root system
    391     socket dnsproxyd stream 0660 root inet
    392 
    393 service debuggerd /system/bin/debuggerd
    394     class main
    395 
    396 service 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 
    403 service surfaceflinger /system/bin/surfaceflinger
    404     class main
    405     user system
    406     group graphics
    407     onrestart restart zygote
    408 
    409 service 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 
    417 service drm /system/bin/drmserver
    418     class main
    419     user drm
    420     group system inet drmrpc
    421 
    422 service 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 
    428 service bootanim /system/bin/bootanimation
    429     class main
    430     user graphics
    431     group graphics
    432     disabled
    433     oneshot
    434 
    435 service 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 
    441 service 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 
    450 service installd /system/bin/installd
    451     class main
    452     socket installd stream 600 system system
    453 
    454 service flash_recovery /system/etc/install-recovery.sh
    455     class main
    456     oneshot
    457 
    458 service 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 
    466 service 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 
    474 service keystore /system/bin/keystore /data/misc/keystore
    475     class main
    476     user keystore
    477     group keystore
    478     socket keystore stream 666
    479 
    480 service dumpstate /system/bin/dumpstate -s
    481     class main
    482     socket dumpstate stream 0660 shell log
    483     disabled
    484     oneshot
    485