mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 08:06:32 +00:00
清理积弊,不必要的动态分发和智能指针
This commit is contained in:
@ -1,14 +1,4 @@
|
||||
# DragonOS Rust-Application Template
|
||||
# test_uevent
|
||||
这是一个测试 uevent 机制的应用,用于测试uevent的功能。
|
||||
|
||||
您可以使用此模板来创建DragonOS应用程序。
|
||||
|
||||
## 使用方法
|
||||
|
||||
1. 使用DragonOS的tools目录下的`bootstrap.sh`脚本初始化环境
|
||||
2. 在终端输入`cargo install cargo-generate`
|
||||
3. 在终端输入`cargo generate --git https://github.com/DragonOS-Community/Rust-App-Template`即可创建项目
|
||||
如果您的网络较慢,请使用镜像站`cargo generate --git https://git.mirrors.dragonos.org/DragonOS-Community/Rust-App-Template`
|
||||
4. 使用`cargo run`来运行项目
|
||||
5. 在DragonOS的`user/dadk/config`目录下,使用`dadk new`命令,创建编译配置,安装到DragonOS的`/`目录下。
|
||||
(在dadk的编译命令选项处,请使用Makefile里面的`make install`配置进行编译、安装)
|
||||
6. 编译DragonOS即可安装
|
||||
执行此测试,将会执行以下操作:
|
||||
|
@ -1,4 +1,4 @@
|
||||
use libc::{sockaddr, sockaddr_storage, recvfrom, bind, sendto, socket, AF_NETLINK, SOCK_DGRAM, SOCK_CLOEXEC, getpid, c_void};
|
||||
use libc::{sockaddr, recvfrom, bind, sendto, socket, AF_NETLINK, SOCK_DGRAM, getpid, c_void};
|
||||
use nix::libc;
|
||||
use std::os::unix::io::RawFd;
|
||||
use std::{ mem, io};
|
||||
@ -14,7 +14,7 @@ struct Nlmsghdr {
|
||||
|
||||
fn create_netlink_socket() -> io::Result<RawFd> {
|
||||
let sockfd = unsafe {
|
||||
socket(AF_NETLINK, SOCK_DGRAM | SOCK_CLOEXEC, libc::NETLINK_KOBJECT_UEVENT)
|
||||
socket(AF_NETLINK, SOCK_DGRAM, libc::NETLINK_KOBJECT_UEVENT)
|
||||
};
|
||||
|
||||
if sockfd < 0 {
|
||||
@ -30,7 +30,7 @@ fn bind_netlink_socket(sock: RawFd) -> io::Result<()> {
|
||||
let mut addr: libc::sockaddr_nl = unsafe { mem::zeroed() };
|
||||
addr.nl_family = AF_NETLINK as u16;
|
||||
addr.nl_pid = pid as u32;
|
||||
addr.nl_groups = 0;
|
||||
addr.nl_groups = 1;
|
||||
|
||||
let ret = unsafe {
|
||||
bind(sock, &addr as *const _ as *const sockaddr, mem::size_of::<libc::sockaddr_nl>() as u32)
|
||||
|
Reference in New Issue
Block a user