vmi_os_linux/comps/
fs_struct.rs1use vmi_core::{Va, VmiError, VmiState, VmiVa, driver::VmiRead};
2
3use super::{macros::impl_offsets, path::LinuxPath};
4use crate::{ArchAdapter, LinuxOs};
5
6pub struct LinuxFsStruct<'a, Driver>
17where
18 Driver: VmiRead,
19 Driver::Architecture: ArchAdapter<Driver>,
20{
21 vmi: VmiState<'a, LinuxOs<Driver>>,
23
24 va: Va,
26}
27
28impl<Driver> VmiVa for LinuxFsStruct<'_, Driver>
29where
30 Driver: VmiRead,
31 Driver::Architecture: ArchAdapter<Driver>,
32{
33 fn va(&self) -> Va {
34 self.va
35 }
36}
37
38impl<'a, Driver> LinuxFsStruct<'a, Driver>
39where
40 Driver: VmiRead,
41 Driver::Architecture: ArchAdapter<Driver>,
42{
43 impl_offsets!();
44
45 pub fn new(vmi: VmiState<'a, LinuxOs<Driver>>, va: Va) -> Self {
47 Self { vmi, va }
48 }
49
50 pub fn root(&self) -> Result<LinuxPath<'a, Driver>, VmiError> {
56 let offsets = self.offsets();
57 let __fs_struct = &offsets.fs_struct;
58
59 Ok(LinuxPath::new(
60 self.vmi,
61 self.va + __fs_struct.root.offset(),
62 ))
63 }
64
65 pub fn pwd(&self) -> Result<LinuxPath<'a, Driver>, VmiError> {
71 let offsets = self.offsets();
72 let __fs_struct = &offsets.fs_struct;
73
74 Ok(LinuxPath::new(self.vmi, self.va + __fs_struct.pwd.offset()))
75 }
76}