• Home
Name Date Size #Lines LOC

..--

export_include/12-May-2024-207119

hm_src/12-May-2024-1,6611,616

hwdb/12-May-2024-267,899179,326

m4/12-May-2024-9,0708,198

man/12-May-2024-2,8862,640

rule_generator/12-May-2024-506334

rules/12-May-2024-705513

rules.d/12-May-2024-65

src/12-May-2024-34,69024,268

test/12-May-2024-2,3302,047

.gitattributesD12-May-2024631 1615

BUILD.gnD12-May-20245 KiB228191

COPYINGD12-May-202417.6 KiB340281

Makefile.amD12-May-2024259 2620

OAT.xmlD12-May-20246.4 KiB9640

README.OpenSourceD12-May-2024436 1211

README_zh.mdD12-May-20242.5 KiB7766

aclocal.m4D12-May-202451.1 KiB1,4181,283

bundle.jsonD12-May-2024927 3434

compileD12-May-20247.2 KiB349259

config.guessD12-May-202443.2 KiB1,4781,286

config.h.inD12-May-20248.6 KiB335234

config.subD12-May-202436.1 KiB1,8671,726

configureD12-May-2024668.3 KiB22,25918,811

configure.acD12-May-202412.1 KiB368307

depcompD12-May-202423 KiB792502

install-shD12-May-202415 KiB519337

ltmain.shD12-May-2024317.8 KiB11,2018,096

missingD12-May-20246.7 KiB216143

test-driverD12-May-20244.5 KiB14987

udevd.rcD12-May-2024148 87

README.OpenSource

1[
2  {
3   "Name":"eudev",
4   "License":"GPL V2.0/LGPL V2.0",
5   "License File":"COPYING",
6   "Version Number":"3.2.10",
7   "Owner":"pengfei.hou@huawei.com",
8   "Upstream URL":"https://github.com/gentoo/eudev",
9   "Description": "This git repo is a fork of git://anongit.freedesktop.org/systemd/systemd with the aim of isolating udev from any particular flavor of system initialization. In this case, the isolation is from systemd"
10  }
11]
12

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