1.uevent介绍
Uevent是内核通知android有状态变化的一种方法,比如USB线插入、拔出,电池电量变化等等。其本质是内核发送(可以通过socket)一个字符串,应用层(android)接收并解释该字符串,获取相应信息。
路径:
system/core/init/ueventd.cpp
imx8 uevent说明:
At a high level, ueventd listens for uevent messages generated by the kernel through a netlink
socket. When ueventd receives such a message it handles it by taking appropriate actions,
which can typically be creating a device node in /dev, setting file permissions, setting selinux
labels, etc.
Ueventd also handles loading of firmware that the kernel requests, and creates symlinks for block
and character devices.
When ueventd starts, it regenerates uevents for all currently registered devices by traversing
/sys and writing 'add' to each 'uevent' file that it finds. This causes the kernel to generate
and resend uevent messages for all of the currently registered devices. This is done, because
ueventd would not have been running when these devices were registered and therefore was unable
to receive their uevent messages and handle them appropriately. This process is known as
'cold boot'.
'init' currently waits synchronously on the cold boot process of ueventd before it continues
its boot process. For this reason, cold boot should be as quick as possible. One way to achieve
a speed up here is to parallelize the handling of ueventd messages, which consume the bulk of the
time during cold boot.
Handling of uevent messages has two unique properties:
1) It can be done in isolation; it doesn't need to read or write any status once it is started.
2) It uses setegid() and setfscre
UEVENTD详解

本文深入解析UEVENTD的工作原理,包括其在内核与应用层间传输状态变化信息的机制,如USB线插拔和电池电量变化。UEVENTD不仅处理设备节点创建、文件权限设置及SELinux标签设定,还负责固件加载和设备符号链接创建。文章详细介绍了UEVENTD的冷启动过程,如何并行处理UEVENT消息以加速启动,以及在冷启动过程中高效处理SELinux restorecon。
最低0.47元/天 解锁文章
2万+

被折叠的 条评论
为什么被折叠?



