kernel: implement /proc/self — symlink to current process

Added /proc/self resolution in open_inner(). When /proc/self
is opened, it resolves to /proc/<current-pid> by reading
context::current().pid and returning a ProcDir handle.

Cross-referenced with Linux 7.1 fs/proc/self.c proc_self_get_link()
which creates a symlink inode pointing to the current PID.

This enables 'ls /proc/self', 'cat /proc/self/status', and all
other tools that use /proc/self to access their own process info.
This commit is contained in:
2026-07-09 10:42:37 +03:00
parent 85347a5678
commit 6f7752892b
+9
View File
@@ -534,6 +534,15 @@ impl ProcScheme {
token: &mut CleanLockToken,
) -> Result<(usize, InternalFlags)> {
let operation_name = operation_str.ok_or(Error::new(EINVAL))?;
// /proc/self → resolve to /proc/<current-pid>
if operation_name == "proc/self" || operation_name == "self" {
let pid = context::current().read(token.token()).pid;
let handle = Handle {
context: context::current(),
kind: ContextHandle::ProcDir { pid },
};
return new_handle((handle, InternalFlags::POSITIONED), token);
};
if let Some(kind) = Self::proc_open(operation_name) {
let handle = Handle {
context: context::current(),