use vmi_core::{Va, VmiError, VmiState, VmiVa, driver::VmiRead};
use super::{macros::impl_offsets, path::LinuxPath};
use crate::{ArchAdapter, LinuxOs};
pub struct LinuxFsStruct<'a, Driver>
where
Driver: VmiRead,
Driver::Architecture: ArchAdapter<Driver>,
{
vmi: VmiState<'a, LinuxOs<Driver>>,
va: Va,
}
impl<Driver> VmiVa for LinuxFsStruct<'_, Driver>
where
Driver: VmiRead,
Driver::Architecture: ArchAdapter<Driver>,
{
fn va(&self) -> Va {
self.va
}
}
impl<'a, Driver> LinuxFsStruct<'a, Driver>
where
Driver: VmiRead,
Driver::Architecture: ArchAdapter<Driver>,
{
impl_offsets!();
pub fn new(vmi: VmiState<'a, LinuxOs<Driver>>, va: Va) -> Self {
Self { vmi, va }
}
pub fn root(&self) -> Result<LinuxPath<'a, Driver>, VmiError> {
let offsets = self.offsets();
let __fs_struct = &offsets.fs_struct;
Ok(LinuxPath::new(
self.vmi,
self.va + __fs_struct.root.offset(),
))
}
pub fn pwd(&self) -> Result<LinuxPath<'a, Driver>, VmiError> {
let offsets = self.offsets();
let __fs_struct = &offsets.fs_struct;
Ok(LinuxPath::new(self.vmi, self.va + __fs_struct.pwd.offset()))
}
}