diff --git a/build.rs b/build.rs index 6034097b..d83cfd71 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,6 @@ -extern crate bindgen; -extern crate cc; -extern crate shlex; +use bindgen; +use cc; +use shlex; use std::env; use std::path::PathBuf; diff --git a/hello-world/src/lib.rs b/hello-world/src/lib.rs index 1799c1ff..e3e9368c 100644 --- a/hello-world/src/lib.rs +++ b/hello-world/src/lib.rs @@ -1,12 +1,11 @@ #![no_std] #![feature(alloc, const_str_as_bytes)] -extern crate alloc; use alloc::borrow::ToOwned; use alloc::string::String; -#[macro_use] -extern crate linux_kernel_module; +use linux_kernel_module; +use linux_kernel_module::println; struct HelloWorldModule { message: String, @@ -28,7 +27,7 @@ impl Drop for HelloWorldModule { } } -kernel_module!( +linux_kernel_module::kernel_module!( HelloWorldModule, author: "Alex Gaynor and Geoffrey Thomas", description: "An extremely simple kernel module", diff --git a/src/filesystem.rs b/src/filesystem.rs index 4b32e1c6..30ba3adf 100644 --- a/src/filesystem.rs +++ b/src/filesystem.rs @@ -3,6 +3,8 @@ use core::default::Default; use core::marker; use core::mem; +use bitflags; + use crate::bindings; use crate::c_types; use crate::error; @@ -24,7 +26,7 @@ pub trait FileSystem { const FLAGS: FileSystemFlags; } -bitflags! { +bitflags::bitflags! { pub struct FileSystemFlags: c_types::c_int { const FS_REQUIRES_DEV = bindings::FS_REQUIRES_DEV as c_types::c_int; const FS_BINARY_MOUNTDATA = bindings::FS_BINARY_MOUNTDATA as c_types::c_int; @@ -34,12 +36,6 @@ bitflags! { } } -impl FileSystemFlags { - pub const fn const_empty() -> FileSystemFlags { - FileSystemFlags { bits: 0 } - } -} - extern "C" fn fill_super_callback( _sb: *mut bindings::super_block, _data: *mut c_types::c_void, diff --git a/src/lib.rs b/src/lib.rs index 6c832827..588bfc23 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,7 @@ #![no_std] -#![feature(allocator_api, const_fn, alloc_error_handler)] +#![feature(allocator_api, alloc_error_handler)] -#[macro_use] extern crate alloc; -#[macro_use] -extern crate bitflags; use core::panic::PanicInfo; @@ -14,7 +11,6 @@ mod c_types; pub mod chrdev; mod error; pub mod filesystem; -#[macro_use] pub mod printk; pub mod sysctl; mod types; @@ -53,7 +49,7 @@ macro_rules! kernel_module { } $( - kernel_module!(@attribute $name, $value); + $crate::kernel_module!(@attribute $name, $value); )* }; diff --git a/src/sysctl.rs b/src/sysctl.rs index 9c429a75..aeb73428 100644 --- a/src/sysctl.rs +++ b/src/sysctl.rs @@ -1,4 +1,5 @@ use alloc::boxed::Box; +use alloc::vec; use core::mem; use core::ptr; use core::sync::atomic; diff --git a/src/user_ptr.rs b/src/user_ptr.rs index b0e5213b..8a3c8095 100644 --- a/src/user_ptr.rs +++ b/src/user_ptr.rs @@ -1,3 +1,4 @@ +use alloc::vec; use alloc::vec::Vec; use core::u32; diff --git a/tests/chrdev/src/lib.rs b/tests/chrdev/src/lib.rs index 9adc989c..b22cfaea 100644 --- a/tests/chrdev/src/lib.rs +++ b/tests/chrdev/src/lib.rs @@ -1,8 +1,7 @@ #![no_std] #![feature(const_str_as_bytes)] -#[macro_use] -extern crate linux_kernel_module; +use linux_kernel_module; struct ChrdevTestModule { _dev: linux_kernel_module::chrdev::DeviceNumberRegion, @@ -19,7 +18,7 @@ impl linux_kernel_module::KernelModule for ChrdevTestModule { } } -kernel_module!( +linux_kernel_module::kernel_module!( ChrdevTestModule, author: "Alex Gaynor and Geoffrey Thomas", description: "A module for testing character devices", diff --git a/tests/chrdev/tests.rs b/tests/chrdev/tests.rs index 2b26ceef..739d1fc6 100644 --- a/tests/chrdev/tests.rs +++ b/tests/chrdev/tests.rs @@ -1,5 +1,3 @@ -extern crate kernel_module_tests; - use kernel_module_tests::with_kernel_module; use std::fs; diff --git a/tests/printk/src/lib.rs b/tests/printk/src/lib.rs index dc0d8f4d..aa77e641 100644 --- a/tests/printk/src/lib.rs +++ b/tests/printk/src/lib.rs @@ -1,8 +1,7 @@ #![no_std] #![feature(const_str_as_bytes)] -#[macro_use] -extern crate linux_kernel_module; +use linux_kernel_module::{self, println}; struct PrintkTestModule; @@ -16,7 +15,7 @@ impl linux_kernel_module::KernelModule for PrintkTestModule { } } -kernel_module!( +linux_kernel_module::kernel_module!( PrintkTestModule, author: "Alex Gaynor and Geoffrey Thomas", description: "A module for testing println!()", diff --git a/tests/printk/tests.rs b/tests/printk/tests.rs index 945235c9..81f6eca0 100644 --- a/tests/printk/tests.rs +++ b/tests/printk/tests.rs @@ -1,5 +1,3 @@ -extern crate kernel_module_tests; - use std::process::Command; use kernel_module_tests::with_kernel_module; diff --git a/tests/run_tests.py b/tests/run_tests.py index f8fae900..b16a3c34 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -59,6 +59,7 @@ def main(): "rustc", "--test", "-Dwarnings", + "--edition", "2018", "--out-dir", os.path.join(BASE_DIR, path), os.path.join(BASE_DIR, path, "tests.rs"), "--extern", "kernel_module_tests=libtestlib.rlib", @@ -76,4 +77,3 @@ def main(): if __name__ == "__main__": main() - diff --git a/tests/sysctl/src/lib.rs b/tests/sysctl/src/lib.rs index 84e9a052..4c256350 100644 --- a/tests/sysctl/src/lib.rs +++ b/tests/sysctl/src/lib.rs @@ -3,8 +3,7 @@ use core::sync::atomic::AtomicBool; -#[macro_use] -extern crate linux_kernel_module; +use linux_kernel_module; use linux_kernel_module::sysctl::Sysctl; use linux_kernel_module::Mode; @@ -33,7 +32,7 @@ impl linux_kernel_module::KernelModule for SysctlTestModule { } } -kernel_module!( +linux_kernel_module::kernel_module!( SysctlTestModule, author: "Alex Gaynor and Geoffrey Thomas", description: "A module for testing sysctls", diff --git a/tests/sysctl/tests.rs b/tests/sysctl/tests.rs index 5ccd7f7f..8848d443 100644 --- a/tests/sysctl/tests.rs +++ b/tests/sysctl/tests.rs @@ -1,5 +1,3 @@ -extern crate kernel_module_tests; - use std::fs; use std::path::Path;