欢迎来到Rust for Linux Insides!
Rust for Linux Insides 是华中科技大学开放原子开源俱乐部发起的技术文档项目,聚焦 Rust 语言与 Linux 的深度结合,旨在通过系列技术博客、代码示例、原理解析,帮助开发者理解 Rust for Linux 内部机制,并掌握用 Rust 开发 Linux 内核驱动、优化 Linux 内核模块的方法。
无论是 Linux 内核初学者、Rust 技术实践者,还是开源爱好者,都能从本项目中获取 Rust for Linux 底层原理的清晰解读与 Rust 落地实践的参考案例。
在本项目中,你可以查阅如下三个模块分别获得对应的帮助:
-
- 旨在帮助读者能够更快上手 Rust for Linux 开发,对 Rust for Linux的源码进行详细解释
-
- 本项目会接收任何爱好者投递的博客(通过Pull Request)的方式,在通过评审后会合并到主线中
-
- 旨在跟踪上游 Rust for Linux 社区的开发路线,并且会对一些功能性 PATCH 或 讨论进行解读
-
参考链接
Wiki
博客
新闻
如何贡献 Rust for Linux Insides 项目
本项目主要采用了mdbook进行构建,本节主要介绍了如何在用户本地自行搭建Rust for Linux Insides进行贡献,并介绍贡献的一些规范。
本项目目前只支持Ubuntu/Debian发行版本的构建流程,对于Rocky/Fedora发行版本尚未完成。
安装Rust
- 国内用户
如果国内用户打算构建本项目,并且当前主机上没有rust,那么请参考rsproxy进行安装。
安装成功后,请检查对应版本,本项目要求\( rust \ version \ge 1.46 \)
cargo --version
cargo 1.91.0 (ea2d97820 2025-10-10)
- 国外用户
国外用户请直接参考rust进行安装:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
安装mdbook
安装mdbook cli的方式有多种,本文档主要采用下方介绍的第一种方式,如有其他需要,请参考其他方式。
- 从crate.io中直接安装
cargo install mdbook
- 从github release上下载解压
wget https://github.com/rust-lang/mdBook/releases/download/v0.4.52/mdbook-v0.4.52-x86_64-unknown-linux-gnu.tar.gz
tar zxvf mdbook-v0.4.52-x86_64-unknown-linux-gnu.tar.gz
- 从crate.io中安装最新版本
cargo install --git https://github.com/rust-lang/mdBook.git mdbook
安装完成后,可以通过运行如下命令进行检查:
mdbook --version
mdbook v0.4.52
构建项目
完成上面的依赖安装后(rust和mdbook),读者可以fork本仓库后,进行克隆到本地(此处直接使用了上游仓库,请读者自行更换为对应的仓库链接):
git clone git@github.com:hust-open-atom-club/rust-for-linux-insides.git
cd rust-for-linux-insides
然后可以直接开始构建,或查看构建命令:
make help
Available targets:
build - Build the mdBook
run - Build and serve the book on 0.0.0.0
watch - Watch & rebuild the book on changes
check-ci - Run tests and custom CI checks
clean - Clean build & cargo artifacts
Use 'make <target>' to run a specific action.
使用build命令进行构建:
2025-11-14 03:30:55 [INFO] (mdbook::book): Book building has started
2025-11-14 03:30:55 [INFO] (mdbook::book): Running the html backend
虚拟机配置
如果用户在物理机上构建,那么不需要参考这一小节。 如果使用虚拟机,在有防火墙的情况下无法直接查看到Rust for Linux Insides在浏览器的页面(默认虚拟机是server version with no GUI);因此需要关闭虚拟机防火墙,并将运行的监听ip绑定为“0.0.0.0“
sudo systemctl stop ufw
sudo systemctl disable ufw
使用run命令启动服务:
make run
2025-11-14 03:35:35 [INFO] (mdbook::book): Book building has started
2025-11-14 03:35:35 [INFO] (mdbook::book): Running the html backend
2025-11-14 03:35:35 [INFO] (mdbook::book): Book building has started
2025-11-14 03:35:35 [INFO] (mdbook::book): Running the html backend
2025-11-14 03:35:35 [INFO] (mdbook::cmd::serve): Serving on: http://0.0.0.0:3000
提交代码规范
假设已经做完任何更改,请使用check-ci命令进行检查,以便提交Pull Request时能够通过CI检查。
make check-ci
number of HTML files scanned: 8
number of HTML redirects found: 0
number of links checked: 130
number of links ignored due to external: 10
number of links ignored due to exceptions: 0
number of intra doc links ignored: 0
errors found: 0
Link check completed successfully!
✅ Link checking completed successfully
🎉 All steps executed successfully. 🚀