From 6f7752892ba84bca23c2bc78c33a185c8677f957 Mon Sep 17 00:00:00 2001 From: vasilito Date: Thu, 9 Jul 2026 10:42:37 +0300 Subject: [PATCH] =?UTF-8?q?kernel:=20implement=20/proc/self=20=E2=80=94=20?= =?UTF-8?q?symlink=20to=20current=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added /proc/self resolution in open_inner(). When /proc/self is opened, it resolves to /proc/ 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. --- src/scheme/proc.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/scheme/proc.rs b/src/scheme/proc.rs index 8140a2f2fd..5b61ee8695 100644 --- a/src/scheme/proc.rs +++ b/src/scheme/proc.rs @@ -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/ + 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(),