This repository was archived by the owner on Mar 7, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ macro_rules! kernel_module {
66
66
} ;
67
67
}
68
68
69
- pub trait KernelModule : Sized {
69
+ pub trait KernelModule : Sized + Sync {
70
70
fn init ( ) -> KernelResult < Self > ;
71
71
}
72
72
Original file line number Diff line number Diff line change @@ -9,12 +9,6 @@ use error;
9
9
use types;
10
10
use user_ptr:: { UserSlicePtr , UserSlicePtrWriter } ;
11
11
12
- pub struct Sysctl < T : SysctlStorage > {
13
- inner : Box < T > ,
14
- table : Box < [ bindings:: ctl_table ] > ,
15
- header : * mut bindings:: ctl_table_header ,
16
- }
17
-
18
12
pub trait SysctlStorage : Sync {
19
13
fn store_value ( & self , data : & [ u8 ] ) -> ( usize , error:: KernelResult < ( ) > ) ;
20
14
fn read_value ( & self , data : & mut UserSlicePtrWriter ) -> ( usize , error:: KernelResult < ( ) > ) ;
@@ -60,6 +54,16 @@ impl SysctlStorage for atomic::AtomicBool {
60
54
}
61
55
}
62
56
57
+ pub struct Sysctl < T : SysctlStorage > {
58
+ inner : Box < T > ,
59
+ table : Box < [ bindings:: ctl_table ] > ,
60
+ header : * mut bindings:: ctl_table_header ,
61
+ }
62
+
63
+ // This is safe because the only public method we have is get(), which returns
64
+ // &T, and T: Sync. Any new methods must adhere to this requirement.
65
+ unsafe impl < T : SysctlStorage > Sync for Sysctl < T > { }
66
+
63
67
unsafe extern "C" fn proc_handler < T : SysctlStorage > (
64
68
ctl : * mut bindings:: ctl_table ,
65
69
write : c_types:: c_int ,
You can’t perform that action at this time.
0 commit comments