Skip to content

Commit 6ef7721

Browse files
committed
Adds vop_lookup_args
1 parent 4cdc7d6 commit 6ef7721

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

kernel-1100/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use self::socket::Socket;
1010
use self::thread::Thread;
1111
use self::ucred::Ucred;
1212
use self::uio::Uio;
13-
use self::vnode::{Vnode, VnodeOp, VopRead, VopReadDir, VopUnlock, VopVector};
13+
use self::vnode::{Vnode, VnodeOp, VopLookup, VopRead, VopReadDir, VopUnlock, VopVector};
1414
use core::ffi::{c_char, c_int};
1515
use core::num::NonZero;
1616
use okf::fd::OpenFlags;
@@ -80,6 +80,7 @@ impl okf::Kernel for Kernel {
8080
type Uio = Uio;
8181
type Vnode = Vnode;
8282
type VnodeOp = VnodeOp;
83+
type VopLookup = VopLookup;
8384
type VopRead = VopRead;
8485
type VopReadDir = VopReadDir;
8586
type VopUnlock = VopUnlock;

kernel-1100/src/vnode.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::namei::ComponentName;
12
use crate::ucred::Ucred;
23
use crate::uio::Uio;
34
use core::ffi::c_int;
@@ -104,3 +105,28 @@ impl okf::vnode::VopReadDir<crate::Kernel> for VopReadDir {
104105
}
105106
}
106107
}
108+
109+
/// Implementation of [`okf::vnode::VopLookup`] for 11.00.
110+
#[repr(C)]
111+
pub struct VopLookup {
112+
desc: *mut VnodeOp,
113+
vp: *mut Vnode,
114+
out: *mut *mut Vnode,
115+
cn: *mut ComponentName,
116+
}
117+
118+
impl okf::vnode::VopLookup<crate::Kernel> for VopLookup {
119+
unsafe fn new(
120+
k: crate::Kernel,
121+
vp: *mut Vnode,
122+
out: *mut *mut Vnode,
123+
cn: *mut ComponentName,
124+
) -> Self {
125+
Self {
126+
desc: k.var(crate::Kernel::VOP_LOOKUP).ptr(),
127+
vp,
128+
out,
129+
cn,
130+
}
131+
}
132+
}

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use self::socket::{SockAddr, Socket};
1212
use self::thread::Thread;
1313
use self::ucred::Ucred;
1414
use self::uio::{Uio, UioSeg};
15-
use self::vnode::{Vnode, VnodeOp, VopRead, VopReadDir, VopUnlock, VopVector};
15+
use self::vnode::{Vnode, VnodeOp, VopLookup, VopRead, VopReadDir, VopUnlock, VopVector};
1616
use core::alloc::{GlobalAlloc, Layout};
1717
use core::ffi::{c_char, c_int};
1818
use core::marker::PhantomData;
@@ -83,6 +83,7 @@ pub trait Kernel: MappedKernel {
8383
type Uio: Uio<Self>;
8484
type Vnode: Vnode<Self>;
8585
type VnodeOp: VnodeOp;
86+
type VopLookup: VopLookup<Self>;
8687
type VopRead: VopRead<Self>;
8788
type VopReadDir: VopReadDir<Self>;
8889
type VopUnlock: VopUnlock;

src/vnode/op.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,17 @@ pub trait VopReadDir<K: Kernel>: Sized {
3838
cookies: *mut *mut u64,
3939
) -> Self;
4040
}
41+
42+
/// Represents `vop_lookup_args` structure.
43+
pub trait VopLookup<K: Kernel>: Sized {
44+
/// # Safety
45+
/// - `vp` cannot be null and must be locked.
46+
/// - `out` cannot be null.
47+
/// - `cn` cannot be null.
48+
unsafe fn new(
49+
k: K,
50+
vp: *mut K::Vnode,
51+
out: *mut *mut K::Vnode,
52+
cn: *mut K::ComponentName,
53+
) -> Self;
54+
}

0 commit comments

Comments
 (0)