Skip to content

Commit f48a5b2

Browse files
committed
Adds vop_readdir_args
1 parent fe55854 commit f48a5b2

File tree

4 files changed

+59
-8
lines changed

4 files changed

+59
-8
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, VopRead, VopUnlock, VopVector};
12+
use self::vnode::{Vnode, VnodeOp, VopRead, VopReadDir, VopUnlock, VopVector};
1313
use core::ffi::{c_char, c_int};
1414
use core::num::NonZero;
1515
use okf::fd::OpenFlags;
@@ -74,6 +74,7 @@ impl okf::Kernel for Kernel {
7474
type Vnode = Vnode;
7575
type VnodeOp = VnodeOp;
7676
type VopRead = VopRead;
77+
type VopReadDir = VopReadDir;
7778
type VopUnlock = VopUnlock;
7879
type VopVector = VopVector;
7980

kernel-1100/src/vnode.rs

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::ucred::Ucred;
22
use crate::uio::Uio;
3-
use crate::Kernel;
43
use core::ffi::c_int;
4+
use okf::Kernel;
55

66
/// Implementation of [`okf::vnode::Vnode`] for 11.00.
77
#[repr(C)]
@@ -10,7 +10,7 @@ pub struct Vnode {
1010
ops: *mut VopVector,
1111
}
1212

13-
impl okf::vnode::Vnode<Kernel> for Vnode {
13+
impl okf::vnode::Vnode<crate::Kernel> for Vnode {
1414
fn ops(&self) -> *mut VopVector {
1515
self.ops
1616
}
@@ -48,16 +48,14 @@ pub struct VopRead {
4848
cred: *mut Ucred,
4949
}
5050

51-
impl okf::vnode::VopRead<Kernel> for VopRead {
51+
impl okf::vnode::VopRead<crate::Kernel> for VopRead {
5252
unsafe fn new(
53-
k: Kernel,
53+
k: crate::Kernel,
5454
vp: *mut Vnode,
5555
uio: *mut Uio,
5656
flags: c_int,
5757
cred: *mut Ucred,
5858
) -> Self {
59-
use okf::Kernel;
60-
6159
Self {
6260
desc: k.var(crate::Kernel::VOP_READ).ptr(),
6361
vp,
@@ -67,3 +65,37 @@ impl okf::vnode::VopRead<Kernel> for VopRead {
6765
}
6866
}
6967
}
68+
69+
/// Implementation of [`okf::vnode::VopReadDir`] for 11.00.
70+
#[repr(C)]
71+
pub struct VopReadDir {
72+
desc: *mut VnodeOp,
73+
vp: *mut Vnode,
74+
uio: *mut Uio,
75+
cred: *mut Ucred,
76+
eof: *mut c_int,
77+
ncookies: *mut c_int,
78+
cookies: *mut *mut u64,
79+
}
80+
81+
impl okf::vnode::VopReadDir<crate::Kernel> for VopReadDir {
82+
unsafe fn new(
83+
k: crate::Kernel,
84+
vp: *mut Vnode,
85+
uio: *mut Uio,
86+
cred: *mut Ucred,
87+
eof: *mut c_int,
88+
ncookies: *mut c_int,
89+
cookies: *mut *mut u64,
90+
) -> Self {
91+
Self {
92+
desc: k.var(crate::Kernel::VOP_READDIR).ptr(),
93+
vp,
94+
uio,
95+
cred,
96+
eof,
97+
ncookies,
98+
cookies,
99+
}
100+
}
101+
}

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, VopRead, VopUnlock, VopVector};
14+
use self::vnode::{Vnode, VnodeOp, VopRead, VopReadDir, VopUnlock, VopVector};
1515
use core::alloc::{GlobalAlloc, Layout};
1616
use core::ffi::{c_char, c_int};
1717
use core::marker::PhantomData;
@@ -78,6 +78,7 @@ pub trait Kernel: MappedKernel {
7878
type Vnode: Vnode<Self>;
7979
type VnodeOp: VnodeOp;
8080
type VopRead: VopRead<Self>;
81+
type VopReadDir: VopReadDir<Self>;
8182
type VopUnlock: VopUnlock;
8283
type VopVector: VopVector;
8384

src/vnode/op.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,20 @@ pub trait VopRead<K: Kernel>: Sized {
2121
cred: *mut K::Ucred,
2222
) -> Self;
2323
}
24+
25+
/// Represents `vop_readdir_args` structure.
26+
pub trait VopReadDir<K: Kernel>: Sized {
27+
/// # Safety
28+
/// - `vp` cannot be null and must be locked.
29+
/// - `uio` cannot be null.
30+
/// - `cred` cannot be null.
31+
unsafe fn new(
32+
k: K,
33+
vp: *mut K::Vnode,
34+
uio: *mut K::Uio,
35+
cred: *mut K::Ucred,
36+
eof: *mut c_int,
37+
ncookies: *mut c_int,
38+
cookies: *mut *mut u64,
39+
) -> Self;
40+
}

0 commit comments

Comments
 (0)