使用 Rust 编写 Linux 内核模块
//! A minimal example defining the system call function
use core::format_args;
use kernel::prelude::*;
use kernel::{Mode, ThisModule};
extern "C" {
static mut STUB_initialize_mod: Option<extern "C" fn() -> i64>;
}
pub extern "C" fn initialize_mod() -> i64 {
pr_info!("Initialize module\n");
100
}
module! {
type: Example,
name: "Example",
author: "Joshie",
description: "System call example",
license: "GPL",
}
struct Example;
impl kernel::Module for Example {
fn init(_name: &'static CStr, _module: &'static ThisModule) -> Result<Self> {
pr_info!("Loaded My example\n");
unsafe {
STUB_initialize_mod = Some(initialize_mod);
}
Ok(Self)
}
}
impl Drop for Example {
fn drop(&mut self) {
pr_info!("Unloaded example\n");
unsafe {
STUB_initialize_mod = None;
}
}
}
ReadMore:https://coderjoshdk.github.io/posts/Rust-Kernel-Programming.html#Everything_you_might_need
Rustup 1.26.0
- 添加 rust-analyzer 作为 rustup 的代理
- 将 clap 从 2.x 升级到 3.x
- ...
Github:https://blog.rust-lang.org/2023/04/25/Rustup-1.26.0.html
GCC 13和GCCRS的状况
GCC 13 版本即将发布,但是 gccrs 不会包含在这个版本中。
ReadMore:https://rust-gcc.github.io/2023/04/24/gccrs-and-gcc13-release.html
From 日报小组 冰山上的 mook && MalikHou
社区学习交流平台订阅:
1
共 0 条评论, 1 页
评论区
写评论还没有评论