|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| export_include/ | | 12-May-2024 | - | 207 | 119 |
| hm_src/ | | 12-May-2024 | - | 1,661 | 1,616 |
| hwdb/ | | 12-May-2024 | - | 267,899 | 179,326 |
| m4/ | | 12-May-2024 | - | 9,070 | 8,198 |
| man/ | | 12-May-2024 | - | 2,886 | 2,640 |
| rule_generator/ | | 12-May-2024 | - | 506 | 334 |
| rules/ | | 12-May-2024 | - | 705 | 513 |
| rules.d/ | | 12-May-2024 | - | 6 | 5 |
| src/ | | 12-May-2024 | - | 34,690 | 24,268 |
| test/ | | 12-May-2024 | - | 2,330 | 2,047 |
| .gitattributes | D | 12-May-2024 | 631 | 16 | 15 |
| BUILD.gn | D | 12-May-2024 | 5 KiB | 228 | 191 |
| COPYING | D | 12-May-2024 | 17.6 KiB | 340 | 281 |
| Makefile.am | D | 12-May-2024 | 259 | 26 | 20 |
| OAT.xml | D | 12-May-2024 | 6.4 KiB | 96 | 40 |
| README.OpenSource | D | 12-May-2024 | 436 | 12 | 11 |
| README_zh.md | D | 12-May-2024 | 2.5 KiB | 77 | 66 |
| aclocal.m4 | D | 12-May-2024 | 51.1 KiB | 1,418 | 1,283 |
| bundle.json | D | 12-May-2024 | 927 | 34 | 34 |
| compile | D | 12-May-2024 | 7.2 KiB | 349 | 259 |
| config.guess | D | 12-May-2024 | 43.2 KiB | 1,478 | 1,286 |
| config.h.in | D | 12-May-2024 | 8.6 KiB | 335 | 234 |
| config.sub | D | 12-May-2024 | 36.1 KiB | 1,867 | 1,726 |
| configure | D | 12-May-2024 | 668.3 KiB | 22,259 | 18,811 |
| configure.ac | D | 12-May-2024 | 12.1 KiB | 368 | 307 |
| depcomp | D | 12-May-2024 | 23 KiB | 792 | 502 |
| install-sh | D | 12-May-2024 | 15 KiB | 519 | 337 |
| ltmain.sh | D | 12-May-2024 | 317.8 KiB | 11,201 | 8,096 |
| missing | D | 12-May-2024 | 6.7 KiB | 216 | 143 |
| test-driver | D | 12-May-2024 | 4.5 KiB | 149 | 87 |
| udevd.rc | D | 12-May-2024 | 148 | 8 | 7 |
README.OpenSource
README_zh.md
1# eudev
2eudev 是一个通用的内核设备管理器。它运行在用户空间, 在Linux 系统上作为守护程序运行,并侦听(通过 netlink 套接字)在初始化新设备或从系统中删除设备时内核发出的内容。通过其提供的规则与事件的导出值和发现设备的属性匹配,命名并创建设备节点,并运行已配置的程序来设置和配置设备。
3
4每当设备结构发生变化时,内核都会发出一个由设备管理器获取的 uevent ,然后设备管理器查找声明的规则,根据uevent中包含的信息,它会找到触发和执行所需操作所需的规则。这些动作可能涉及设备文件的创建或删除,还可能触发将特定固件文件加载到内核内存中。
5
6## 目录结构
7
8```
9README.md 英文说明
10README_zh.md 中文说明
11COPYING 版权文件
12hwdb/ 硬件数据库文件
13rules.d/ 规则文件
14export_include/ 导出头文件
15src/ C++源码
16test/ 测试文件
17man/ 帮助文件
18```
19
20## OpenHarmony如何集成libudev
21### 1.头文件引入
22```cpp
23#include "libudev.h"
24```
25### 2.BUILD.gn添加引用
26```cpp
27deps += [ "//third_party/eudev:libudev" ]
28```
29### 3.调用udev函数过程举例
30```cpp
31#include <stdio.h>
32#include "libudev.h"
33
34void test_device(struct udev *udev, const char *syspath)
35{
36 struct udev_device *device;
37 printf("looking at device: %s\n", syspath);
38 device = udev_device_new_from_syspath(udev, syspath);
39 if (device == NULL) {
40 printf("no device found\n");
41 return;
42 }
43 printf("*** device: %p ***\n", device);
44 const char *str = udev_device_get_devnode(device);
45 if (str != NULL) {
46 printf("devname: '%s'\n", str);
47 }
48 dev_t devnum = udev_device_get_devnum(device);
49 if (major(devnum) > 0) {
50 printf("devnum: %u:%u\n", major(devnum), minor(devnum));
51 }
52 udev_device_unref(device);
53}
54
55int main(int argc, char *argv[])
56{
57 struct udev *udev = udev_new();
58 printf("udev context: %p\n", udev);
59 if (udev == NULL) {
60 printf("no context\n");
61 return 1;
62 }
63 const char *path = "/sys/devices/virtual/mem/null";
64 test_device(udev, path);
65 udev_unref(udev);
66 return 0;
67}
68```
69
70## udev使用文档
71
72官方文档 https://github.com/eudev-project/eudev
73
74## COPYING
75
76见 [COPYING](COPYING).
77