[VFS] Skeleton for moving victoria falls to rust.
This commit is contained in:
parent
59efb1659a
commit
a806e41af0
11 changed files with 130 additions and 3 deletions
31
rust/lib/client/denali_client/src/disk_reader.rs
Normal file
31
rust/lib/client/denali_client/src/disk_reader.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use mammoth::{cap::Capability, zion::ZError};
|
||||
|
||||
use crate::{DenaliClient, DiskBlock, ReadRequest};
|
||||
|
||||
pub struct DiskReader {
|
||||
client: DenaliClient,
|
||||
disk_id: u64,
|
||||
lba_offset: u64,
|
||||
}
|
||||
|
||||
impl DiskReader {
|
||||
pub fn new(client: DenaliClient, disk_id: u64, lba_offset: u64) -> Self {
|
||||
Self {
|
||||
client,
|
||||
disk_id,
|
||||
lba_offset,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read(&mut self, lba: u64, cnt: u64) -> Result<Capability, ZError> {
|
||||
let read_resp = self.client.read(&ReadRequest {
|
||||
device_id: self.disk_id,
|
||||
block: DiskBlock {
|
||||
lba: self.lba_offset + lba,
|
||||
size: cnt,
|
||||
},
|
||||
})?;
|
||||
|
||||
Ok(Capability::take(read_resp.memory))
|
||||
}
|
||||
}
|
||||
|
|
@ -3,3 +3,7 @@
|
|||
use core::include;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/yunq.rs"));
|
||||
|
||||
mod disk_reader;
|
||||
|
||||
pub use disk_reader::DiskReader;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue