1# ueventd 2 3## Overview 4 5The **ueventd** module listens for **netlink** events about hot plug of kernel device drivers and dynamically manages the dev node of the corresponding device based on the event type. 6 7## Configuration Files of ueventd 8 9### File Type 10 11The configuration files of the **ueventd** module are stored in the **/base/startup/init/ueventd/etc/** directory. They are classified into three types: **device**, **sysfs**, and **firmware**. 12 13Currently, the **ueventd** module uses configuration files of the **device** type. If needed, set DAC permissions for a created node in such files. 14 15File types are distinguished by the field at the beginning of the file. The following uses **device** as an example: 16 ``` 17 [device] # File type. 18 # <device name> <mode> <uid> <gid> <parameter> 19 /dev/null 0666 0 0 20 ``` 21 22### Configuration File Description 23 24 - The configuration file of the **ueventd** module is named **ueventd.config**. 25 26 - The file consists of five fields, for example: 27 28 ``` 29 /dev/null 0666 0 0 30 /dev/binder 0666 0 0 31 /dev/hwbinder 0666 0 0 32 /dev/vndbinder 0666 0 0 33 /dev/input/event* 0660 0 input 34 ``` 35 36 **Fields in the Configuration File** 37 | Field | Description | 38 | ----------- | ---------------- | 39 | device name | Device node name. | 40 | mode | Permission granted to a device node in compliance with the UGO model.| 41 | uid | UID of a device node.| 42 | gid | GID of a device node.| 43 | parameter | Device node parameter information, which is similar to a notification. If a device is created, a corresponding parameter is set so that other processes can perform operations on the node based on the parameter information.<br>/dev/null 0666 0 0 device_null<br>Take the **dev/null** node as as example:<br>When the device node is created, this field is set to **startup.uevent.device_null "added"**; when the device node is removed, this field is set to **startup.uevet.device_null "removed"**.| 44 45 - Remarks 46 47 The nodes of the boot partition may vary according to devices. Therefore, you can configure soft link permissions in the **ueventd.config** file to change the permissions of the corresponding physical device node. 48 These nodes are stored in the **/dev/block/by-name** directory. 49 50 ``` 51 lrwxrwxrwx 1 root root 20 2017-08-10 16:22 boot_linux -> /dev/block/mmcblk0p5 52 lrwxrwxrwx 1 root root 20 2017-08-10 16:22 bootctrl -> /dev/block/mmcblk0p3 53 lrwxrwxrwx 1 ueventd ueventd 21 2017-08-10 16:22 chip-prod -> /dev/block/mmcblk0p10 54 lrwxrwxrwx 1 root root 20 2017-08-10 16:22 misc -> /dev/block/mmcblk0p2 55 lrwxrwxrwx 1 root root 20 2017-08-10 16:22 ramdisk -> /dev/block/mmcblk0p6 56 lrwxrwxrwx 1 ueventd ueventd 20 2017-08-10 16:22 resource -> /dev/block/mmcblk0p4 57 lrwxrwxrwx 1 ueventd ueventd 20 2017-08-10 16:22 sys-prod -> /dev/block/mmcblk0p9 58 lrwxrwxrwx 1 root root 20 2017-08-10 16:22 system -> /dev/block/mmcblk0p7 59 lrwxrwxrwx 1 root root 20 2017-08-10 16:22 uboot -> /dev/block/mmcblk0p1 60 lrwxrwxrwx 1 ueventd ueventd 21 2017-08-10 16:22 updater -> /dev/block/mmcblk0p11 61 lrwxrwxrwx 1 ueventd ueventd 21 2017-08-10 16:22 userdata -> /dev/block/mmcblk0p12 62 lrwxrwxrwx 1 root root 20 2017-08-10 16:22 vendor -> /dev/block/mmcblk0p8 63 ``` 64 65 Configuration example: 66 67 ``` 68 /dev/block/by-name/misc 0660 update update 69 /dev/block/by-name/bootctrl 0660 update update 70 ``` 71 72### Setting the SELinux Tag of a Device Node 73 74 The SELinux tags of device nodes are set in the **/base/security/selinux_adapter/sepolicy/base/system/file_contexts** file. If the SELinux tag of a device node is not set, the node inherits the SELinux tag of its parent directory. 75 76 - Defining node tags 77 ``` 78 /dev/block(/.*)? u:object_r:dev_block_file:s0 79 /dev/block/zram0 u:object_r:zram_device:s0 80 ``` 81 82 - Viewing the SELinux tag of the device node by using the **ls -Zl** command 83 84 ``` 85 # ls -Zl 86 total 0 87 lrwxrwxrwx 1 root root u:object_r:dev_block_file:s0 20 2017-08-10 16:22 boot_linux -> /dev/block/mmcblk0p5 88 lrwxrwxrwx 1 root root u:object_r:dev_block_file:s0 20 2017-08-10 16:22 bootctrl -> /dev/block/mmcblk0p3 89 lrwxrwxrwx 1 ueventd ueventd u:object_r:dev_block_file:s0 21 2017-08-10 16:22 chip-prod -> /dev/block/mmcblk0p10 90 lrwxrwxrwx 1 root root u:object_r:dev_block_file:s0 20 2017-08-10 16:22 misc -> /dev/block/mmcblk0p2 91 lrwxrwxrwx 1 root root u:object_r:dev_block_file:s0 20 2017-08-10 16:22 ramdisk -> /dev/block/mmcblk0p6 92 lrwxrwxrwx 1 ueventd ueventd u:object_r:dev_block_file:s0 20 2017-08-10 16:22 resource -> /dev/block/mmcblk0p4 93 lrwxrwxrwx 1 ueventd ueventd u:object_r:dev_block_file:s0 20 2017-08-10 16:22 sys-prod -> /dev/block/mmcblk0p9 94 lrwxrwxrwx 1 root root u:object_r:dev_block_file:s0 20 2017-08-10 16:22 system -> /dev/block/mmcblk0p7 95 lrwxrwxrwx 1 root root u:object_r:dev_block_file:s0 20 2017-08-10 16:22 uboot -> /dev/block/mmcblk0p1 96 lrwxrwxrwx 1 ueventd ueventd u:object_r:dev_block_file:s0 21 2017-08-10 16:22 updater -> /dev/block/mmcblk0p11 97 lrwxrwxrwx 1 ueventd ueventd u:object_r:dev_block_file:s0 21 2017-08-10 16:22 userdata -> /dev/block/mmcblk0p12 98 lrwxrwxrwx 1 root root u:object_r:dev_block_file:s0 20 2017-08-10 16:22 vendor -> /dev/block/mmcblk0p8 99 ``` 100