mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 08:26:30 +00:00
Add init_component for mlsdisk
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
f6e040ec94
commit
04be02efb7
@ -8,6 +8,7 @@ edition = "2021"
|
||||
[dependencies]
|
||||
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" }
|
||||
component = { path = "../../libs/comp-sys/component" }
|
||||
aster-block = { path = "../block" }
|
||||
ostd = { path = "../../../ostd" }
|
||||
# Enable `force-soft` feature to disable `AES-NI` and `CLMUL` intrinsics, ensuring that the implementation
|
||||
|
@ -16,7 +16,7 @@ mod util;
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::{sync::Arc, vec};
|
||||
use alloc::{string::ToString, sync::Arc, vec};
|
||||
use core::ops::Range;
|
||||
|
||||
use aster_block::{
|
||||
@ -24,6 +24,7 @@ use aster_block::{
|
||||
id::Sid,
|
||||
BlockDevice, SECTOR_SIZE,
|
||||
};
|
||||
use component::{init_component, ComponentInitError};
|
||||
use ostd::{mm::VmIo, prelude::*};
|
||||
|
||||
pub use self::{
|
||||
@ -36,6 +37,20 @@ pub use self::{
|
||||
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)]
|
||||
struct RawDisk {
|
||||
inner: Arc<dyn BlockDevice>,
|
||||
|
Reference in New Issue
Block a user