Skip to content

Commit d9406b3

Browse files
rust: task: use safe macro
1 parent 8f7e376 commit d9406b3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

rust/kernel/task.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl Task {
164164
/// Returns the given task's pid in the current pid namespace.
165165
pub fn pid_in_current_ns(&self) -> Pid {
166166
// SAFETY: Calling `task_active_pid_ns` with the current task is always safe.
167-
let namespace = unsafe { bindings::task_active_pid_ns(bindings::get_current()) };
167+
let namespace = unsafe { bindings::task_active_pid_ns(current!()) };
168168
// SAFETY: We know that `self.0.get()` is valid by the type invariant.
169169
unsafe { bindings::task_tgid_nr_ns(self.0.get(), namespace) }
170170
}
@@ -176,6 +176,15 @@ impl Task {
176176
// running.
177177
unsafe { bindings::wake_up_process(self.0.get()) };
178178
}
179+
180+
/// Returns a raw pointer to the underlying C task struct.
181+
///
182+
/// # Safety
183+
///
184+
/// Callers must ensure that the pointer is not used after `Task` is invalidated.
185+
pub unsafe fn as_raw(&self) -> *const bindings::task_struct {
186+
self.0.get()
187+
}
179188
}
180189

181190
impl Kuid {

0 commit comments

Comments
 (0)