init.rc到底在做些什么
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
当我们只是按下电源键开机时,会进入正常启动模式。 Secondary stage bootloader 会从boot 分区开始启动。Boot 分区的格式是固定的,首先是一个头部,然后是 Linux 内核,最后是用作根文件系统的 ramdisk。
当 Linux 内核启动完毕后,就开始执行根文件系统中的 init 程序,init 程序会读取启动脚本文件(init.rc 和init.goldfish)。
现在就来说一下,init.rc到底在做些什么,我会在附件上传有关init_rc脚本语法和自己阅读是坐下到笔记,希望对各位有所帮助。
复制代码
++++++++++++++++++++++++++++++++++++++++语法+++++++++++++++++++++++++++++++++++++++++++++++++++
当 Linux 内核启动完毕后,就开始执行根文件系统中的 init 程序,init 程序会读取启动脚本文件(init.rc 和init.goldfish)。
现在就来说一下,init.rc到底在做些什么,我会在附件上传有关init_rc脚本语法和自己阅读是坐下到笔记,希望对各位有所帮助。
- on boot-pause
- exec sbin/chargerlogo #运行sbin/chargerlogo(此运行在内核目录下)
- on early-init
- start ueventd #调用sbin/uventd链接所指的可执行程序,其源码位于system/core/init/ueventd.c,为设备赋予权限
- on init #源码位于system/core/init/init.c
- #主要完成一下的工作
- #清空umask、创建并挂载一些基本的目录(/dev-设备、/proc-系统信息、/sys-系统信息、/dev/pts-终端控制字,用于执行adb、/dev/socket)
- sysclktz 0 #把硬件时钟当成本地时间(GMT时区)
- loglevel 3 #讲系统LOG设置成可见,0为(NONE)
- write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "performance"
- # setup the global environment 设置全局变量
- export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin #PATH变量
- export LD_LIBRARY_PATH /vendor/lib:/system/lib #库
- export ANDROID_BOOTLOGO 1
- export ANDROID_CACHE /cache #cache目录
- export ANDROID_ROOT /system #安卓系统root分区-->/system
- export ANDROID_ASSETS /system/app #安卓系统可访问到-->/system/app(这就是为什么没有root权限不能删除/system/app下到文件)
- export ANDROID_DATA /data #安卓data区
- export DOWNLOAD_CACHE /cache/download #下载缓存为/cache/download
- export EXTERNAL_STORAGE /mnt/sdcard #附加存储-->sdcard卡
- export ASEC_MOUNTPOINT /mnt/asec #asec根文件目录
- export LOOP_MOUNTPOINT /mnt/obb
- export SD_EXT_DIRECTORY /sd-ext #sdcard挂载格式
- 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 #bootclasspath
- export DSP_PATH /system/lib/dsp #dsp(数字信号处理器) path
- export DEFAULT_BASEIMAGE /system/lib/dsp/baseimage.dof
- export QOSDYN_FILE /system/lib/dsp/qosdyn_3430.dll64P
- # Backward compatibility #反向兼容,确保对以前版本到兼容?(不缺定)
- symlink /system/etc /etc #在/etc下创建链接到/system/etc到链接
- symlink /sys/kernel/debug /d
- # Right now vendor lives on the same filesystem as system,
- # but someday that may change.
- symlink /system/vendor /vendor
- # create mountpoints
- mkdir /mnt 0775 root system
- #给system赋予0775的权限,也就是rwx-rwx-rw-现在详细解释如下
- #此权限数值对应为:
- #u(用户):r(读)-w(写)-x(执行)
- #g(群组):r(读)-w(写)-x(执行)
- #0(其他):r(读)-w(写)-
- #对应到2进制数值为:
- #1 1 1 :111 ---7
- #1 1 1 :111 ---7
- #1 1 0 :110 ---5
- #
- mkdir /mnt/sdcard 0000 system system
- # Create cgroup mount point for cpu accounting #为cpu创建
- mkdir /acct
- mount cgroup none /acct cpuacct
- mkdir /acct/uid
- # Backwards Compat - XXX: Going away in G*
- symlink /mnt/sdcard /sdcard
- mkdir /system
- mkdir /data 0771 system system
- mkdir /cache 0771 system cache
- mkdir /config 0500 root root
- mkdir /sqlite_stmt_journals 01777 root root
- mount tmpfs tmpfs /sqlite_stmt_journals size=4m
- # Directory for putting things only root should see.#创建用于存放root用户才能可见到文件夹
- mkdir /mnt/secure 0700 root root
- # Directory for staging bindmounts #伺服器根文件目录
- mkdir /mnt/secure/staging 0700 root root
- # Directory-target for where the secure container
- # imagefile directory will be bind-mounted
- mkdir /mnt/secure/asec 0700 root root
- # Secure container public mount points.
- mkdir /mnt/asec 0700 root system
- mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
- # Filesystem image public mount points.
- mkdir /mnt/obb 0700 root system
- mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
- mkdir /sd-ext 0771 system system
- write /proc/sys/kernel/panic_on_oops 1
- write /proc/sys/kernel/hung_task_timeout_secs 0
- write /proc/cpu/alignment 4
- write /proc/sys/kernel/sched_latency_ns 10000000
- write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
- write /proc/sys/kernel/sched_compat_yield 1
- write /proc/sys/kernel/sched_child_runs_first 0
- # Create cgroup mount points for process groups
- mkdir /dev/cpuctl
- mount cgroup none /dev/cpuctl cpu
- chown system system /dev/cpuctl
- chown system system /dev/cpuctl/tasks
- chmod 0777 /dev/cpuctl/tasks
- write /dev/cpuctl/cpu.shares 1024
- mkdir /dev/cpuctl/fg_boost
- chown system system /dev/cpuctl/fg_boost/tasks
- chmod 0777 /dev/cpuctl/fg_boost/tasks
- write /dev/cpuctl/fg_boost/cpu.shares 1024
- mkdir /dev/cpuctl/bg_non_interactive
- chown system system /dev/cpuctl/bg_non_interactive/tasks
- chmod 0777 /dev/cpuctl/bg_non_interactive/tasks
- # 5.0 %
- write /dev/cpuctl/bg_non_interactive/cpu.shares 52
- #[LGE_start] hyunwoong.ahn
- mkdir /dvp 0771 system system
- mkdir /dvp/hwkey 0771 system system
- mkdir /dvp/userdata 0771 system system
- #[LGE_end] hyunwoong.ahn
- chown system system /sys/class/leds/lcd-backlight/als
- # Increase readahead buffers on MMC devices
- write /sys/block/mmcblk0/bdi/read_ahead_kb 1024
- write /sys/block/mmcblk1/bdi/read_ahead_kb 1024
- on fs
- # mount mtd partitions
- # Mount /system rw first to give the filesystem a chance to save a checkpoint
- mount ext4 /dev/block/mmcblk0p8 /system ro noatime barrier=1 wait
- # We chown/chmod /data again so because mount is run as root + defaults
- mount ext4 /dev/block/mmcblk0p9 /data nosuid nodev noatime barrier=1 wait
- chown system system /data
- chmod 0771 /data
- #[LGE_star]Hyunwoong.ahn^M
- mount ext3 /dev/block/mmcblk0p6 /dvp/hwkey nosuid nodev
- chown system system /dvp/hwkey
- chown system divxdrm /dvp/hwkey/key.hw
- chmod 0660 /dvp/hwkey/key.hw
- mount ext3 /dev/block/mmcblk0p6 /dvp/userdata nosuid nodev
- chown system divxdrm /dvp/userdata
- chmod 0770 /dvp/userdata
- chown system system /dev/block/mmcblk0p5
- chown system system /dev/block/mmcblk0p12
- chmod 0777 /dev/block/mmcblk0p5
- chmod 0777 /dev/block/mmcblk0p12
- mount ext4 /dev/block/mmcblk0p10 /cache nosuid nodev noatime barrier=1 wait
- mkdir /lgdrm 0770 lgdrm lgdrm_acc
- mount ext3 /dev/block/mmcblk0p5 /lgdrm nosuid nodev
- on post-fs
- # once everything is setup, no need to modify /
- mount rootfs rootfs / ro remount
- # We chown/chmod /data again so because mount is run as root + defaults
- chown system system /data
- chmod 0771 /data
- # Mount compressed filesystems
- mount squashfs loop@/system/lib/modules/modules.sqf /system/lib/modules ro
- mount squashfs loop@/system/xbin/xbin.sqf /system/xbin ro
- # Create dump dir and collect dumps.
- # Do this before we mount cache so eventually we can use cache for
- # storing dumps on platforms which do not have a dedicated dump partition.
-
- mkdir /data/dontpanic
- chown root log /data/dontpanic
- chmod 0750 /data/dontpanic
- # Collect apanic data, free resources and re-arm trigger
- copy /proc/apanic_console /data/dontpanic/apanic_console
- chown root log /data/dontpanic/apanic_console
- chmod 0640 /data/dontpanic/apanic_console
- copy /proc/apanic_threads /data/dontpanic/apanic_threads
- chown root log /data/dontpanic/apanic_threads
- chmod 0640 /data/dontpanic/apanic_threads
- write /proc/apanic_console 1
- # Same reason as /data above
- chown system cache /cache
- chmod 0771 /cache
- # This may have been created by the recovery system with odd permissions
- chown system cache /cache/recovery
- chmod 0770 /cache/recovery
- #change permissions on vmallocinfo so we can grab it from bugreports
- chown root log /proc/vmallocinfo
- chmod 0440 /proc/vmallocinfo
- #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
- chown root system /proc/kmsg
- chmod 0440 /proc/kmsg
- chown root system /proc/sysrq-trigger
- chmod 0220 /proc/sysrq-trigger
- # create basic filesystem structure
- mkdir /data/misc 01771 system misc
- mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
- mkdir /data/misc/bluetooth 0770 system system
- mkdir /data/misc/keystore 0700 keystore keystore
- mkdir /data/misc/vpn 0770 system system
- mkdir /data/misc/systemkeys 0700 system system
- mkdir /data/misc/vpn/profiles 0770 system system
- # give system access to wpa_supplicant.conf for backup and restore
- mkdir /data/misc/wifi 0770 wifi wifi
- chmod 0770 /data/misc/wifi
- chmod 0660 /data/misc/wifi/wpa_supplicant.conf
- mkdir /data/local 0771 shell shell
- mkdir /data/local/tmp 0771 shell shell
- mkdir /data/local/download 0771 system cache
- mkdir /data/data 0771 system system
- mkdir /data/app-private 0771 system system
- mkdir /data/app 0771 system system
- mkdir /data/property 0700 root root
- mkdir /cache/download 0771 system cache
- # create dalvik-cache and double-check the perms
- mkdir /data/dalvik-cache 0771 system system
- chown system system /data/dalvik-cache
- chmod 0771 /data/dalvik-cache
- mkdir /cache/dalvik-cache 0771 system system
- chown system system /cache/dalvik-cache
- chmod 0771 /cache/dalvik-cache
- # create the lost+found directories, so as to enforce our permissions
- mkdir /data/lost+found 0770
- mkdir /cache/lost+found 0770
- # double check the perms, in case lost+found already exists, and set owner
- chown root root /data/lost+found
- chmod 0770 /data/lost+found
- chown root root /cache/lost+found
- chmod 0770 /cache/lost+found
- # allow net_raw to have access to /dev/socket directory
- chown root net_raw /dev/socket
- chmod 0775 /dev/socket
- # allow system to modify cpufreq control files
- chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
- chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
- chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
- chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
- chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- chmod 0777 /data/misc/wifi/config_mac
- mkdir /data/misc/wifi/sockets 0770 wifi wifi
- mkdir /data/misc/dhcp 0777 dhcp dhcp
- setprop wifi.supplicant_scan_interval 20
- setprop wifi.interface wlan0
- on boot
- # basic network init
- ifup lo
- hostname localhost
- domainname localdomain
- # set RLIMIT_NICE to allow priorities from 19 to -20
- setrlimit 13 40 40
- # Define the oom_adj values for the classes of processes that can be
- # killed by the kernel. These are used in ActivityManagerService.
- setprop ro.FOREGROUND_APP_ADJ 0
- setprop ro.VISIBLE_APP_ADJ 1
- setprop ro.PERCEPTIBLE_APP_ADJ 2
- setprop ro.HEAVY_WEIGHT_APP_ADJ 3
- setprop ro.SECONDARY_SERVER_ADJ 4
- setprop ro.BACKUP_APP_ADJ 5
- setprop ro.HOME_APP_ADJ 6
- setprop ro.HIDDEN_APP_MIN_ADJ 7
- setprop ro.EMPTY_APP_ADJ 15
- # Define the memory thresholds at which the above process classes will
- # be killed. These numbers are in pages (4k).
- setprop ro.FOREGROUND_APP_MEM 2048
- setprop ro.VISIBLE_APP_MEM 3072
- setprop ro.PERCEPTIBLE_APP_MEM 4096
- setprop ro.HEAVY_WEIGHT_APP_MEM 4096
- setprop ro.SECONDARY_SERVER_MEM 6144
- setprop ro.BACKUP_APP_MEM 6144
- setprop ro.HOME_APP_MEM 6144
- setprop ro.HIDDEN_APP_MEM 7168
- setprop ro.EMPTY_APP_MEM 8192
- # Write value must be consistent with the above properties.
- # Note that the driver only supports 6 slots, so we have combined some of
- # the classes into the same memory level; the associated processes of higher
- # classes will still be killed first.
- write /sys/module/lowmemorykiller/parameters/adj 0,1,2,4,7,15
- write /proc/sys/vm/overcommit_memory 1
- write /proc/sys/vm/min_free_order_shift 4
- write /sys/module/lowmemorykiller/parameters/minfree 2048,3072,4096,6144,7168,8192
- # Set init its forked children's oom_adj.
- write /proc/1/oom_adj -16
- # Tweak background writeout
- write /proc/sys/vm/dirty_expire_centisecs 200
- write /proc/sys/vm/dirty_background_ratio 5
- # Permissions for System Server and daemons.
- chown radio system /sys/android_power/state
- chown radio system /sys/android_power/request_state
- chown radio system /sys/android_power/acquire_full_wake_lock
- chown radio system /sys/android_power/acquire_partial_wake_lock
- chown radio system /sys/android_power/release_wake_lock
- chown radio system /sys/power/state
- chown radio system /sys/power/wake_lock
- chown radio system /sys/power/wake_unlock
- chmod 0660 /sys/power/state
- chmod 0660 /sys/power/wake_lock
- chmod 0660 /sys/power/wake_unlock
- chown system system /sys/class/timed_output/vibrator/enable
- chown system system /sys/class/leds/keyboard-backlight/brightness
- chown system system /sys/class/leds/lcd-backlight/brightness
- chown system system /sys/class/leds/button-backlight/brightness
- chown system system /sys/class/leds/jogball-backlight/brightness
- chown system system /sys/class/leds/red/brightness
- chown system system /sys/class/leds/green/brightness
- chown system system /sys/class/leds/blue/brightness
- chown system system /sys/class/leds/red/device/grpfreq
- chown system system /sys/class/leds/red/device/grppwm
- chown system system /sys/class/leds/red/device/blink
- chown system system /sys/class/leds/red/brightness
- chown system system /sys/class/leds/green/brightness
- chown system system /sys/class/leds/blue/brightness
- chown system system /sys/class/leds/red/device/grpfreq
- chown system system /sys/class/leds/red/device/grppwm
- chown system system /sys/class/leds/red/device/blink
- chown system system /sys/class/timed_output/vibrator/enable
- chown system system /sys/module/sco/parameters/disable_esco
- chown system system /sys/kernel/ipv4/tcp_wmem_min
- chown system system /sys/kernel/ipv4/tcp_wmem_def
- chown system system /sys/kernel/ipv4/tcp_wmem_max
- chown system system /sys/kernel/ipv4/tcp_rmem_min
- chown system system /sys/kernel/ipv4/tcp_rmem_def
- chown system system /sys/kernel/ipv4/tcp_rmem_max
- chown root radio /proc/cmdline
- # Define TCP buffer sizes for various networks
- # ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
- setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
- setprop net.tcp.buffersize.wifi 4095,87380,110208,4096,16384,110208
- setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208
- setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040
- setprop net.tcp.buffersize.hspa 4094,87380,110208,4096,16384,110208
- setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680
- chmod 0660 /sys/class/rfkill/rfkill0/state
- chmod 0660 /sys/class/rfkill/rfkill0/type
- chmod 0660 /sys/class/rfkill/rfkill1/state
- chmod 0660 /sys/class/rfkill/rfkill1/type
- chmod 0666 /sys/devices/platform/bd_address/bdaddr_if
- chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state
- chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type
- chown bluetooth bluetooth /sys/class/rfkill/rfkill1/state
- chown bluetooth bluetooth /sys/class/rfkill/rfkill1/type
- write /sys/class/rfkill/rfkill0/state 0
- chown system system /sys/devices/platform/motion_sensor/accel_onoff
- chown system system /sys/devices/platform/motion_sensor/accel_delay
- chown system system /sys/devices/platform/motion_sensor/compass_onoff
- chown system system /sys/devices/platform/motion_sensor/compass_delay
- chown system system /sys/devices/platform/motion_sensor/tilt_onoff
- chown system system /sys/devices/platform/motion_sensor/tilt_delay
- chown system system /sys/devices/platform/motion_sensor/gyro_onoff
- chown system system /sys/devices/platform/motion_sensor/gyro_delay
- chown system system /sys/bus/i2c/drivers/hub_proxi/3-0044/onoff
- chown system system /sys/bus/i2c/drivers/hub_proxi/3-0044/delay
- chown system system /sys/devices/platform/motion_sensor/shake_onoff
- chown system system /sys/bus/i2c/drivers/kxtf9/3-000f/shake_onoff
- chown system system /sys/devices/platform/motion_sensor/snap_onoff
- chown system system /sys/bus/i2c/drivers/kxtf9/3-000f/snap_onoff
- chown system system /sys/devices/platform/motion_sensor/flip_onoff
- chown system system /sys/bus/i2c/drivers/kxtf9/3-000f/flip_onoff
- chown system system /sys/devices/platform/motion_sensor/tap_onoff
- chown system system /sys/bus/i2c/drivers/kxtf9/3-000f/tap_onoff
- chown system system /sys/devices/platform/motion_sensor/yawimage_onoff
- chown system system /sys/devices/platform/i2c-gpio.7/i2c-adapter/i2c-7/7-001c/checkresult
- chown system system /sys/devices/platform/i2c-gpio.7/i2c-adapter/i2c-7/7-001c/checkopmode
- chmod 0666 /sys/devices/platform/motion_sensor/accel_onoff
- chmod 0666 /sys/devices/platform/motion_sensor/accel_delay
- chmod 0666 /sys/devices/platform/motion_sensor/compass_onoff
- chmod 0666 /sys/devices/platform/motion_sensor/compass_delay
- chmod 0666 /sys/devices/platform/motion_sensor/tilt_onoff
- chmod 0666 /sys/devices/platform/motion_sensor/tilt_delay
- chmod 0666 /sys/devices/platform/motion_sensor/gyro_onoff
- chmod 0666 /sys/devices/platform/motion_sensor/gyro_delay
- chmod 0666 /sys/bus/i2c/drivers/hub_proxi/3-0044/onoff
- chmod 0666 /sys/bus/i2c/drivers/hub_proxi/3-0044/delay
- chmod 0666 /sys/devices/platform/motion_sensor/shake_onoff
- chmod 0666 /sys/bus/i2c/drivers/kxtf9/3-000f/shake_onoff
- chmod 0666 /sys/devices/platform/motion_sensor/snap_onoff
- chmod 0666 /sys/bus/i2c/drivers/kxtf9/3-000f/snap_onoff
- chmod 0666 /sys/devices/platform/motion_sensor/flip_onoff
- chmod 0666 /sys/bus/i2c/drivers/kxtf9/3-000f/flip_onoff
- chmod 0666 /sys/devices/platform/motion_sensor/tap_onoff
- chmod 0666 /sys/bus/i2c/drivers/kxtf9/3-000f/tap_onoff
- chmod 0666 /sys/devices/platform/motion_sensor/yawimage_onoff
- chmod 0666 /sys/devices/platform/i2c-gpio.7/i2c-adapter/i2c-7/7-001c/checkresult
- chmod 0666 /sys/devices/platform/i2c-gpio.7/i2c-adapter/i2c-7/7-001c/checkopmode
- chmod 0666 /sys/devices/platform/omapdss/display0/name
- chmod 0666 /sys/devices/platform/omapdss/display1/name
- chmod 0666 /sys/devices/platform/omapdss/display0/enabled
- chmod 0666 /sys/devices/platform/omapdss/display1/enabled
- chmod 0666 /sys/devices/platform/omapdss/display0/timings
- chmod 0666 /sys/devices/platform/omapdss/display1/timings
- chmod 0666 /sys/devices/platform/omapdss/overlay0/manager
- chmod 0666 /sys/devices/platform/omapdss/overlay1/manager
- chmod 0666 /sys/devices/platform/omapdss/overlay2/manager
- chmod 0666 /sys/devices/platform/omapdss/overlay0/zorder
- chmod 0666 /sys/devices/platform/omapdss/overlay1/zorder
- chmod 0666 /sys/devices/platform/omapdss/overlay2/zorder
- chmod 0666 /sys/devices/platform/omapdss/overlay0/enabled
- chmod 0666 /sys/devices/platform/omapdss/overlay1/enabled
- chmod 0666 /sys/devices/platform/omapdss/overlay2/enabled
- chmod 0666 /sys/devices/platform/omapdss/manager0/display
- chmod 0666 /sys/devices/platform/omapdss/manager1/display
- chmod 0666 /sys/devices/platform/omapdss/manager0/trans_key_enabled
- chmod 0666 /sys/devices/platform/omapdss/manager1/trans_key_enabled
- chmod 0666 /sys/devices/platform/omapdss/manager0/trans_key_type
- chmod 0666 /sys/devices/platform/omapdss/manager1/trans_key_type
- chmod 0666 /sys/devices/platform/omapdss/manager0/trans_key_value
- chmod 0666 /sys/devices/platform/omapdss/manager1/trans_key_value
- chmod 0666 /sys/devices/platform/omapdss/manager0/alpha_blending_enabled
- chmod 0666 /sys/devices/platform/omapdss/manager1/alpha_blending_enabled
- write /sys/devices/platform/omapdss/manager0/alpha_blending_enabled 1
- # MMS: Create log directory for fw3a_core
- mkdir /data/log/fw3A 0775 root root
- # change permissions for alsa nodes
- symlink /dev/snd/pcmC0D0c /dev/pcmC0D0c
- symlink /dev/snd/pcmC0D0p /dev/pcmC0D0p
- symlink /dev/snd/controlC0 /dev/controlC0
- symlink /dev/snd/timer /dev/timer
- chmod 0777 /dev/pcmC0D0c
- chmod 0777 /dev/pcmC0D0p
- chmod 0777 /dev/controlC0
- chmod 0777 /dev/timer
- chmod 0664 /sys/devices/platform/i2c_omap.2/i2c-2/2-0060/leds/lcd-backlight/als
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-0060/leds/lcd-backlight/als
- # Batt gauge error detection
- chmod 0666 /sys/bus/platform/drivers/twl4030_bci/twl4030_bci/gauge_if
- # Enabling sleep in idle path
- write /sys/power/sleep_while_idle 1
- # Enabling Off mode
- write /sys/power/enable_off_mode 1
- # Enabling voltage off while idle
- write /sys/power/voltage_off_while_idle 1
- # Permissions for setting the DSP Frequency
- chown media root /sys/power/dsp_freq
- chown media system /sys/devices/platform/omap3isp/isp_reserve
- # Include extra init file
- import /system/etc/init.local.rc
- # gps permissions
- chown system system /sys/devices/platform/hub_gps_gpio/poweron
- chown system system /sys/devices/platform/hub_gps_gpio/reset
- mkdir /data/gps
- chmod 777 /data/gps
- mkdir /data/gps/var
- chmod 777 /data/gps/var
- mkdir /data/gps/var/run
- chmod 777 /data/gps/var/run
- mkdir /data/gps/log
- chmod 777 /data/gps/log
- mkdir /data/cache
- chmod 777 /data/cache
- ## Torch perms
- chown system camera /sys/class/leds/rt8515/brightness
- chmod 0660 /sys/class/leds/rt8515/brightness
- ## liblights
- chown system system /sys/class/leds/lcd-backlight/brightness
- chown system system /sys/class/leds/lcd-backlight/onoff
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/led_brightness
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/led_onoff
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/led_sync
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/blink_enable
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/0x06
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/0x07
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/0x0D
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/0x0E
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/0x10
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/0x11
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/0x03
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/0x04
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/0x09
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/0x0A
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/0x13
- chown system system /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/0x14
- # Run sysinit
- exec /system/bin/sysinit
- class_start default
- ## Daemon processes to be run by init.
- ##
- service ueventd /sbin/ueventd
- critical
- service prb /sbin/prb
- user root
- disabled
- oneshot
- keycodes 114 116
- service console /system/bin/sh
- console
- disabled
- user shell
- group log
- on property:ro.secure=0
- start console
- # adbd is controlled by the persist.service.adb.enable system property
- service adbd /sbin/adbd
- disabled
- # adbd on at boot in emulator
- on property:ro.kernel.qemu=1
- start adbd
- on property:persist.service.adb.enable=1
- start adbd
- on property:persist.service.adb.enable=0
- stop adbd
- service pvrsrvinit /system/bin/pvrsrvinit
- user root
- oneshot
- # load DSP firmware 防火墙
- service baseimage /system/bin/cexec.out /system/lib/dsp/baseimage.dof
- user root
- group audio
- oneshot
- service fw3a /system/bin/fw3a_core --dbgport=6660 --dbgremote --dbgpath=/data/log/fw3A
- user root
- group root
- service servicemanager /system/bin/servicemanager
- user system
- critical
- onrestart restart zygote
- onrestart restart media
- service vold /system/bin/vold
- socket vold stream 0660 root mount
- ioprio be 2
- service netd /system/bin/netd
- socket netd stream 0660 root system
- socket dnsproxyd stream 0660 root inet
- service debuggerd /system/bin/debuggerd
- service ril-daemon /system/bin/rild
- socket rild stream 660 root radio
- socket rild-debug stream 660 radio system
- user root
- group radio cache inet misc audio sdcard_rw net_admin net_raw
- service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
- socket zygote stream 666
- onrestart write /sys/android_power/request_state wake
- onrestart write /sys/power/state on
- onrestart restart media
- onrestart restart netd
- service media /system/bin/mediaserver
- user media
- group system audio camera graphics inet net_bt net_bt_admin net_raw
- ioprio rt 4
- service bootanim /system/bin/bootanimation
- user graphics
- group graphics
- disabled
- oneshot
- service dbus /system/bin/dbus-daemon --system --nofork
- socket dbus stream 660 bluetooth bluetooth
- user bluetooth
- group bluetooth net_bt_admin
- service bluetoothd /system/bin/bluetoothd -n
- socket bluetooth stream 660 bluetooth bluetooth
- socket dbus_bluetooth stream 660 bluetooth bluetooth
- # init.rc does not yet support applying capabilities, so run as root and
- # let bluetoothd drop uid to bluetooth with the right linux capabilities
- group bluetooth net_bt_admin misc
- disabled
- service hfag /system/bin/sdptool add --channel=10 HFAG
- user bluetooth
- group bluetooth net_bt_admin
- disabled
- oneshot
- service hsag /system/bin/sdptool add --channel=11 HSAG
- user bluetooth
- group bluetooth net_bt_admin
- disabled
- oneshot
- service opush /system/bin/sdptool add --channel=12 OPUSH
- user bluetooth
- group bluetooth net_bt_admin
- disabled
- oneshot
- service pbap /system/bin/sdptool add --channel=19 PBAP
- user bluetooth
- group bluetooth net_bt_admin
- disabled
- oneshot
- service installd /system/bin/installd
- socket installd stream 600 system system
- service racoon /system/bin/racoon
- socket racoon stream 600 system system
- # racoon will setuid to vpn after getting necessary resources.
- group net_admin
- disabled
- oneshot
- service mtpd /system/bin/mtpd
- socket mtpd stream 600 system system
- user vpn
- group vpn net_admin net_raw
- disabled
- oneshot
- service keystore /system/bin/keystore /data/misc/keystore
- user keystore
- group keystore
- socket keystore stream 666
- service dumpstate /system/bin/dumpstate -s
- socket dumpstate stream 0660 shell log
- disabled
- oneshot
- #开启GPS服务,配置文件位置位于:/system/etc/gps_brcm_conf.xml
- service glgps /system/bin/glgps -c /system/etc/gps_brcm_conf.xml
- user root
- group system
- on property:dev.bootcomplete=1
- write /sys/devices/platform/i2c_omap.2/i2c-2/2-001a/blink_enable 0
- write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "interactive"
- #write /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold 90
- #write /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate 40000
- write /sys/devices/system/cpu/cpu0/cpufreq/turn_on_lg_dvfs 1
- service dhcpcd_wlan0 /system/bin/dhcpcd -BKA wlan0
- disabled
- oneshot
- service iprenew_wlan0 /system/bin/dhcpcd -n wlan0
- disabled
- oneshot
- on property:init.svc.wpa_supplicant=stopped
- stop dhcpcd_wlan0
- service wpa_supplicant /system/bin/wpa_supplicant -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf #-dd
- socket wpa_wlan0 dgram 660 wifi wifi
- group system wifi inet
- disabled
- service hciattach /system/bin/brcm_patchram_plus --enable_hci --enable_lpm \
- --baudrate 3000000 --patchram /etc/firmware/BCM43291A0_003.001.013.0066.xxxx_B-Project.hcd /dev/ttyO1
- user bluetooth
- group bluetooth net_bt_admin
- disabled
- service rawip_vsnet1 /system/bin/init.vsnet 1
- user root
- group radio cache inet misc
- disabled
- oneshot
- service wlan_precheck /system/bin/wlan-precheck
- oneshot
++++++++++++++++++++++++++++++++++++++++语法+++++++++++++++++++++++++++++++++++++++++++++++++++
- system/core/init/readme.txt(此文也是对init.rc 的解释)内容不同:
- socket <name> <type> <perm> [ <user> [ <group> ] ]
- -----------------------------------------------
- 注1:另外还讲述了怎样输出log:
- Debugging notes
- ---------------
- By default, programs executed by init will drop stdout and stderr into
- /dev/null. To help with debugging, you can execute your program via the
- Andoird program logwrapper. This will redirect stdout/stderr into the
- Android logging system (accessed via logcat).
- For example
- service akmd /system/bin/logwrapper /sbin/akmd
- 注2:讲述了一个新的命令
- sysclktz <mins_west_of_gmt>
- Set the system clock base (0 if system clock ticks in GMT)
- 注3:triggers
- boot
- This is the first trigger that will occur when init starts
- (after /init.conf is loaded)
- <name>=<value>
- Triggers of this form occur when the property <name> is set
- to the specific value <value>.
- device-added-<path>
- device-removed-<path>
- Triggers of these forms occur when a device node is added
- or removed.
- service-exited-<name>
- Triggers of this form occur when the specified service exits.
- ------------------------------------------
- init 由如下四种类型语句组成:
- Actionn :行为
- Commands
- Services
- Options
- 语法(language syntax)结构如下:
- 每一个语句占据一行,并且各个关键字被空格分开。c规范中的(如 /n)反斜杠将被忽略(backslash escapes)而被认为是一个空格 ,双引号用来保证空格不会把一个文字串分分为多个关键字。行最后的反斜杠用作续行。
- 由 # (前面允许有空格)开始的行都是注释行(comment)
- 一个actions 或 services 的开始隐含声明了一个新的段,所有commands 或 options 属于最近的声明。在第一个段之前的 commands 或 options 都会被忽略
- 每一个actions 和 services 都有不同的名字。后面与前面发生重名的,那么这个后面重名的将被忽略或被认为是一个错误
- Actions
- Actions其实就是一组被命名的命令序列。actions 都有一个触发条件,触发条件决定了action何时执行。当一个事件发生如果匹配action的触发条件,那么这个action将会被添加到预备执行队列的尾部(除非它已经在队列当中)
- 每一个action中的命令将被顺序执行。init进程负责在其它activities(如:设备创建/销毁,属性设置,进程重启)之间执行这些命令序列。
- action 的格式如下
- on <trigger>
- <command>
- <command>
- <command>
- Services
- services 是一些由init 启动 和 重新(如果有需要)启动的程序,当然这些程序如果是存在的。
- services 的格式如下:
- service <name> <pathname> [ <argument> ]*
- <option>
- <option>
- ...
- Options
- options 是service的修饰符,用来告诉init 怎样及何时启动service。
- Option Description
- disabled This service will not automatically start with its class. It must be explicitly started by name.
- socket <type> <name> <perm> [ <user> [ <group> ] ]
- Create a unix domain socket named /dev/socket/<name> and pass its fd to the launched process. Valid <type>dgram and stream. user and group default to 0.(type 实际中是放在name之后)
- values include
- user <username> Change to username before exec'ing this service. Currently defaults to root.
- group <groupname> [ <groupname> ]* Change to groupname before exec'ing this service. Additional groupnames beyond the first, which is required, are used to set additional groups of the process (with setgroups()). Currently defaults to root.
- capability [ <capability> ]+ Set linux capability before exec'ing this service
- oneshot Do not restart the service when it exits.
- class <name> Specify a class name for the service. All services in a named class must start and stop together. A service is considered of class "default" if one is not specified via the class option.
- Triggers
- Triggers are strings used to match certain kinds of events that cause an action to occur.
- Trigger Description
- boot This is the first trigger that occurs when init starts (after /init.conf is loaded).
- <name>=<value> Triggers of this form occur when the property <name> is set to the specific value <value>.
- device-added-<path>
- device-removed-<path> Triggers of these forms occur when a device node is added or removed.
- service-exited-<name> Triggers of this form occur when the specified service exits.
- Commands
- Command Description
- exec <path> [ <argument> ]* Fork and execute a program (<path>). This will block until the program completes execution. Try to avoid exec. Unlike the builtin commands, it runs the risk of getting init "stuck".
- export <name> <value> Set the environment variable <name> equal to <value> in the global environment (which will be inherited by all processes started after this command is executed).
- ifup <interface> Bring the network interface <interface> online.
- import <filename> Parse an init config file, extending the current configuration.
- hostname <name> Set the host name.
- class_start <serviceclass> Start all services of the specified class if they are not already running.
- class_stop <serviceclass> Stop all services of the specified class if they are currently running.
- domainname <name> Set the domain name.
- insmod <path> Install the module at <path>.
- mkdir <path> Make a directory at <path>.
- mount <type> <device> <dir> [ <mountoption> ]* Attempt to mount the named device at the directory <dir> <device>. This may be of the form mtd@name to specify a mtd block device by name.
- setkey - currenlty undefined -
- setprop <name> <value> Set system property <name> to <value>.
- setrlimit <resource> <cur> <max> Set the rlimit for a resource.
- start <service> Start a service running if it is not already running.
- stop <service> Stop a service from running if it is currently running.
- symlink <target> <path> Create a symbolic link at <path> with the value <target>.
- write <path> <string> [ <string> ]* Open the file at <path> and write one or more strings to it with write(2).
- Properties
- Init updates some system properties to provide some insight into
- what it's doing:
- Property Description
- init.action Equal to the name of the action currently being executed or "" if none.
- init.command Equal to the command being executed or "" if none.
- init.svc.<name> State of a named service ("stopped", "running", or "restarting").
- 在init.rc中使用属性的范例如下:
- setprop ro.FOREGROUND_APP_MEM 1536
- setprop ro.VISIBLE_APP_MEM 2048
- on property:ro.kernel.qemu=1
- start adbd
- setprop用于设置属性,on property可以用于判断属性,这里的属性在整个Android系统运行中都是一致的。
- init脚本中的关键字可以参考:system/core/init/keywords.h
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献2条内容
所有评论(0)