Skip to content

Commit 35d3055

Browse files
committed
Adds v_op
1 parent 921db80 commit 35d3055

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

kernel-1100/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use self::socket::Socket;
99
use self::thread::Thread;
1010
use self::ucred::Ucred;
1111
use self::uio::Uio;
12-
use self::vnode::{Vnode, VnodeOp, VopUnlock};
12+
use self::vnode::{Vnode, VnodeOp, VopUnlock, VopVector};
1313
use core::ffi::{c_char, c_int};
1414
use core::num::NonZero;
1515
use okf::fd::OpenFlags;
@@ -68,6 +68,7 @@ impl okf::Kernel for Kernel {
6868
type Vnode = Vnode;
6969
type VnodeOp = VnodeOp;
7070
type VopUnlock = VopUnlock;
71+
type VopVector = VopVector;
7172

7273
#[offset(0x419040)]
7374
unsafe fn fget(

kernel-1100/src/vnode.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1+
use crate::Kernel;
12
use core::ffi::c_int;
23

34
/// Implementation of [`okf::vnode::Vnode`] for 11.00.
45
#[repr(C)]
5-
pub struct Vnode {}
6+
pub struct Vnode {
7+
pad1: [u8; 0x10],
8+
ops: *mut VopVector,
9+
}
10+
11+
impl okf::vnode::Vnode<Kernel> for Vnode {
12+
fn ops(&self) -> &'static VopVector {
13+
unsafe { &*self.ops }
14+
}
15+
}
16+
17+
/// Implementation of [`okf::vnode::VopVector`] for 11.00.
18+
#[repr(C)]
19+
pub struct VopVector {}
620

7-
impl okf::vnode::Vnode for Vnode {}
21+
impl okf::vnode::VopVector for VopVector {}
822

923
/// Implementation of [`okf::vnode::VnodeOp`] for 11.00.
1024
#[repr(C)]

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use self::socket::{SockAddr, Socket};
1111
use self::thread::Thread;
1212
use self::ucred::Ucred;
1313
use self::uio::{Uio, UioSeg};
14-
use self::vnode::{Vnode, VnodeOp, VopUnlock};
14+
use self::vnode::{Vnode, VnodeOp, VopUnlock, VopVector};
1515
use core::alloc::{GlobalAlloc, Layout};
1616
use core::ffi::{c_char, c_int};
1717
use core::marker::PhantomData;
@@ -72,9 +72,10 @@ pub trait Kernel: MappedKernel {
7272
type Thread: Thread<Self>;
7373
type Ucred: Ucred;
7474
type Uio: Uio<Self>;
75-
type Vnode: Vnode;
75+
type Vnode: Vnode<Self>;
7676
type VnodeOp: VnodeOp;
7777
type VopUnlock: VopUnlock;
78+
type VopVector: VopVector;
7879

7980
fn var<O: StaticOff>(self, off: O) -> O::Ops {
8081
let value = unsafe { self.addr().add(off.value()) };

src/vnode/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
pub use self::op::*;
2+
use crate::Kernel;
23

34
mod op;
45

56
/// Represents `vnode` structure.
6-
pub trait Vnode: Sized {}
7+
pub trait Vnode<K: Kernel>: Sized {
8+
/// Returns `v_op`.
9+
fn ops(&self) -> &'static K::VopVector;
10+
}
11+
12+
/// Represents `vop_vector` structure.
13+
pub trait VopVector: Sized {}

0 commit comments

Comments
 (0)