mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 16:33:24 +00:00
Add init_component for mlsdisk
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
f6e040ec94
commit
04be02efb7
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -151,6 +151,7 @@ dependencies = [
|
|||||||
"aes-gcm",
|
"aes-gcm",
|
||||||
"aster-block",
|
"aster-block",
|
||||||
"bittle",
|
"bittle",
|
||||||
|
"component",
|
||||||
"ctr",
|
"ctr",
|
||||||
"hashbrown 0.14.5",
|
"hashbrown 0.14.5",
|
||||||
"inherit-methods-macro",
|
"inherit-methods-macro",
|
||||||
|
@ -8,6 +8,7 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
inherit-methods-macro = {git = "https://github.com/asterinas/inherit-methods-macro", rev = "98f7e3e"}
|
inherit-methods-macro = {git = "https://github.com/asterinas/inherit-methods-macro", rev = "98f7e3e"}
|
||||||
ostd-pod = { git = "https://github.com/asterinas/ostd-pod", rev = "c4644be", version = "0.1.1" }
|
ostd-pod = { git = "https://github.com/asterinas/ostd-pod", rev = "c4644be", version = "0.1.1" }
|
||||||
|
component = { path = "../../libs/comp-sys/component" }
|
||||||
aster-block = { path = "../block" }
|
aster-block = { path = "../block" }
|
||||||
ostd = { path = "../../../ostd" }
|
ostd = { path = "../../../ostd" }
|
||||||
# Enable `force-soft` feature to disable `AES-NI` and `CLMUL` intrinsics, ensuring that the implementation
|
# Enable `force-soft` feature to disable `AES-NI` and `CLMUL` intrinsics, ensuring that the implementation
|
||||||
|
@ -16,7 +16,7 @@ mod util;
|
|||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use alloc::{sync::Arc, vec};
|
use alloc::{string::ToString, sync::Arc, vec};
|
||||||
use core::ops::Range;
|
use core::ops::Range;
|
||||||
|
|
||||||
use aster_block::{
|
use aster_block::{
|
||||||
@ -24,6 +24,7 @@ use aster_block::{
|
|||||||
id::Sid,
|
id::Sid,
|
||||||
BlockDevice, SECTOR_SIZE,
|
BlockDevice, SECTOR_SIZE,
|
||||||
};
|
};
|
||||||
|
use component::{init_component, ComponentInitError};
|
||||||
use ostd::{mm::VmIo, prelude::*};
|
use ostd::{mm::VmIo, prelude::*};
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
@ -36,6 +37,20 @@ pub use self::{
|
|||||||
util::{Aead as _, RandomInit, Rng as _},
|
util::{Aead as _, RandomInit, Rng as _},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[init_component]
|
||||||
|
fn init() -> core::result::Result<(), ComponentInitError> {
|
||||||
|
// FIXME: add a virtio-blk-pci device in qemu and a image file.
|
||||||
|
let Some(device) = aster_block::get_device("raw_mlsdisk") else {
|
||||||
|
return Err(ComponentInitError::Unknown);
|
||||||
|
};
|
||||||
|
let raw_disk = RawDisk::new(device);
|
||||||
|
let root_key = AeadKey::random();
|
||||||
|
let device =
|
||||||
|
MlsDisk::create(raw_disk, root_key, None).map_err(|_| ComponentInitError::Unknown)?;
|
||||||
|
aster_block::register_device("mlsdisk".to_string(), Arc::new(device));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
struct RawDisk {
|
struct RawDisk {
|
||||||
inner: Arc<dyn BlockDevice>,
|
inner: Arc<dyn BlockDevice>,
|
||||||
|
Reference in New Issue
Block a user