Skip to content

Commit 9ed5155

Browse files
committed
Adds mnt_stat
1 parent ae34788 commit 9ed5155

File tree

6 files changed

+34
-8
lines changed

6 files changed

+34
-8
lines changed

kernel-1100/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use self::file::File;
44
use self::lock::{LockObject, Mtx};
55
use self::malloc::Malloc;
6-
use self::mount::{Filesystem, Mount};
6+
use self::mount::{Filesystem, FsStats, Mount};
77
use self::pcpu::Pcpu;
88
use self::socket::Socket;
99
use self::thread::Thread;
@@ -47,6 +47,7 @@ impl okf::Kernel for Kernel {
4747

4848
type File = File;
4949
type Filesystem = Filesystem;
50+
type FsStats = FsStats;
5051
type LockObject = LockObject;
5152
type Malloc = Malloc;
5253
type Mount = Mount;

kernel-1100/src/mount.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ pub struct Mount {
1313
fs: *mut Filesystem,
1414
pad3: [u8; 0x38],
1515
flags: u64,
16+
pad4: [u8; 0x20],
17+
stats: FsStats,
1618
}
1719

1820
impl okf::mount::Mount<Kernel> for Mount {
@@ -35,6 +37,10 @@ impl okf::mount::Mount<Kernel> for Mount {
3537
unsafe fn flags(&self) -> u64 {
3638
self.flags
3739
}
40+
41+
fn stats(&self) -> *mut FsStats {
42+
&self.stats as *const FsStats as *mut FsStats
43+
}
3844
}
3945

4046
/// Implementation of [`okf::mount::Filesystem`] for 11.00.
@@ -49,3 +55,11 @@ impl okf::mount::Filesystem for Filesystem {
4955
self.name.as_ptr()
5056
}
5157
}
58+
59+
/// Implementation of [`okf::mount::FsStats`] for 11.00.
60+
#[repr(C)]
61+
pub struct FsStats {
62+
pad: [u8; 0x1d8],
63+
}
64+
65+
impl okf::mount::FsStats for FsStats {}

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use self::fd::OpenFlags;
44
use self::file::File;
55
use self::lock::{LockObject, Mtx};
66
use self::malloc::{Malloc, MallocFlags};
7-
use self::mount::{Filesystem, Mount};
7+
use self::mount::{Filesystem, FsStats, Mount};
88
use self::pcpu::Pcpu;
99
use self::queue::TailQueue;
1010
use self::socket::{SockAddr, Socket};
@@ -55,6 +55,7 @@ pub trait Kernel: MappedKernel {
5555

5656
type File: File;
5757
type Filesystem: Filesystem;
58+
type FsStats: FsStats;
5859
type LockObject: LockObject;
5960
type Malloc: Malloc;
6061
type Mount: Mount<Self>;

src/mount/fs.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use core::ffi::c_char;
2+
3+
/// Represents `vfsconf` structure.
4+
pub trait Filesystem: Sized {
5+
/// Returns `vfc_name`.
6+
fn name(&self) -> *const c_char;
7+
}

src/mount/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
pub use self::fs::*;
2+
pub use self::stats::*;
13
use crate::queue::TailQueueEntry;
24
use crate::Kernel;
3-
use core::ffi::c_char;
5+
6+
mod fs;
7+
mod stats;
48

59
/// Represents `mount` structure.
610
pub trait Mount<K: Kernel>: Sized {
@@ -27,10 +31,7 @@ pub trait Mount<K: Kernel>: Sized {
2731
/// # Safety
2832
/// [`Mount::mtx()`] must be locked.
2933
unsafe fn flags(&self) -> u64;
30-
}
3134

32-
/// Represents `vfsconf` structure.
33-
pub trait Filesystem: Sized {
34-
/// Returns `vfc_name`.
35-
fn name(&self) -> *const c_char;
35+
/// Returns `mnt_stat`.
36+
fn stats(&self) -> *mut K::FsStats;
3637
}

src/mount/stats.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// Represents `statfs` structure.
2+
pub trait FsStats: Sized {}

0 commit comments

Comments
 (0)