Skip to content

Commit ac314c1

Browse files
committed
Adds componentname
1 parent dc4ca4d commit ac314c1

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

kernel-1100/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use self::file::File;
44
use self::lock::{LockObject, Mtx};
55
use self::malloc::Malloc;
66
use self::mount::{Filesystem, FsOps, FsStats, Mount};
7+
use self::namei::ComponentName;
78
use self::pcpu::Pcpu;
89
use self::socket::Socket;
910
use self::thread::Thread;
@@ -23,6 +24,7 @@ mod file;
2324
mod lock;
2425
mod malloc;
2526
mod mount;
27+
mod namei;
2628
mod pcpu;
2729
mod socket;
2830
mod thread;
@@ -60,6 +62,7 @@ impl okf::Kernel for Kernel {
6062
#[offset(0x1534360)]
6163
const VOP_UNLOCK: StaticMut<Self::VnodeOp>;
6264

65+
type ComponentName = ComponentName;
6366
type File = File;
6467
type Filesystem = Filesystem;
6568
type FsOps = FsOps;

kernel-1100/src/namei.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use crate::thread::Thread;
2+
use crate::ucred::Ucred;
3+
use core::ffi::{c_char, c_int};
4+
use okf::Kernel;
5+
6+
/// Implementation of [`okf::namei::ComponentName`] for 11.00.
7+
#[repr(C)]
8+
pub struct ComponentName {
9+
op: u64,
10+
flags: u64,
11+
td: *mut Thread,
12+
cred: *mut Ucred,
13+
lk: c_int,
14+
buf: *mut c_char,
15+
name: *mut c_char,
16+
len: isize,
17+
consume: isize,
18+
}
19+
20+
impl okf::namei::ComponentName<crate::Kernel> for ComponentName {
21+
unsafe fn new(k: crate::Kernel, op: u64, lk: c_int, buf: *mut c_char, td: *mut Thread) -> Self {
22+
use okf::thread::Thread;
23+
24+
Self {
25+
op,
26+
flags: 0,
27+
td,
28+
cred: (*td).cred(),
29+
lk,
30+
buf,
31+
name: buf,
32+
len: k.strlen(buf) as _,
33+
consume: 0,
34+
}
35+
}
36+
}

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use self::file::File;
55
use self::lock::{LockObject, Mtx};
66
use self::malloc::{Malloc, MallocFlags};
77
use self::mount::{Filesystem, FsOps, FsStats, Mount};
8+
use self::namei::ComponentName;
89
use self::pcpu::Pcpu;
910
use self::queue::TailQueue;
1011
use self::socket::{SockAddr, Socket};
@@ -25,6 +26,7 @@ pub mod file;
2526
pub mod lock;
2627
pub mod malloc;
2728
pub mod mount;
29+
pub mod namei;
2830
pub mod pcpu;
2931
pub mod queue;
3032
pub mod socket;
@@ -64,6 +66,7 @@ pub trait Kernel: MappedKernel {
6466
const VOP_READDIR: StaticMut<Self::VnodeOp>;
6567
const VOP_UNLOCK: StaticMut<Self::VnodeOp>;
6668

69+
type ComponentName: ComponentName<Self>;
6770
type File: File;
6871
type Filesystem: Filesystem;
6972
type FsOps: FsOps<Self>;

src/namei/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use crate::Kernel;
2+
use core::ffi::{c_char, c_int};
3+
4+
/// Represents `componentname` structure.
5+
pub trait ComponentName<K: Kernel>: Sized {
6+
/// # Safety
7+
/// - `buf` cannot be null and must point to a null-terminated string.
8+
/// - `td` cannot be null.
9+
unsafe fn new(k: K, op: u64, lk: c_int, buf: *mut c_char, td: *mut K::Thread) -> Self;
10+
}

0 commit comments

Comments
 (0)