This repository was archived by the owner on Mar 7, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +9
-12
lines changed Expand file tree Collapse file tree 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] = &[
2323 "wait_for_random_bytes" ,
2424 "get_random_bytes" ,
2525 "rng_is_initialized" ,
26+ "printk" ,
2627 "add_device_randomness" ,
2728] ;
2829const INCLUDED_VARS : & [ & str ] = & [
Original file line number Diff line number Diff line change 44#include <linux/version.h>
55
66
7- int printk_helper (const unsigned char * s , int len )
8- {
9- return printk (KERN_INFO "%.*s" , len , (const char * )s );
10- }
11-
127void bug_helper (void )
138{
149 BUG ();
Original file line number Diff line number Diff line change 11use core:: cmp;
22use core:: fmt;
33
4+ use crate :: bindings;
45use crate :: c_types:: c_int;
56
6- pub struct KernelConsole ;
7-
8- extern "C" {
9- fn printk_helper ( s : * const u8 , len : c_int ) -> c_int ;
10- }
11-
127#[ doc( hidden) ]
138pub 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+
1415 // 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 ( ) ) } ;
1617}
1718
1819// From kernel/print/printk.c
You can’t perform that action at this time.
0 commit comments