Skip to content

Commit 7c650a1

Browse files
committed
Adds mnt_mtx
1 parent f2f01a1 commit 7c650a1

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

kernel-1100/src/mount.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
1+
use crate::lock::Mtx;
2+
use crate::Kernel;
13
use okf::queue::TailQueueEntry;
24

35
/// Implementation of [`okf::mount::Mount`] for 11.00.
46
#[repr(C)]
57
pub struct Mount {
6-
pad1: [u8; 0x28],
8+
mtx: Mtx,
9+
pad1: [u8; 0x8],
710
entry: TailQueueEntry<Self>,
811
pad2: [u8; 0x48],
912
flags: u64,
1013
}
1114

12-
impl okf::mount::Mount for Mount {
13-
fn entry(&self) -> &TailQueueEntry<Self> {
15+
impl okf::mount::Mount<Kernel> for Mount {
16+
fn mtx(&self) -> *mut Mtx {
17+
&self.mtx as *const Mtx as *mut Mtx
18+
}
19+
20+
unsafe fn entry(&self) -> &TailQueueEntry<Self> {
1421
&self.entry
1522
}
1623

17-
fn entry_mut(&mut self) -> &mut TailQueueEntry<Self> {
24+
unsafe fn entry_mut(&mut self) -> &mut TailQueueEntry<Self> {
1825
&mut self.entry
1926
}
2027

21-
fn flags(&self) -> u64 {
28+
unsafe fn flags(&self) -> u64 {
2229
self.flags
2330
}
2431
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub trait Kernel: MappedKernel {
5555
type File: File;
5656
type LockObject: LockObject;
5757
type Malloc: Malloc;
58-
type Mount: Mount;
58+
type Mount: Mount<Self>;
5959
type Mtx: Mtx<Self>;
6060
type Pcpu: Pcpu<Self>;
6161
type Socket: Socket;

src/mount/mod.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
use crate::queue::TailQueueEntry;
2+
use crate::Kernel;
23

34
/// Represents `mount` structure.
4-
pub trait Mount: Sized {
5+
pub trait Mount<K: Kernel>: Sized {
6+
/// Returns `mnt_mtx`.
7+
fn mtx(&self) -> *mut K::Mtx;
8+
59
/// Returns `mnt_list`.
6-
fn entry(&self) -> &TailQueueEntry<Self>;
10+
///
11+
/// # Safety
12+
/// [`Kernel::MOUNTLIST_MTX`] must be locked.
13+
unsafe fn entry(&self) -> &TailQueueEntry<Self>;
714

815
/// Returns mutable `mnt_list`.
9-
fn entry_mut(&mut self) -> &mut TailQueueEntry<Self>;
16+
///
17+
/// # Safety
18+
/// [`Kernel::MOUNTLIST_MTX`] must be locked.
19+
unsafe fn entry_mut(&mut self) -> &mut TailQueueEntry<Self>;
1020

1121
/// Returns the value of `mnt_flag`.
12-
fn flags(&self) -> u64;
22+
///
23+
/// # Safety
24+
/// [`Mount::mtx()`] must be locked.
25+
unsafe fn flags(&self) -> u64;
1326
}

0 commit comments

Comments
 (0)