- FreeBSD machine
- Rust nightly
- Xargo
I recommend using rustup
for installing and handling different versions of Rust.
Rust
Xargo
$ cargo install xargo
Setting Rust nightly
Do in crate root:
$ rustup override set nightly
This folder is the Cargo
root for the module itself.
Here are all the dependency crates that are not available on crates.io.
core
is built and handled completely by Xargo
.
Copied from Rust source code, unmodified.
Copied from Rust source code, unmodified.
Copied from Rust source code, unmodified.
Copied from Rust source code.
Added kern_malloc.rs
which is the FFI bindings to kernel's malloc functions.
Modified lib.rs
to use said functions.
A minimal implementation of std for the echo module. FFI bindings are generated on build. Safe bindings exists for things necessary for this code to run.
Check build.sh
script if you like to make any changes then run
$ ./build.sh
If build was successful there should be a hello.ko
file in the root folder. Load with
$ sudo kldload ./hello.ko
$ cat /dev/rustmodule
Default Message :)
$ echo Hello > /dev/rustmodule
Read 6 bytes. Setting new message to "Hello\n"
$ cat /dev/rustmodule
Hello
$ sudo kldunload hello
If there are any bugs or faulty code the kernel will most likely hang.
I recommend testing the module in a virtual machine.
It keeps your system safe and it makes it easier to develop and test.