From 09148beaed80d2c6911a97de0e9904581f6c4da7 Mon Sep 17 00:00:00 2001 From: chenjiayi Date: Fri, 26 Jan 2024 15:26:34 +0800 Subject: [PATCH 1/2] docs: update path of scripts after directory move --- .../readme.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/docs/use/devmaster\346\233\277\344\273\243udev\350\277\220\350\241\214/readme.md" "b/docs/use/devmaster\346\233\277\344\273\243udev\350\277\220\350\241\214/readme.md" index aadb07a8..20c21add 100644 --- "a/docs/use/devmaster\346\233\277\344\273\243udev\350\277\220\350\241\214/readme.md" +++ "b/docs/use/devmaster\346\233\277\344\273\243udev\350\277\220\350\241\214/readme.md" @@ -24,7 +24,7 @@ Linux localhost.localdomain 5.10.0-60.18.0.50.oe2203.x86_64 #1 SMP Wed Mar 30 03 2. 安装`devmaster`的二进制以及相关配置文件,在`sysmaster`源码根目录下执行如下命令: ```shell - # sh -x tools/run_with_devmaster/install_devmaster.sh [debug|release] + # sh -x docs/use/devmaster替代udev运行/install_devmaster.sh [debug|release] ``` 3. 重启系统,选择`sysmaster`启动项。进入主系统后检查`devmaster`服务状态和网络连通情况。 -- Gitee From 98a7de479aa6da2d499b893fb1b5e5bfc598ab40 Mon Sep 17 00:00:00 2001 From: chenjiayi Date: Fri, 26 Jan 2024 15:27:03 +0800 Subject: [PATCH 2/2] feature(devmaster): add net_driver builtin to be compatible with systemd-udev 255 The net_driver builtin is added to be compatible with systemd-udev 255. Otherwise devmaster would crash when encounterring net_driver builtin in udev rules. --- exts/devmaster/src/lib/builtin/mod.rs | 12 ++++- exts/devmaster/src/lib/builtin/net_driver.rs | 56 ++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 exts/devmaster/src/lib/builtin/net_driver.rs diff --git a/exts/devmaster/src/lib/builtin/mod.rs b/exts/devmaster/src/lib/builtin/mod.rs index 259ebd13..30ad9031 100644 --- a/exts/devmaster/src/lib/builtin/mod.rs +++ b/exts/devmaster/src/lib/builtin/mod.rs @@ -34,6 +34,7 @@ pub mod hwdb; pub mod input_id; pub mod keyboard; pub mod kmod; +pub mod net_driver; pub mod net_id; pub mod net_setup_link; pub mod path_id; @@ -108,8 +109,9 @@ pub enum BuiltinCommand { PathId = 8, Uaccess = 9, UsbId = 10, - Example = 11, - Max = 12, + NetDriver = 11, + Example = 12, + Max = 13, } impl FromStr for BuiltinCommand { @@ -135,6 +137,7 @@ impl FromStr for BuiltinCommand { "path_id" => Ok(BuiltinCommand::PathId), "uaccess" => Ok(BuiltinCommand::Uaccess), "usb_id" => Ok(BuiltinCommand::UsbId), + "net_driver" => Ok(BuiltinCommand::NetDriver), "example" => Ok(BuiltinCommand::Example), _ => Err(Error::BuiltinCommandError { msg: "invalid builtin command".to_string(), @@ -157,6 +160,7 @@ impl Display for BuiltinCommand { BuiltinCommand::PathId => "path_id", BuiltinCommand::Uaccess => "uaccess", BuiltinCommand::UsbId => "usb_id", + BuiltinCommand::NetDriver => "net_driver", BuiltinCommand::Example => "example", _ => "invalid", }; @@ -190,6 +194,10 @@ impl BuiltinManager { builtins.insert(BuiltinCommand::PathId, Box::new(path_id::PathId {})); builtins.insert(BuiltinCommand::Uaccess, Box::new(uaccess::Uaccess {})); builtins.insert(BuiltinCommand::UsbId, Box::new(usb_id::UsbId {})); + builtins.insert( + BuiltinCommand::NetDriver, + Box::new(net_driver::NetDriver {}), + ); builtins.insert(BuiltinCommand::Example, Box::new(example::Example {})); BuiltinManager { builtins } diff --git a/exts/devmaster/src/lib/builtin/net_driver.rs b/exts/devmaster/src/lib/builtin/net_driver.rs new file mode 100644 index 00000000..83e6398e --- /dev/null +++ b/exts/devmaster/src/lib/builtin/net_driver.rs @@ -0,0 +1,56 @@ +// Copyright (c) 2022 Huawei Technologies Co.,Ltd. All rights reserved. +// +// sysMaster is licensed under Mulan PSL v2. +// You can use this software according to the terms and conditions of the Mulan +// PSL v2. +// You may obtain a copy of Mulan PSL v2 at: +// http://license.coscl.org.cn/MulanPSL2 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +// See the Mulan PSL v2 for more details. + +//! net_driver builtin +//! +//! Todo: compatible with udev + +use crate::builtin::Builtin; +use crate::error::Result; +use crate::rules::exec_unit::ExecuteUnit; + +/// btrfs builtin command +pub struct NetDriver; + +impl Builtin for NetDriver { + /// builtin command + fn cmd( + &self, + _exec_unit: &ExecuteUnit, + _argc: i32, + _argv: Vec, + _test: bool, + ) -> Result { + Ok(true) + } + + /// builtin init function + fn init(&self) {} + + /// builtin exit function + fn exit(&self) {} + + /// check whether builtin command should reload + fn should_reload(&self) -> bool { + false + } + + /// the help of builtin command + fn help(&self) -> String { + "detect network interface driver".to_string() + } + + /// whether the builtin command can only run once + fn run_once(&self) -> bool { + false + } +} -- Gitee