Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

Commit 4b4dfa6

Browse files
committed
Fixes #18 -- call the kerne's BUG macro when we panic
1 parent f7443bf commit 4b4dfa6

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/helpers.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
#include <linux/bug.h>
12
#include <linux/printk.h>
23

34
int printk_helper(const unsigned char *s, int len)
45
{
5-
return printk(KERN_INFO "%.*s", len, (const char *)s);
6+
return printk(KERN_INFO "%.*s", len, (const char *)s);
7+
}
8+
9+
void bug_helper(void)
10+
{
11+
BUG();
612
}

src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,18 @@ pub trait KernelModule: Sized {
6464
fn init() -> KernelResult<Self>;
6565
}
6666

67+
extern "C" {
68+
fn bug_helper() -> !;
69+
}
70+
6771
#[lang = "eh_personality"]
6872
extern "C" fn eh_personality() {}
6973

7074
#[lang = "panic_fmt"]
7175
extern "C" fn panic_fmt() -> ! {
72-
loop {}
76+
unsafe {
77+
bug_helper();
78+
}
7379
}
7480

7581
#[global_allocator]

0 commit comments

Comments
 (0)