-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlkm.rs
37 lines (28 loc) · 834 Bytes
/
lkm.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: GPL-2.0
//! Rust LKM Template
mod module;
use module::test;
use kernel::prelude::*;
module! {
type: RustLkmTemplate,
name: "rust_lkm_template",
author: "Pablo Alessando Santos Hugen",
description: "Rust KLM Template",
license: "GPL",
}
struct RustLkmTemplate(&'static str);
impl kernel::Module for RustLkmTemplate {
fn init(_name: &'static CStr, _module: &'static ThisModule) -> Result<Self> {
let message: &'static str = "Hello World!";
test();
pr_info!("Rust LKM Template (init)\n");
pr_info!("Am I built-in? {}\n", !cfg!(MODULE));
Ok(RustLkmTemplate(message))
}
}
impl Drop for RustLkmTemplate {
fn drop(&mut self) {
pr_info!("My message is: {}\n", self.0);
pr_info!("Rust LKM Template (exit)\n");
}
}