Skip to content

Commit c2dfb47

Browse files
committed
Adds vop_read_args
1 parent 0ff5267 commit c2dfb47

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
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, VopVector};
12+
use self::vnode::{Vnode, VnodeOp, VopRead, VopUnlock, VopVector};
1313
use core::ffi::{c_char, c_int};
1414
use core::num::NonZero;
1515
use okf::fd::OpenFlags;
@@ -71,6 +71,7 @@ impl okf::Kernel for Kernel {
7171
type Uio = Uio;
7272
type Vnode = Vnode;
7373
type VnodeOp = VnodeOp;
74+
type VopRead = VopRead;
7475
type VopUnlock = VopUnlock;
7576
type VopVector = VopVector;
7677

kernel-1100/src/vnode.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use crate::ucred::Ucred;
2+
use crate::uio::Uio;
13
use crate::Kernel;
24
use core::ffi::c_int;
35

@@ -35,3 +37,33 @@ pub struct VopUnlock {
3537
}
3638

3739
impl okf::vnode::VopUnlock for VopUnlock {}
40+
41+
/// Implementation of [`okf::vnode::VopRead`] for 11.00.
42+
#[repr(C)]
43+
pub struct VopRead {
44+
desc: *mut VnodeOp,
45+
vp: *mut Vnode,
46+
uio: *mut Uio,
47+
flags: c_int,
48+
cred: *mut Ucred,
49+
}
50+
51+
impl okf::vnode::VopRead<Kernel> for VopRead {
52+
unsafe fn new(
53+
k: Kernel,
54+
vp: *mut Vnode,
55+
uio: *mut Uio,
56+
flags: c_int,
57+
cred: *mut Ucred,
58+
) -> Self {
59+
use okf::Kernel;
60+
61+
Self {
62+
desc: k.var(crate::Kernel::VOP_READ).ptr(),
63+
vp,
64+
uio,
65+
flags,
66+
cred,
67+
}
68+
}
69+
}

src/lib.rs

Lines changed: 2 additions & 1 deletion
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, VopVector};
14+
use self::vnode::{Vnode, VnodeOp, VopRead, VopUnlock, VopVector};
1515
use core::alloc::{GlobalAlloc, Layout};
1616
use core::ffi::{c_char, c_int};
1717
use core::marker::PhantomData;
@@ -77,6 +77,7 @@ pub trait Kernel: MappedKernel {
7777
type Uio: Uio<Self>;
7878
type Vnode: Vnode<Self>;
7979
type VnodeOp: VnodeOp;
80+
type VopRead: VopRead<Self>;
8081
type VopUnlock: VopUnlock;
8182
type VopVector: VopVector;
8283

src/vnode/op.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1+
use crate::Kernel;
2+
use core::ffi::c_int;
3+
14
/// Represents `vnodeop_desc` structure.
25
pub trait VnodeOp: Sized {}
36

47
/// Represents `vop_unlock_args` structure.
58
pub trait VopUnlock: Sized {}
9+
10+
/// Represents `vop_read_args` structure.
11+
pub trait VopRead<K: Kernel>: Sized {
12+
/// # Safety
13+
/// - `vp` cannot be null and must be locked.
14+
/// - `uio` cannot be null.
15+
/// - `cred` cannot be null.
16+
unsafe fn new(
17+
k: K,
18+
vp: *mut K::Vnode,
19+
uio: *mut K::Uio,
20+
flags: c_int,
21+
cred: *mut K::Ucred,
22+
) -> Self;
23+
}

0 commit comments

Comments
 (0)