This repository was archived by the owner on Mar 7, 2021. It is now read-only.
File tree 3 files changed +9
-12
lines changed
3 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ const INCLUDED_FUNCTIONS: &[&str] = &[
23
23
"wait_for_random_bytes" ,
24
24
"get_random_bytes" ,
25
25
"rng_is_initialized" ,
26
+ "printk" ,
26
27
"add_device_randomness" ,
27
28
] ;
28
29
const INCLUDED_VARS : & [ & str ] = & [
Original file line number Diff line number Diff line change 4
4
#include <linux/version.h>
5
5
6
6
7
- int printk_helper (const unsigned char * s , int len )
8
- {
9
- return printk (KERN_INFO "%.*s" , len , (const char * )s );
10
- }
11
-
12
7
void bug_helper (void )
13
8
{
14
9
BUG ();
Original file line number Diff line number Diff line change 1
1
use core:: cmp;
2
2
use core:: fmt;
3
3
4
+ use crate :: bindings;
4
5
use crate :: c_types:: c_int;
5
6
6
- pub struct KernelConsole ;
7
-
8
- extern "C" {
9
- fn printk_helper ( s : * const u8 , len : c_int ) -> c_int ;
10
- }
11
-
12
7
#[ doc( hidden) ]
13
8
pub fn printk ( s : & [ u8 ] ) {
9
+ // Don't copy the trailing NUL from `KERN_INFO`.
10
+ let mut fmt_str = [ 0 ; bindings:: KERN_INFO . len ( ) - 1 + b"%.*s\0 " . len ( ) ] ;
11
+ fmt_str[ ..bindings:: KERN_INFO . len ( ) - 1 ]
12
+ . copy_from_slice ( & bindings:: KERN_INFO [ ..bindings:: KERN_INFO . len ( ) - 1 ] ) ;
13
+ fmt_str[ bindings:: KERN_INFO . len ( ) - 1 ..] . copy_from_slice ( b"%.*s\0 " ) ;
14
+
14
15
// TODO: I believe printk never fails
15
- unsafe { printk_helper ( s . as_ptr ( ) , s. len ( ) as c_int ) } ;
16
+ unsafe { bindings :: printk ( fmt_str . as_ptr ( ) as _ , s. len ( ) as c_int , s . as_ptr ( ) ) } ;
16
17
}
17
18
18
19
// From kernel/print/printk.c
You can’t perform that action at this time.
0 commit comments